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 / surround.md
Created December 25, 2009 23:31
surround.vim reference

Deleting

Text              Command    New Text
---------------   -------    -----------
'Hello W|orld'    ds'        Hello World
(12|3+4*56)/2     ds(        123+4*56/2
<div>fo|o</div>   dst        foo
#!/usr/bin/env python
import web
from openid.consumer.consumer import *
# Store OpenID session variables in memory
store = openid.store.memstore.MemoryStore()
# Get this from the Clickpass website
clickpass_site_key = YOUR_SITE_KEY
@dlo
dlo / gist:326254
Created March 9, 2010 05:18
Django WSGI File
import os
import sys
sys.stdout = sys.stderr
PATH = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.abspath(os.path.join(PATH, '..')))
os.environ['PYTHON_EGG_CACHE'] = '/usr/local/django/python-eggs'
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
dan@jamaica cnn $ python2.6 manage.py test
Traceback (most recent call last):
File "manage.py", line 20, in <module>
execute_from_command_line()
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 429, in execute_from_command_line
utility.execute()
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
def search(n, l):
H = len(l) - 1
L = 0
M = int(H / 2)
while H - L > 1 and n != l[M]:
if n > l[M]:
L = M
else:
H = M
@dlo
dlo / index.py
Created May 4, 2010 22:44
Websockets w/ Tornado
#!/usr/bin/env python
import tornado.httpserver
import tornado.ioloop
import tornado.web
from tornado import websocket
import os
class EchoWebSocket(websocket.WebSocketHandler):
def open(self):
@dlo
dlo / Makefile
Last active October 15, 2021 21:14
A really really simple pong clone.
GLEW_INCLUDE = /opt/local/include
GLEW_LIB = /opt/local/lib
pong: pong.o
gcc -o pong $^ -framework GLUT -framework OpenGL -L$(GLEW_LIB) -lGLEW
.c.o:
gcc -c -o $@ $< -I$(GLEW_INCLUDE)
clean:
#!/usr/bin/env python
#
# Jamie Kirkpatrick, November 2009. <jkp@kirkconsulting.co.uk>
# Released under the BSD license.
#
"""
Experimental code to add asyncronous functionality to WSGI applications
running under the Tornado webserver. Uses greenlet to spin micro-threads
which can be suspended and resumed within a single thread as required.
http://github.com/mxcl/homebrew/blob/master/Library/Formula/wine.rb#L44
==> Environment
HOMEBREW_VERSION: 0.7
HEAD: ad09e7fefb79831657e13572cc3a58fc6d2ab8ec
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: 8-core 64-bit nehalem
Engineering:
Some people
Human Interface Design:
Some other people
Testing:
Hopefully not nobody
Documentation: