Skip to content

Instantly share code, notes, and snippets.

View schuyler's full-sized avatar

Schuyler Erle schuyler

View GitHub Profile
@schuyler
schuyler / gist:137537
Created June 29, 2009 09:05
scheduler patch for RapidSMS
diff --git a/lib/rapidsms/router.py b/lib/rapidsms/router.py
index 0785499..ddecd0a 100644
--- a/lib/rapidsms/router.py
+++ b/lib/rapidsms/router.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4
-import time, datetime, os
+import time, datetime, os, heapq
description "ruby_app"
# start on runlevel [2345]
# stop on runlevel [!2345]
expect fork
respawn
env APP_CFG=/etc/app/config
exec /usr/bin/thin -C /etc/app/thin.yml -R /etc/app/thin.ru start
@schuyler
schuyler / primes.clj
Created January 31, 2011 21:39
why is this not evaluated lazily?
(defn divisible-by? [n factors] (some #(zero? (rem n %)) factors))
(defn next-prime [factors] (first (drop-while #(divisible-by? % factors) (iterate inc (first factors)))))
(defn primes [factors] (lazy-seq (primes (cons (next-prime factors) factors))))
this_kind_of_error = "breaks things unexpectedly"
i_object = {}
i_object["#{this_kind_of_error}"] = "OK so far"
another_object = {"#{this_kind_of_error}": "this is not what I expected"}
"""
$ coffee -c unexpected_paren.coffee
Error: In unexpected_paren.coffee, Parse error on line 6: Unexpected '('
@schuyler
schuyler / pyrolite.py
Created April 29, 2011 19:33
Some overengineered code for taking a bounding box and computing its constituent geohashes
import math
import geohash as ghash
WGS84_RADIUS = 6370997.0 # meters
METERS_PER_DEGREE = WGS84_RADIUS * 2 * math.pi / 360.0
class Point(list):
def __init__(self, latitude, longitude):
list.__init__(self, (latitude, longitude))
@schuyler
schuyler / gist:1420102
Created December 1, 2011 21:42
Converting Ushahidi JSON to GeoJSON
# convert Ushahidi JSON on stdin to GeoJSON on stdout
import json, sys
data = json.load(sys.stdin)
features = []
for item in data["payload"]["incidents"]:
incident = item["incident"]
feature = {
@schuyler
schuyler / .bash_profile
Last active December 14, 2015 20:49
my .bashrc
source .bashrc
if [ `hostname -s` != $MY_LAPTOP ]; then
# reattach or start a new screen. don't make it a login shell.
screen -xRR -ln
fi
@schuyler
schuyler / rack_test.rb
Last active December 15, 2015 05:39
Rack::Test doesn't pass a request body for GET requests?
if env["REQUEST_METHOD"] == "GET"
# merge :params with the query string
if params = env[:params]
params = parse_nested_query(params) if params.is_a?(String)
params.update(parse_nested_query(uri.query))
uri.query = build_nested_query(params)
end
@schuyler
schuyler / feature.sh
Created May 13, 2013 19:36
simple Git workflow script
# Workflow:
#
# 1. feature start 000-new-feature
# 2. git commit -m "here's my new feature"
# 3. feature update
# 4. git commit -m "here's some tests"
# 5. feature diff
# 6. feature finish 000-new-feature
# 7. git push origin master
@schuyler
schuyler / keybase.md
Created January 30, 2017 22:59
Keybase proof

Keybase proof

I hereby claim:

  • I am schuyler on github.
  • I am schuyler (https://keybase.io/schuyler) on keybase.
  • I have a public key ASAmCjm9owN2COQyzkyFqy6HTyJr44Mu-26Ki_RjaF4b1Ao

To claim this, I am signing this object: