Skip to content

Instantly share code, notes, and snippets.

View dlo's full-sized avatar
Always shipping.

Dan Loewenherz dlo

Always shipping.
View GitHub Profile
@dlo
dlo / gevent-socketio.py
Created October 5, 2011 18:13
Socket.IO server-side implementations
class Application(object):
greenlet = None
def __call__(self, environ, start_response):
path = environ['PATH_INFO'].strip('/')
if path.startswith("socket.io"):
socketio = environ['socketio']
while True:
message = socketio.recv()
@dlo
dlo / README.md
Created February 10, 2012 05:54
Array.remove prototype function

This is a small snippet that gives Javascript arrays the (much-needed) ability to remove elements based on value. Example:

items = [1,2,3,3,4,4,5];
items.remove(3); // => [1,2,4,4,5]
@dlo
dlo / README.md
Last active September 30, 2015 20:57
Ubuntu 11.10 & OS X PostGIS Setup Script

Installing PostGIS

Ubuntu 11.10

sudo apt-get install postgresql-9.3-postgis-2.1
sudo su postgres
bash <(curl -s https://gist.githubusercontent.com/dlo/1860599/raw/514276029c43e6e68a2e2164f2a77fd53354b8e9/create_template.sh)

OS X

@dlo
dlo / patch.sh
Last active October 1, 2015 02:18 — forked from lambdalisue/patch.sh
Ubuntu 11.10 Python Image Library (PIL) 1.1.7 installation via pip patch
#!/bin/sh
# Ref: http://ubuntuforums.org/showthread.php?t=1751455
# Uninstall PIL
# sudo pip uninstall PIL -q
# Install required libs
apt-get --yes install build-essential python-dev zlib1g-dev liblcms1-dev libjpeg8 libjpeg62-dev libfreetype6 libfreetype6-dev
# Link to correct location
@tqbf
tqbf / gist:3132713
Created July 17, 2012 22:58
Crypto syllabus #1
0e3647e8592d35514a081243582536ed3de6734059001e3f535ce6271032
334b041de124f73c18011a50e608097ac308ecee501337ec3e100854201d
40e127f51c10031d0133590b1e490f3514e05a54143d08222c2a4071e351
45440b171d5c1b21342e021c3a0eee7373215c4024f0eb733cf006e2040c
22015e420b07ef21164d5935e82338452f42282c1836e42536284c450de3
043b452e0268e7eb005a080b360f0642e6e342005217ef04a42f3e43113d
581e0829214202063d70030845e5301f5a5212ed0818e22f120b211b171b
ea0b342957394717132307133f143a1357e9ed1f5023034147465c052616
0c300b355c2051373a051851ee154a023723414c023a08171e1b4f17595e
550c3e13e80246320b0bec09362542243be42d1d5d060e203e1a0c66ef48
@josephmosby
josephmosby / gist:4264437
Created December 12, 2012 02:49
Week Two of Ruby on Rails: The Incredible Power of Rails

I have now hit my first "wow" moment with Rails, where I actually understood why it has the following it does. It has raised some questions for me about the pedagogy of Rails, but that is not the language's fault; it is a question for the community.

Rails is fast. Mind-blowingly fast. From my cursory looks at the framework, it is immediately apparent that this was designed from the ground up to give me everything I'm going to inevitably want in a basic web application. And yet, for some reason, it isn't immediately sold that way. It's instead sold with stuff like...

"I'm not even joking when I say this, but I think some of the resources out there make it intentionally hard for non-technical people to start learning."

The above line was from a class on Rails - not a Ruby class, but a Rails class. The class was designed so that you could have no coding experience whatsoever and build an MVP, and it advertises itself as such. I think learning to code, even at the lowest level of difficulty, is a fantast

@dlo
dlo / index.html
Created December 12, 2012 17:11
How to center varying-width elements using HTML and CSS.
<!doctype html>
<html>
<head>
<link rel='stylesheet' src='main.css' />
</head>
<body>
<div class='center-outer'>
<div class='center-inner'>
This is a test. <img src='http://placehold.it/200x200' /> And an image.
</div>
@dlo
dlo / gist:4331171
Created December 18, 2012 19:34 — forked from anonymous/gist:4331127
40 random alphanumeric characters in Python
''.join(random.sample(string.letters+string.digits, 40))
anonymous
anonymous / gist:4331127
Created December 18, 2012 19:27
40 Random Letters and Numbers
''.join(random.sample(string.letters+string.digits, 40))
@dlo
dlo / README.md
Created December 20, 2012 04:42
Apple Crash Report Cleanup Script

A lot of the time, crash reports sent via email get a bit garbled over the wire, and Xcode won't symbolicate them. It turns out that a lot of email clients (including Apple Mail) are the cause of this.

This script takes a crash report and cleans it up so that Xcode likes it.

Usage:

$ cat example.crash | cleanup.py