Skip to content

Instantly share code, notes, and snippets.

---- TRACE 10 start t.lua:62
0011 MOV 9 0
0012 TGETS 8 0 3 ; "getint"
0000 . . FUNCC ; ffi.meta.__index
0013 MOV 10 1
0014 CALL 8 2 3
0000 . FUNCF 6 ; rng.lua:11
0001 . UGET 2 0 ; tonumber
0002 . UGET 3 1 ; gsl
0003 . TGETS 3 3 0 ; "gsl_rng_uniform_int"
$ make
CC src/jltypes.o
CC src/gf.o
FLISP src/julia_flisp.boot
FLISP src/julia_flisp.boot.inc
CC src/ast.o
CC src/builtins.o
CC src/module.o
CC src/codegen.o
CC src/interpreter.o
@pygy
pygy / lutn.lua
Last active October 12, 2021 08:01
lutn: Load a JSON-like Lua expression, securely. (see also: ltin)
-- Loads a single Lua expression as a JSON-like document, securely.
-- function expressions are prohibited, and the __index of the
-- strings metatable is temporarily stripped or replaced.
-- see also: ltin
-- usage:
-- lutn = require "lutn"
-- result = lutn(source_string [, environment = nil] [, string_metatable_index = nil])
@pygy
pygy / utf-8.lua
Last active March 11, 2021 01:28
UTF-8 encoder/decoder in Lua
local
function utf8_to_codepoint (stream, i)
-- returns the codepoint and the index of the next character in the stream.
local msB = string.byte(stream, i)
local b2, b1, b0
if msB < 128 then return msB, i + 1
elseif msB < 192 then
error("Byte values between 0x80 to 0xBF cannot start a multibyte sequence")
@pygy
pygy / gist:7034063
Created October 17, 2013 23:22
SocketStream grunt log
This file has been truncated, but you can view the full file.
Running "jshint:server" (jshint) task
Linting test/fixtures/project/app.js ...ERROR
[L13:C3] E007: Missing "use strict" statement.
res.serve('main');
Linting test/fixtures/project/app.js ...ERROR
[L25:C12] W116: Expected '===' and instead saw '=='.
if (ss.env == 'production') ss.client.packAssets();
Linting test/fixtures/project/app.js ...ERROR
[L25:C29] W116: Expected '{' and instead saw 'ss'.
if (ss.env == 'production') ss.client.packAssets();
@pygy
pygy / lpeg-brief.md
Last active December 16, 2015 20:59

Brief introduction to LPEG

LPEG is a library for operating on patterns. It is not an alternative to the Lua string library, but it can be used to implement libraries rather like the string library instead of doing it directly in C.

Some words mean very specific things to LPEG.

##### string
A Lua string, consisting of an arbitrary sequence of bytes. On many systems, one could say "characters" instead.
@pygy
pygy / PureLPeg.lua
Last active December 15, 2015 20:40
-- A more complete version is now available here:
-- https://github.com/pygy/LuLPeg
-- PureLPeg.lua
-- a WIP LPeg implementation in pure Lua, by Pierre-Yves Gérardy
-- released under the Romantic WTF Public License (see the end of the file).
-- Captures and locales are not yet implemented, but the rest works quite well.
-- UTF-8 is supported out of the box
--
@pygy
pygy / Errors
Created September 29, 2012 19:23
Build errors log of Slate.app on OS X 10.6.
/Volumes/Data HD/Downloads/slate/Slate/SlateAppDelegate.m:96:80: error: use of undeclared identifier '__bridge'
/Volumes/Data HD/Downloads/slate/Slate/SlateAppDelegate.m:97:96: error: use of undeclared identifier '__bridge'
/Volumes/Data HD/Downloads/slate/Slate/SlateAppDelegate.m:187:105: error: use of undeclared identifier '__bridge'
/Volumes/Data HD/Downloads/slate/Slate/SlateAppDelegate.m:200:71: error: use of undeclared identifier 'keyUpSeen'
/Volumes/Data HD/Downloads/slate/Slate/SlateAppDelegate.m:247:34: error: use of undeclared identifier '__bridge'
/Volumes/Data HD/Downloads/slate/Slate/SlateAppDelegate.m:262:34: error: use of undeclared identifier '__bridge'
/Volumes/Data HD/Downloads/slate/Slate/SlateAppDelegate.m:298:10: error: use of undeclared identifier '__bridge'
/Volumes/Data HD/Downloads/slate/Slate/SlateAppDelegate.m:301:12: error: use of undeclared identifier '__bridge'
/Volumes/Data HD/Downloads/slate/Slate/SlateAppDelegate.m:322:27: error: use of undeclared identifier '__bridge'
/Volume