Skip to content

Instantly share code, notes, and snippets.

@honewatson
honewatson / peg.py
Created September 16, 2016 00:30 — forked from orlp/peg.py
PEG parser in Python.
from __future__ import unicode_literals
import sys
# We only use unicode in our parser, except for __repr__, which must return str.
if sys.version_info.major == 2:
repr_str = lambda s: s.encode("utf-8")
str = unicode
else:
repr_str = lambda s: s
@honewatson
honewatson / access.lua
Created August 13, 2016 21:19 — forked from josegonzalez/access.lua
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_lua.
- certain endpoints are always blocked
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then
ngx.exit(403)
end
-- import requirements
local cjson = require "cjson"
-- setup some app-level vars
local app_id = "APP_ID"
@honewatson
honewatson / LUA unserialize
Created April 19, 2016 23:27 — forked from cristobal/LUA unserialize
Lua php unserialize port
--[[
LUA variant of the php unserialize function
Port of http://phpjs.org/functions/unserialize
]]--
local function unserialize (data)
local function utf8Overhead (chr)
local code = chr:byte()
if (code < 0x0080) then
return 0
@honewatson
honewatson / queries.sql
Created April 5, 2016 23:50 — forked from whodidthis/queries.sql
YES for pgmoon too, because YeSQL
-- name: get_cools
SELECT *
FROM cools
-- name: insert_a_cool
INSERT INTO cools
(name, why)
VALUES
(?, ?)
RETURNING level