Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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'.
@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 / 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])
$ 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
---- 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"

Experimental Generation of Interpersonal Closeness

Instructions to Subjects Included With Task Slips Packet

This is a study of interpersonal closeness, and your task, which we think will be quite enjoyable, is simply to get close to your partner. We believe that the best way for you to get close to your partner is for you to share with them and for them to share with you. Of course, when we advise you about getting close to your partner, we are giving advice regarding your behavior in this demonstration only, we are not advising you about your behavior outside of this demonstration.

In order to help you get close we've arranged for the two of you to engage in a kind of sharing game. You're sharing time will be for about one hour, after which time we ask you to fill out a questionnaire concerning your experience of getting close to your partner.

You have been given three sets of slips. Each slip has a question or a task written on it. As soon as you both finish reading these instructions, you should