Skip to content

Instantly share code, notes, and snippets.

// HTTP client for testing high connection concurrency
// Authors: Richard Jones and Rasmus Andersson
// Released in the public domain. No restrictions, no support.
#include <sys/types.h>
#include <sys/time.h>
#include <sys/queue.h>
#include <stdlib.h>
#include <err.h>
#include <event.h>
#include <evhttp.h>
# In-memory Cassandra-ish thingy... useful for unit tests. Maybe useful for other
# stuff too? No support for SuperColumns, but that should be easy enough to add.
import bisect
import copy
from cassandra.ttypes import NotFoundException, Column, ColumnPath, ColumnOrSuperColumn
class SSTable(object):
@mager
mager / index.html
Created October 15, 2010 22:11
This is an example of SimpleGeo's GeoIP functionality for getting the user's location based on IP address. This example uses Polymaps.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var simplegeo=(function(b,d){var c=(function(k,g){function e(){return(new Date).getTime()}var m=k.document;var n=e(),i=/=\?(&|$)/,j=/(\?|&)_=.*?(&|$)/,l=/\?/,h=/%20/g,f=Object.prototype.toString,o={isFunction:function(p){return f.call(p)==="[object Function]"},isArray:function(p){return f.call(p)==="[object Array]"},each:function(s,w,r){var q,t=0,u=s.length,p=u===g||o.isFunction(s);if(r){if(p){for(q in s){if(w.apply(s[q],r)===false){break}}}else{for(;t<u;){if(w.apply(s[t++],r)===false){break}}}}else{if(p){for(q in s){if(w.call(s[q],q,s[q])===false){break}}}else{for(var v=s[0];t<u&&w.call(v,t,v)!==false;v=s[++t]){}}}return s},param:function(p){var q=[];if(o.isArray(p)||p.jquery){o.each(p,function(){u(this.name,this.value)})}else{for(var t in p){r(t,p[t])}}return q.join("&").replace(h,"+");function r(s,v){if(o.isArray(v)){o.each(v,function(x,w){if(/\[\]$/.test(s)){u(s,w)}else{r(s+"["+(typeof w==="object"||o.isArray(w)?x:"")+"]",w)}})}else{if(v!=n
require.registerExtension('.js', function(js){
return js.replace(/^ *\/\/debug: */gm, '');
});
@protocool
protocool / caveatPatchor.js
Created February 14, 2011 02:29
Sample caveatPatchor.js file for use in Propane 1.1.2 and above
/*
As of version 1.1.2, Propane will load and execute the contents of
~Library/Application Support/Propane/unsupported/caveatPatchor.js
immediately following the execution of its own enhancer.js file.
You can use this mechanism to add your own customizations to Campfire
in Propane.
Below you'll find two customization examples.
// Based on http://bit.ly/215MBZ
function FailureDetector(ws) {
// ws stands for window size.
// How many heartbeat intervals we keep track of.
this.ws = ws || 100;
this.window = [];
this.last = null;
}
exports.FailureDetector = FailureDetector;
/*
A simple new-line delimited JSON protocol with upgrades.
Receiving Usage:
protocol = require('./frame-protocol');
// parsing data
parser = protocol.Parser();
@barkerja
barkerja / find_my_friends.js
Created February 15, 2012 03:48
Find My Friends
var options, req, request;
request = require('request');
options = {
uri: 'https://p04-fmfmobile.icloud.com/fmipservice/friends/{account_id}/{unique_device_id}/minCallback/selFriend/refreshClient',
method: 'POST',
headers: {
'X-Apple-AuthScheme': 'Forever',
'Content-type': 'application/json'
@eonnen
eonnen / gist:2647948
Created May 9, 2012 18:52
Sample ZK Configuration
# The number of milliseconds of each tick
tickTime=300
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/home/erik/var/data/zookeeper
@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