Skip to content

Instantly share code, notes, and snippets.

View spro's full-sized avatar
🤙
!

Sean Robertson spro

🤙
!
View GitHub Profile
@spro
spro / nginx_lua.conf
Created September 9, 2013 21:53
Example nginx configuration with a simple Lua script acting at /hello
events {
worker_connections 1024;
}
http {
include mime.types;
server {
listen 8080;
server_name localhost;
@spro
spro / why_spool.sh
Created April 18, 2013 21:44
Follow _why's SPOOL in real time.
#!/bin/sh
# Read _why's SPOOL in real time.
# Requires `lp` and a printer.
BASEURL=http://whytheluckystiff.net
if [ ! -d SPOOL ]; then
mkdir SPOOL
fi
@spro
spro / gist:7c929c5213253e054a04
Created June 17, 2015 07:39
Overly simple REST API with Bottle.py
import bottle
import json
all_people = [
{'name': 'Fred Wilson'},
{'name': 'Fred Durst'},
{'name': 'Fred Astaire'},
]
@bottle.get('/people.json')
Verifying that +spro is my openname (Bitcoin username). https://onename.com/spro
@spro
spro / hipache.nginx.conf
Last active August 29, 2015 14:13
hipache reimplimented in lua in nginx
location / {
set $proxy_to "";
access_by_lua "
local redis = require 'redis'
local red = redis:new()
red:connect('127.0.0.1', 6379)
local headers = ngx.req.get_headers()
local hosts = red:smembers('frontend:' .. headers['host'])
@spro
spro / bookshelf-basic.coffee
Last active August 29, 2015 14:12
Bookshelf.js Examples
knex = require('knex')(client: 'pg', connection: 'postgres:///test1')
bookshelf = require('bookshelf')(knex)
util = require 'util'
inspect = (o) -> console.log util.inspect o.toJSON(), colors: true
# Schema
# ------
User = bookshelf.Model.extend
@spro
spro / counters.coffee
Created September 23, 2014 00:16
React.js test with flux-ish data/action layer and undoable states
D = React.DOM
Button = ({text, action}) ->
D.button(onClick: action, text)
# Views
# ------------------------------------------------------------------------------
# <App>
# - <Counter Collection>
@spro
spro / gist:84f62bcd66207aa1e136
Last active August 29, 2015 14:05
Consul panic
2014/08/21 08:52:13 [INFO] consul.fsm: snapshot created in 23.435us
2014/08/21 08:52:13 [INFO] raft: Starting snapshot up to 8232
2014/08/21 08:52:13 [INFO] snapshot: Creating new snapshot at /tmp/consul/raft/snapshots/2-8232-2014-08-21T08:52:13.72566997-07:00.tmp
2014/08/21 08:52:13 [INFO] raft: Compacting logs from 1 to 8232
panic: runtime error: index out of range
goroutine 30 [running]:
runtime.panic(0x9bdc40, 0xf763fc)
/opt/go/src/pkg/runtime/panic.c:279 +0xf5
encoding/binary.bigEndian.Uint64(0xf8f230, 0x0, 0x0, 0xc208201300)
fs = require 'fs'
util = require 'util'
exec = require('child_process').exec
jsdom = require 'jsdom'
jquery = require 'jquery'
_ = require 'underscore'
# Github APIs require a user agent to be set, so set one by default
request = require('request')

Keybase proof

I hereby claim:

  • I am spro on github.
  • I am spro (https://keybase.io/spro) on keybase.
  • I have a public key whose fingerprint is C66D 0B30 C6AD 364F 48D5 F21F 087C 2F86 D07C 4554

To claim this, I am signing this object: