Skip to content

Instantly share code, notes, and snippets.

View zeeshanlakhani's full-sized avatar

Zeeshan Lakhani zeeshanlakhani

View GitHub Profile
/**
* Creates an ArrayBuffer, converts the binary to a Uint8 Array, and
* places the buffer in a DataView, which is needed to create a Blob
**/
_makeBlob: function(binary) {
var data = new ArrayBuffer(binary.length),
mimeString = "text/plain",
ui8a = new Uint8Array(data, 0),
dataView,
blob;
@zeeshanlakhani
zeeshanlakhani / face-bounding-box.py
Created December 13, 2012 15:27
face-detection ~ visual-mean (no cropping approach in this file, just detection)
import os, sys, glob
import cv
import math
import argparse
HAAR_CASCADE_FRONT = \
"/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml"
HAAR_CASCADE_PROFILE = \
"/usr/local/share/OpenCV/haarcascades/haarcascade_profileface.xml"
@zeeshanlakhani
zeeshanlakhani / smartcrop.py
Created November 16, 2012 20:05
face-detection ~ visual-mean
import os
import sys
import glob
import cv
import math
import argparse
from collections import OrderedDict
HAAR_CASCADE_FRONT = \
"/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml"
@zeeshanlakhani
zeeshanlakhani / mixins.js
Created June 17, 2012 23:12
set of underscore.js mixins, including, most importantly, a function to parse the link header for paging (a la the Github API). ParseLinkHeader is the javascript version of Github's PageLinks Java method => http://bit.ly/L71lRb
_.mixin({
capitalize: function(string) {
return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
},
startsWith: function(string, start) {
return string.slice(0, start.length) == start;
},
@zeeshanlakhani
zeeshanlakhani / heroku_unicorn_logger_fix.rb
Created April 30, 2012 16:36 — forked from jamiew/heroku_unicorn_logger_fix.rb
Fix Heroku cedar app logging with Rails 3.1 and Unicorn
# config/environments/production.rb
# We're on Heroku, just output straight to STDOUT
# This is required because we're using Unicorn: https://github.com/ryanb/cancan/issues/511#issuecomment-3643266
config.logger = Logger.new(STDOUT)
config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'INFO')
use Rack::Static, :urls => ["/stylesheets", "/images"], :root => "public"
run lambda { |env| [200, { 'Content-Type' => 'text/html', 'Cache-Control' => 'public, max-age=86400' }, File.open('public/index.html', File::RDONLY)] }
@zeeshanlakhani
zeeshanlakhani / gist:2429986
Created April 20, 2012 16:13 — forked from thinkphp/gist:1450738
Binary Search Tree implementation in Python
'''
by Adrian Statescu <adrian@thinkphp.ro>
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'