Skip to content

Instantly share code, notes, and snippets.

@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'
/*
A simple new-line delimited JSON protocol with upgrades.
Receiving Usage:
protocol = require('./frame-protocol');
// parsing data
parser = protocol.Parser();
// 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;
@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.
require.registerExtension('.js', function(js){
return js.replace(/^ *\/\/debug: */gm, '');
});
@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
# 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):
// 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>