Skip to content

Instantly share code, notes, and snippets.

include "/usr/share/X11/locale/en_US.UTF-8/Compose"
# IPA
<Multi_key> <i> <g> <s> : "ʔ"
<Multi_key> <i> <s> <h> : "ʃ"
<Multi_key> <i> <j> : "ʒ"
<Multi_key> <i> <t> <h> : "θ"
<Multi_key> <i> <v> <t> <h> : "ð"
<Multi_key> <i> <f> <r> : "ɾ"
<Multi_key> <i> <d> <c> : "ǀ"
local str = 'Test.wat#hi[a[1]=2] Child, Other'
local function clone(t, m)
m = m or {}
if m[t] then
return m[t]
elseif type(t) == 'table' then
local r = {}
m[t] = r
for k, v in pairs(t) do
-- or maybe `metamethod`
instance Add Ratio where
add (Ratio x1 y1) (Ratio x2 y2) = Ratio ((x1 * y2) + (x2 * y1)) (y1 * y2)
local function formArguments( class, target )
local reg = class:getRegistry()
local constructor, alias, args = reg.constructor, reg.alias, target.arguments
local returnArguments, trailingTable = {n=0;}, {}
if not constructor then return nil end
local argumentTypes = constructor.argumentTypes
local ordered, set, target = constructor.orderedArguments, {}
for i = 1, #ordered do
local VFS = {
['test'] = 'hello?\nwho\'s there?';
}
VFS_ENV.fs = setmetatable({}, { __index = fs })
function VFS_ENV.fs.open(path, mode)
local handle = {}
if mode == 'r' then
if VFS[path] then
local data = VFS[path]
-- outside is a ResourceContext for outside the application
-- inside is a ResourceContext for the application bundle
-- all these are bundled
local img = ImageParser.parse(inside.get('test-image.whatever-extension-here'))
local masterTheme = Theme.fromFile(inside.get('ui/master.theme'))
local layout = Layout.fromFile(inside.get('ui/master.tml'))
-- this is bundled
local api = CCAPI.load(inside.get('api'), outside)
@CoderPuppy
CoderPuppy / hbomb79-vfs.lua
Last active July 28, 2016 01:16
Some VFS code for hbomb79
local VFS_ENV = setmetatable({
TEST_VAR = "TEST_VAR_VALUE";
}, {__index = _ENV or getfenv()})
VFS_ENV._G = VFS_ENV
VFS_ENV._ENV = VFS_ENV
function VFS_ENV.load(src, name, mode, env)
return load(src, name or '(load)', mode, env or VFS_ENV)
end
@CoderPuppy
CoderPuppy / demhydraz-lazy.lua
Created July 25, 2016 03:58
Lazy streams with coroutines
local function pull(c)
if coroutine.status(c) == 'dead' then
return false
else
local ok, res = coroutine.resume(c)
if coroutine.status(c) == 'dead' then
return false
elseif ok then
return true, res
else
def subsets(s, n, l):
if len(s) == 0 and n == 0:
l.append([])
return
if len(s) == 0:
return
h, *t = s
supervise([
worker(Buffer, []),
supervisor(Modes, [buffer_pid])
], strategy: :one_for_one)