Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/lua
sh = function(...)
local cmd = table.concat({...}, ' ')
return os.execute(cmd)
end
shout = function(...)
local cmd = table.concat({...}, ' ')
local out = assert(io.popen(cmd)):read '*all'
assert(type(out) == 'string')
@greatwolf
greatwolf / Lua_Build-MinGW|w64devkit.md
Last active September 9, 2024 05:50
Building and Packaging Lua from source using MinGW | w64devkit

Compile Lua src

Start MSYS/MinGW32 shell

msys64/msys2_shell.cmd -mingw32

or

w64devkit.exe

Go into base directory and make

@greatwolf
greatwolf / oci-cli_usage.md
Last active September 2, 2024 02:46
Notes and cmd snippets on how to use OCI-CLI.

Setting up OCI-CLI API key

  1. Log into cloud.oracle.com
  2. From upper-right corner click Profile -> My Profile
  3. From lower-left section find Resources -> API keys
  4. Click 'Add API key' and paste public key in PEM format
  5. Copy and save displayed configuration into ~/.oci/config

Note: Get a suitable public key PEM for step 4 from an existing private key with:

ssh-keygen -e -m PKCS8 -f oci_api_privkey.pem
@greatwolf
greatwolf / aws-signal-setup.lua
Last active September 12, 2024 20:31
Setup Signal + Shadowsocks Proxy on AWS using Lua
#!/usr/bin/env lua
server_domain = assert(..., 'Pass server domain as first argument')
-- Convenience functions for running shell commands
sh = os.execute
shout = function(cmd)
local out = assert(io.popen(cmd)):read '*all'
assert(type(out) == 'string')
return out:sub(0, -2) -- drop trailing newline
end
@greatwolf
greatwolf / chromeappid_patch.lua
Last active May 16, 2025 10:03
Allow deprecated Chrome Apps to work again on latest Chromium version
#!/usr/bin/lua
-- This script replaces one of the extension ids hardcoded in Chromium
-- with our own desired app extension id so it can function again.
-- See https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/web_applications/extensions/extension_status_utils.cc;l=30
local filename = ...
assert(filename, "missing filename")
local file = assert(io.open(filename, 'r+b'))
local bin = file:read '*a'
local kk_appid = 'idgiipeogajjpkgheijapngmlbohdhjg'
@greatwolf
greatwolf / camenduru_webui_colab-stable.sh
Last active September 14, 2023 07:47
camenduru_webui_colab stable
#From https://github.com/camenduru/stable-diffusion-webui-colab
#Modified to use user selected model checkpoint passed in as first argument
cd /content
env TF_CPP_MIN_LOG_LEVEL=1
apt -y update -qq
wget https://github.com/camenduru/gperftools/releases/download/v1.0/libtcmalloc_minimal.so.4 -O /content/libtcmalloc_minimal.so.4
env LD_PRELOAD=/content/libtcmalloc_minimal.so.4
@greatwolf
greatwolf / patch_konsolecursor.lua
Last active June 30, 2023 06:47
Lua script to force KDE Konsole to use a blinking vertical I cursor shape by default.
#!/usr/bin/lua
--[[
Intended for SteamOS v3.4.8 build 20230508.1.
Usage:
sudo steamos-readonly disable
sudo chmod +x patch_konsolecursor.lua
sudo patch_konsolecursor.lua /usr/lib/libkonsoleprivate.so.22.08.2
sudo steamos-readonly enable

Keybase proof

I hereby claim:

  • I am greatwolf on github.
  • I am greatwolf (https://keybase.io/greatwolf) on keybase.
  • I have a public key whose fingerprint is D92A 7BD0 33DD 16FF E492 C6F7 949E 25AC 2A21 57D4

To claim this, I am signing this object:

@greatwolf
greatwolf / luacom-scm.moteus-1.rockspec
Created January 31, 2020 05:16
LuaCOM rockspec modified to build with CMake.
package = "LuaCOM"
version = "scm.moteus-1"
source = {
url = "https://github.com/moteus/luacom/archive/master.zip",
dir = "luacom-master",
}
description = {
summary = "Use COM libraries from Lua",
detailed = [[
LuaCOM is an add-on library to the Lua language that allows Lua programs to use and implement objects that follow Microsoft's Component Object Model (COM) specification and use the ActiveX technology for property access and method calls. ]],
-- Monte Carlo Simulation of state machine in paper
-- Make one attempt to reach state 1000, fail at zero
function attempt (p)
local state = 2
local ups = 1
while state > 0 do
if state > 1000 then
-- attempt succeeded