Skip to content

Instantly share code, notes, and snippets.

View zeeshanlakhani's full-sized avatar

Zeeshan Lakhani zeeshanlakhani

View GitHub Profile
@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 / TestSing.java
Created November 14, 2011 17:32
Simple Singleton Example in Java
import java.io.*;
import java.util.*;
class Singleton {
private static Singleton _Instance;
private Singleton()
{
}
@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([
@zeeshanlakhani
zeeshanlakhani / grep.py
Created October 19, 2011 02:27
Coroutine Simple Example Python
# grep.py
#
# A very simple coroutine
def grep(pattern):
print "Looking for %s" % pattern
while True:
line = (yield)
if pattern in line:
print line,
@zeeshanlakhani
zeeshanlakhani / decorators.py
Created October 19, 2011 02:12
Make a Decorator Python
#simple decorators concept from...
#http://stackoverflow.com/questions/739654/understanding-python-decorators
def makebold(fn):
def wrapped():
return "<b>" + fn() + "</b>"
return wrapped
def makeitalic(fn):
def wrapped():
@zeeshanlakhani
zeeshanlakhani / disc.py
Created October 16, 2011 04:45 — forked from jaymzcd/disc.py
Codility tests
#!/usr/bin/env python2
from itertools import combinations
def number_of_disc_intersections(A):
boundries = list()
for x, r in enumerate(A):
boundries.append((x-r, x+r))
r = range(len(A))