This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '(' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from shapely.geometry import asShape | |
from simplegeo import context | |
client = context.Client('your-key','your-secret') | |
context_response = client.get_context(37.775255,-122.40289) | |
neighborhoods = [feature for feature in context_response['features'] if feature['classifiers'][0]['category'] == 'Neighborhood'] | |
if neighborhoods: | |
neighborhood_handle = neighborhoods[0]['handle'] | |
neighborhood_boundary = asShape(client.get_feature(neighborhood_handle).to_dict()['geometry']) | |
centroid = neighborhood_boundary.centroid.wkt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
OlderNewer