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
@mislav
mislav / gist:17371
Created October 17, 2008 07:42
haml2erb
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
push_text "<%= #{text.strip} %>"
end
def push_silent(text, can_suppress = false)
push_text "<% #{text.strip} %>"
end
end
@jkp
jkp / wsgi_async.py
Created November 22, 2009 13:54
Experimental code to add async functionality to WSGI applications running under Tornado
#!/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.
@defunkt
defunkt / clients.md
Created April 18, 2010 14:09
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@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:
@jashkenas
jashkenas / minified-single-line-bookmarket.js
Created October 27, 2010 19:06
Handy Bookmarklet to recursively reload all CSS stylesheets for each frame in the page.
(function(){function f(b){b=b||window;for(var g=b.document.getElementsByTagName("link"),a=0,d=g.length;a<d;a++){var e=g[a],c=e.href;if(c&&/stylesheet/i.test(e.rel)){c=c.replace(/(&|%5C?)forceReload=\d+/,"");var h="forceReload="+(new Date).valueOf();e.href=c+(c.indexOf("?")>=0?"&":"?")+h}}a=0;for(d=b.frames.length;a<d;a++)f(b.frames[a])}f()})();
@dlo
dlo / .gitignore
Created February 9, 2011 17:47
Using filesystem events and git to version my Notational Velocity notes
Interim Note-Changes
.DS_Store
@shinzui
shinzui / tmux.conf
Created March 12, 2011 01:08 — forked from bryanl/tmux.conf
tmux.conf
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
# URLs to read:
#
@stefanw
stefanw / reader2wordpress.py
Created April 2, 2011 15:02
Convert Google Reader Atom XML to WordPress eXtended RSS. Useful to recreate Wordpress blog from Google Reader "Backup".
# -*- coding:utf-8 -*-
"""
Backup Google Reader Items to WordPress eXtended RSS (Wordpress Export Format)
Download Feeds from http://www.google.com/reader/atom/feed/http://yourblogdomain.com/yourfeed?n=1000
(1000 = number of items)
Usage: reader2wordpress.py google_atom.xml http://yourblogdomain.com/
Licensed under BSD.
@ngabel
ngabel / profiler.h
Created May 2, 2011 21:58
A lightweight set of routines for your on-device iPhone performance tuning needs. Enjoy!
//
// profiler.h
// Quick and dirty profiler
//
// Created by Niels Gabel on 9/1/08.
//
// Copyright 2010 Niels Gabel
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@atdt
atdt / queryset_generators.py
Created June 2, 2011 02:19 — forked from dbrgn/queryset_generators.py
queryset_generator and queryset_list_generator
def queryset_generator(queryset, chunksize=1000):
"""
Iterate over a Django Queryset ordered by the primary key
This method loads a maximum of chunksize (default: 1000) rows in its
memory at the same time while django normally would load all rows in its
memory. Using the iterator() method only causes it to not preload all the
classes.
Note that the implementation of the generator does not support ordered query sets.