Skip to content

Instantly share code, notes, and snippets.

View zeeshanlakhani's full-sized avatar

Zeeshan Lakhani zeeshanlakhani

View GitHub Profile
@zeeshanlakhani
zeeshanlakhani / presentation.md
Created December 3, 2015 21:21 — forked from slfritchie/presentation.md
Erlang tracing, for the Riak source code reading series, 2014-03-18, Tokyo, Japan

Erlang Tracing: more than you wanted to know

Rough Outline

  • What can be traced?
  • How can trace events be specified?
  • "match specifications": twisty passages, all alike
  • WTF, can I just use DTrace and drink my coffee/beer/whisky in peace?
  • Trace delivery mechanisms: pick one of two
@zeeshanlakhani
zeeshanlakhani / latency.txt
Created October 31, 2015 21:40 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
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
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

USING: kernel math sequences ;
IN: euler1
: multiple-of ( x y -- z ) mod zero? ;
: euler1 ( x -- y )
1 - iota [ 1 + ] map
[ dup [ 3 multiple-of ] [ 5 multiple-of ] bi or [ ] [ drop 0 ] if ]
map
sum
four primitives: run*, ==, conde, fresh
(run* (q)
(== q #t))
; for what values of q is q equal to true?
answer: q must also be #t, so
'(#t) ; answer comes back in a list
# time
# ====
macro time(ex)
quote
local t0 = time_ns()
local val = $(esc(ex))
local t1 = time_ns()
println("elapsed time: ", (t1-t0)/1e9, " seconds")
val
(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
@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)] }