Skip to content

Instantly share code, notes, and snippets.

View zeeshanlakhani's full-sized avatar

Zeeshan Lakhani zeeshanlakhani

View GitHub Profile
@avescodes
avescodes / Editing Clojure with Emacs
Last active July 5, 2022 13:32
Get started editing Clojure in Emacs with this basic config.
Check out README.md to get started editing Clojure with Emacs.
@saolsen
saolsen / core.clj
Last active December 14, 2015 09:29
markerbot
(ns markerbot.core
(:require [taoensso.timbre :as log]
[clojure.data.json :as json]
[clojure.string :as s]
[clj-http.client :as client])
(:import (java.net Socket)
(java.io PrintWriter InputStreamReader BufferedReader))
(:gen-class))
;; marksy
@jeremyheiler
jeremyheiler / smtp.clj
Last active December 14, 2015 03:38
Possible ways to script SMTP with Clojure.
;; A data-oriented approach.
;; Basic SMTP. Falls back to HELO if Extended SMTP isn't supported.
(def script
[[:CONNECT ["server.example.com" 587]]
[:EHLO ["client.example.com"] :on-reply {502 [:HELO ["client.example.com"]]}]
[:MAIL ["[email protected]"]]
[:RCPT ["[email protected]"]]
[:RCPT ["[email protected]"]]
(use '[clojure.core.logic])
(require '[clojure.core.logic.fd :as fd])
(defn simple []
(run* [x y]
(fd/in x y (fd/interval 0 9))
(fd/eq
(= (+ x y) 9)
(= (+ (* 4 x) (* 2 y)) 24))))
@mbigatti
mbigatti / BMXRubberBanding.h
Last active December 11, 2015 07:08
iOS6 Rubber-banding Formula, as described by Grant Paul (chpwn) (ref. https://twitter.com/chpwn/status/285540192096497664)
//
// BMXRubberBanding.h
// Rubber-banding Formula, as described by Grant Paul (chpwn)
// https://twitter.com/chpwn/status/285540192096497664
//
#ifndef TimerApp_BMXRubberBanding_h
#define TimerApp_BMXRubberBanding_h
#define BMX_RUBBER_BANDING_CONSTANT 0.55
@bowmanb
bowmanb / quicksort.hs
Last active October 13, 2015 17:27
Quicksort in Haskell, from Learn You a Haskell for Great Good! Optimization courtesy of @saolsen.
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort [x] = [x]
quicksort (x:xs) =
let smallerOrEqual = [a | a <- xs, a <= x]
larger = [a | a <- xs, a > x]
in quicksort smallerOrEqual ++ [x] ++ quicksort larger
-- using filter
quicksort' :: (Ord a) => [a] -> [a]
@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"
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@kennethreitz
kennethreitz / flaskapp.py
Created June 9, 2012 15:38
My typical flask app base
# -*- coding: utf-8 -*-
import os
from flask import Flask
from flask_heroku import Heroku
from flask_sslify import SSLify
from raven.contrib.flask import Sentry
from flask.ext.celery import Celery
@jboner
jboner / latency.txt
Last active May 30, 2025 09:45
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD