Skip to content

Instantly share code, notes, and snippets.

@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@krosenvold
krosenvold / gist:2508909
Created April 27, 2012 12:43
Try this on your multimodule maven build and watch the performance difference !
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
.....
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<version>1.8.6</version>
</dependency>
@dlutzy
dlutzy / gist:2469037
Created April 23, 2012 05:59
Multi VM Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# David Lutz's Multi VM Vagrantfile
# inspired from Mark Barger's https://gist.github.com/2404910
boxes = [
{ :name => :web, :role => 'web_dev', :ip => '192.168.33.1', :ssh_port => 2201, :http_fwd => 9980, :cpus =>4, :shares => true },
{ :name => :data, :role => 'data_dev', :ip => '192.168.33.2', :ssh_port => 2202, :mysql_fwd => 9936, :cpus =>4 },
{ :name => :railsapp, :role => 'railsapp_dev', :ip => '192.168.33.3', :ssh_port => 2203, :http_fwd => 9990, :cpus =>1}
]
@radupotop
radupotop / fonts.conf.xml
Created March 10, 2012 20:46
fonts.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<!-- http://ubuntuforums.org/showthread.php?t=1354116 -->
<fontconfig>
<!-- See: man 5 fonts-conf -->
<!-- Antialias rules -->
<match target="font">
<!--Subpixel smoothing: rgb, bgr, vrgb, vbgr, none-->
<edit mode="assign" name="rgba"><const>none</const></edit>
@bfroehle
bfroehle / knee.py
Created February 29, 2012 22:05
knee.py for Python 2.6, 2.7, and 3.2
"""
An Python re-implementation of hierarchical module import.
Function names and arguments have been chosen to mimic the C code in
`Python/import.c` whenever possible.
This code is intended to be read, not executed. However, it does work
-- all you need to do to enable it is "import knee".
(The name is a pun on the klunkier predecessor of this module, "ni".)
@sivy
sivy / README.markdown
Created January 20, 2012 16:34 — forked from lukemorton/README.markdown
init.d file for statsd and carbon on debian

Ideally do this as SUDO

yum install -y git gcc gcc-c++ zlib-devel curl curl-devel openssl

Install node

wget http://nodejs.org/dist/node-v0.4.9.tar.gz
@jchnkl
jchnkl / gist:1609254
Created January 13, 2012 23:07
background a process automagically if its is an X11 program
setopt nohup # recommended for bg'ing a proc
setopt nocheckjobs # recommended for bg'ing a proc
#setopt auto_continue # recommened for disown'ing a proc
local alwaysBackgroundPattern
alwaysBackgroundPattern=('firefox.*' 'thunderbird.*' 'urxvt.*')
function checkForXProc() {
coproc isXWindow "$1" $(date +%s)
disown %isXWindow
@astrofrog
astrofrog / async_plotting.py
Created December 10, 2011 00:11
Asynchronous Plotting in Matplotlib: rather than call savefig directly, add plots to an asynchronous queue to avoid holding up the main program. Makes use of multiple processes to speed up the writing out. Suggestions welcome!
import time
import multiprocessing as mp
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
@jbrisbin
jbrisbin / gist:1444077
Created December 7, 2011 18:50
Reactor-based framework versus Node.js streaming

I've been hacking away recently at a JVM framework for doing asynchronous, non-blocking applications using a variation of the venerable Reactor pattern. The core of the framework is currently in Java. I started with Scala then went with Java and am now considering Scala again for the core. What can I say: I'm a grass-is-greener waffler! :) But it understands how to invoke Groovy Closures, Scala anonymous functions, and Clojure functions, so you can use the framework directly without needing wrappers.

I've been continually micro-benchmarking this framework because I feel that the JVM is a better foundation on which to build highly-concurrent, highly-scalable, C100K applications than V8 or Ruby. The problem has been, so far, no good tools exist for JVM developers to leverage the excellent performance and manageability of the JVM. This yet-to-be-publicly-released framework is an effort to give Java, Groovy, Scala, [X JVM language] developers access to an easy-to-use programming model that removes the necessity

@shyiko
shyiko / intellij-idea-jd-gui-launcher.sh
Created November 12, 2011 09:27
JD-GUI Launcher for Intellij IDEA (via External Tools)
#!/bin/bash
JDGUI_BIN=$1; FILE_PATH=$2
DELIMITER_INDEX=$(awk -v a="$FILE_PATH" -v b="!/" 'BEGIN{print index(a,b)}')
if [ $DELIMITER_INDEX -eq 0 ]; then
$JDGUI_BIN $FILE_PATH
else
JAR_FILE=${FILE_PATH:0:$DELIMITER_INDEX-1}
CLASS_RELATIVE_LOCATION=${FILE_PATH:$DELIMITER_INDEX+1}
if [[ $CLASS_RELATIVE_LOCATION == "" ]]; then
$JDGUI_BIN $JAR_FILE