Skip to content

Instantly share code, notes, and snippets.

View zeeshanlakhani's full-sized avatar

Zeeshan Lakhani zeeshanlakhani

View GitHub Profile
@zeeshanlakhani
zeeshanlakhani / gist:2429986
Created April 20, 2012 16:13 — forked from thinkphp/gist:1450738
Binary Search Tree implementation in Python
'''
by Adrian Statescu <[email protected]>
Twitter: @thinkphp
G+ : http://gplus.to/thinkphp
MIT Style License
'''
'''
Binary Search Tree
------------------
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@zeeshanlakhani
zeeshanlakhani / sinatra_redis_cache.rb
Created February 15, 2012 19:15 — forked from antirez/sinatra_redis_cache.rb
the simplest Redis caching for Sinatra -- not even tested... consider this code just an hint
# This is just an hint for a simple Redis caching "framework" using Sinatra
# A friend of mine asked for something like that, after checking the first two gems realized there was
# a lot of useless complexity (IMHO). That's the result.
#
# The use_cache parameter is useful if you want to cache only if the user is authenticated or
# something like that, so you can do cache_url(ttl,User.logged_in?, ...)
require 'rubygems'
require 'sinatra'
require 'redis'
@zeeshanlakhani
zeeshanlakhani / Gemfile
Created January 13, 2012 07:04 — forked from igrigorik/Gemfile
deploying Goliath on Heroku's cedar stack
source :gemcutter
gem 'goliath', :git => 'git://github.com/postrank-labs/goliath.git'
gem 'em-http-request', :git => 'git://github.com/igrigorik/em-http-request.git'
gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git'
gem 'yajl-ruby'
@zeeshanlakhani
zeeshanlakhani / gist:1604879
Created January 13, 2012 06:14 — forked from yob/gist:967934
Testing the combination of Async Sinatra with Em::HttpRequest
require 'rack'
require 'sinatra'
require 'sinatra/async'
require 'em-http-request'
# Trying out sinatra in async request mode.
#
# Run it like so:
#
# thin -R test.rb -p 4000 start
@zeeshanlakhani
zeeshanlakhani / .osx
Created January 11, 2012 22:02 — forked from dennmart/.osx
Sensible defaults for Mac OS X Lion
# Enable full keyboard access for all controls (e.g. enable Tab in modal dialogs)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Enable the 2D Dock
defaults write com.apple.dock no-glass -bool true
# Make Dock icons of hidden applications translucent
defaults write com.apple.dock showhidden -bool true
# Disable menu bar transparency
@zeeshanlakhani
zeeshanlakhani / sinatra_metal.rb
Created January 9, 2012 16:39 — forked from raggi/sinatra_metal.rb
sinatra as rails metal example - mostly unnecessary
require 'sinatra/metal'
class SinatraMetal < Sinatra::Base
include Sinatra::Metal
get '/sinatra' do
'hello sinatra!'
end
end
@zeeshanlakhani
zeeshanlakhani / function_lengths.py
Created January 8, 2012 22:42 — forked from wesm/function_lengths.py
Count all function lengths under a directory
from pandas import DataFrame
from pandas.util.testing import set_trace
import os
import numpy as np
import matplotlib.pyplot as plt
dirs = []
names = []
lengths = []
@zeeshanlakhani
zeeshanlakhani / jquery.ba-tinypubsub.js
Created November 2, 2011 21:45 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@zeeshanlakhani
zeeshanlakhani / make_turk_job.py
Created October 28, 2011 21:47 — forked from aparrish/make_turk_job.py
make a mechanical turk job with boto
import boto.mturk
import boto.mturk.connection
import boto.mturk.price
from boto.mturk.question import *
import sys
question = QuestionForm([
Question(
identifier=1,
content=QuestionContent([