Skip to content

Instantly share code, notes, and snippets.

View missinglink's full-sized avatar

Peter Johnson missinglink

View GitHub Profile
IMPORTANT: this is outdated, go to https://github.com/netroy/Lockets
"npm install socket-io" & you are ready to go
@eculver
eculver / APPNAME
Created July 5, 2011 17:35 — forked from shimondoodkin/APPNAME
init.d script for node.js for debian
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@brianyang
brianyang / gist:1211453
Created September 12, 2011 14:51
Twitter Stream - Front End
jQuery(function(){
// Execute this code when the page is ready to work
// Create a Script Tag
var script=document.createElement('script');
script.type='text/javascript';
script.src= "http://search.twitter.com/search.json?&q=%23Ogilvy&callback=processTheseTweets&_="+ new Date().getTime();
// Add the Script to the Body element, which will in turn load the script and run it.
$("body").append(script);
});
@dbainbridge
dbainbridge / app.js
Created April 19, 2012 20:48
How to use socket.io with Express 3
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http');
var app = express();
var server = app.listen(3000);
@jboner
jboner / latency.txt
Last active May 5, 2024 03:12
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
@atrawog
atrawog / TileLayer.TileJSON.js
Created August 2, 2012 11:46 — forked from DGuidi/TileLayer.TileJSON.js
Leaflet TileCanvas
L.TileLayer.TileJSON = L.TileLayer.Canvas.extend({
options: {
debug: false
},
tileSize: 256,
initialize: function (options) {
L.Util.setOptions(this, options);
@missinglink
missinglink / app.js
Created September 17, 2012 20:39 — forked from bobbydavid/app.js
socket.io in Express 3
var express = require('express')
, http = require('http')
, connect = require('connect')
, io = require('socket.io');
var app = express();
/* NOTE: We'll need to refer to the sessionStore container later. To
* accomplish this, we'll create our own and pass it to Express
* rather than letting it create its own. */
var sessionStore = new connect.session.MemoryStore();
@katanacrimson
katanacrimson / netstat.js
Created October 24, 2012 22:29
Quickie node.js to grab & parse current local TCP connections [netstat, Windows]
var child = require('child_process'),
util = require('util'),
netstat = child.spawn('netstat', ['-nb']),
out = ''
netstat.stdout.on('data', function(data) {
out += data
})
netstat.stderr.on('data', function(data) {
console.log('err: ' + data)
@max-mapper
max-mapper / index.js
Created October 30, 2012 03:15
twitter bot for @sandyaid retweets
var crypto = require('crypto')
var request = require('request')
var url = require('url')
var irc = require('./IRC/lib/irc') // https://github.com/gf3/IRC-js
var ntwitter = require('ntwitter')
var twitter = require('twitter')
var qs = require('querystring')
// separate accounts to post and search because twitter was sending me 500s
// when I tried to use the same oauth creds for both twitter() and ntwitter()
@mrflip
mrflip / 20130416-todo.md
Last active January 21, 2024 21:06
Elasticsearch Tuning Plan

Next Steps

  • Measure time spend on index, flush, refresh, merge, query, etc. (TD - done)
  • Take hot threads snapshots under read+write, read-only, write-only (TD - done)
  • Adjust refresh time to 10s (from 1s) and see how load changes (TD)
  • Measure time of a rolling restart doing disable_flush and disable_recovery (TD)
  • Specify routing on query -- make it choose same node for each shard each time (MD)
  • GC new generation size (TD)
  • Warmers
  • measure before/after of client query time with and without warmers (MD)