Skip to content

Instantly share code, notes, and snippets.

View GeorgeErickson's full-sized avatar

George Erickson GeorgeErickson

View GitHub Profile
function binarySearch(list, value){
var states = new Array;
var state = new Object;
state.done = false;
state.b = 0;
state.e = list.length;
state.m = Math.floor((state.b+state.e)/2);
//states.push(state.clone());
while(list[state.m] != value && state.b < state.e){
if(value > list[state.m]){
express = require('express')
app = module.exports = express.createServer()
app.configure = ->
app.set 'views', __dirname + '/views'
app.set 'view engine', 'jade'
app.use express.bodyParser()
app.use express.methodOverride()
app.use express.compiler({ src: __dirname + '/public', enable: ['less'] })
app.use app.router
@GeorgeErickson
GeorgeErickson / gist:1134831
Created August 9, 2011 18:36
webfaction ssh
The procedure for setting up automatic private/public key login on our servers is as follows:
- On your own machine, go to $HOME/.ssh and type: ssh-keygen -t dsa
- When prompted for it, leave the default location for the file and let the passphrase empty
- Copy the content of the "id_dsa.pub" file that just got created into the $HOME/.ssh/authorized_keys and authorized_keys2 on our machine.
- Set the following permissions:
chmod 644 $HOME/.ssh/authorized_keys*
@GeorgeErickson
GeorgeErickson / normal.css
Created September 24, 2011 20:29
personal css normalize
/* HTML5 ✰ Boilerplate
* ==|== normalize ==========================================================
*/
article, aside, details, figcaption, figure, footer, header, hgroup, nav, section { display: block; }
audio, canvas, video { display: inline-block; *display: inline; *zoom: 1; }
audio:not([controls]) { display: none; }
[hidden] { display: none; }
html { font-size: 100%; overflow-y: scroll; -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
@GeorgeErickson
GeorgeErickson / gunicorn
Created September 28, 2011 22:28 — forked from suda/gunicorn
Gunicorn init.d script (debian/ubuntu)
#!/bin/sh
### BEGIN INIT INFO
# Provides: gunicorn
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the gunicorn server
# Description: starts gunicorn using start-stop-daemon
@GeorgeErickson
GeorgeErickson / sencha_events.js
Created November 3, 2011 22:00
Log all events in SenchaTouch 1.1
Ext.util.Observable.prototype.fireEvent =
Ext.createInterceptor(Ext.util.Observable.prototype.fireEvent, function() {
console.log(this.name);
console.log(arguments);
return true;
});
@GeorgeErickson
GeorgeErickson / decorators.py
Created November 10, 2011 15:56
useful python snippets
import time
def log_timing(func):
def wrapper(*arg):
t1 = time.time()
res = func(*arg)
t2 = time.time()
print "%s took %d ms" % (func.func_name, (t2-t1)*1000.0)
return res
return wrapper
insert('This is a line added by the user. \n This is another line added by the user.', A, B)
insert('This is yet another line added by the user.' B, null)
@GeorgeErickson
GeorgeErickson / gist:2869852
Created June 4, 2012 17:55
script loading
class app.view.ProfileListView extends Backbone.View
events:
"click li.js_profile": "select_click_person"
"click li.js_next_page": "next_page"
"click li.js_prev_page": "prev_page"
"click .close": "filter_x_click"
"click .order_buttons button": "order_by"
initialize: ->
@loading_overlay_el = $('#js_overlay_'[email protected])
@GeorgeErickson
GeorgeErickson / debug_url.py
Created August 28, 2012 14:52
Serving static files in django for development
from django.conf import settings
from django.conf.urls.defaults import patterns, url
import os
urlpatterns = patterns('',)
if settings.DEBUG:
urlpatterns += patterns('',
url(r'^(?P<path>.*)$', 'django.views.static.serve', {'document_root': os.getcwd()})
)