Skip to content

Instantly share code, notes, and snippets.

@rjrodger
rjrodger / gist:c3717b2b21a8339a47de
Last active Aug 29, 2015
outline of loadbalance transport
View gist:c3717b2b21a8339a47de
module.exports = function( options ) {
var seneca = this
var plugin = 'loadbalance-transport'
var so = seneca.options()
options = seneca.util.deepextend(
{
loadbalance: {
workers: [ ... ]
View ey-rr01-c-webuse
seneca.act({role:'web',use:{
name:name,
prefix:'/well/:event/',
pin:{role:name,cmd:'*'},
map:{
whoami:{GET:setcontext},
leader:{GET:setcontext},
members: { alias:'player/members/:team', GET: setcontext },
@rjrodger
rjrodger / comedy.txt
Created Oct 1, 2012
some cool comedians and shows to checkout
View comedy.txt
http://en.wikipedia.org/wiki/Dara_Ó_Briain
http://desbishop.net/
http://en.wikipedia.org/wiki/Russell_Howard
http://en.wikipedia.org/wiki/Michael_McIntyre
http://en.wikipedia.org/wiki/Have_I_Got_News_For_You
http://en.wikipedia.org/wiki/Mock_the_Week
http://www.bbc.co.uk/programmes/b008cnxn
http://www.thecatlaughs.com/
@rjrodger
rjrodger / proporder.js
Created Aug 7, 2012
Workaround for property order inconsistency in Chrome V8.
View proporder.js
/*
Workaround for property order inconsistency in Chrome V8.
Although unspecified by ECMA, most JavaScript engines return
properties in insertion order when you use for..in to iterate through
them.
For example:
@rjrodger
rjrodger / nodejs-event-stacktrace.js
Created Jun 7, 2012
better node.js stacktraces from event triggered code
View nodejs-event-stacktrace.js
// the stack trace you really want that tells you how you originally got to the fs.readFile call
var stacktrace = new Error()
Error.captureStackTrace(stacktrace)
fs.readFile( path, encoding, function(err,data) {
if( err ) {
var stackerr = new Error('Unable to read file: '+path+' (error code: '+err.code+')')
stackerr.errno = err.errno
stackerr.code = err.code
@rjrodger
rjrodger / draw.html
Created Jun 6, 2011
Little HTML5 mobile web app for drawing on a canvas
View draw.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="user-scalable=no,initial-scale=1.0,maximum-scale=1.0" />
<style>
body { padding:10px; margin:0px; background-color: #ccc; }
#main { margin: 10px auto 0px auto; }
</style>
@rjrodger
rjrodger / augment.css
Created May 26, 2011
Phonegap 3D compass
View augment.css
#main {
margin: 0px;
width: 480px;
height: 300px;
}
@rjrodger
rjrodger / streambuffer.js
Created Mar 28, 2011
A utility object that caches inbound HTTP data, allow you to attach your event handlers after you make other asynchronous requests.
View streambuffer.js
function StreamBuffer(req) {
var self = this
var buffer = []
var ended = false
var ondata = null
var onend = null
self.ondata = function(f) {
for(var i = 0; i < buffer.length; i++ ) {
@rjrodger
rjrodger / line1030-http.js
Created Feb 8, 2011
possible fix for issue with new Agent code in http.js where Agent in an error state stop working
View line1030-http.js
socket.on('error', function(err) {
debug('AGENT SOCKET ERROR: ' + err.message);
var req;
if (socket._httpMessage) {
req = socket._httpMessage;
} else if (self.queue.length) {
req = self.queue.shift();
assert(req._queue === self.queue);
req._queue = null;
} else {
@rjrodger
rjrodger / servegif.js
Created Jan 26, 2011
node.js: serve a 1x1 gif
View servegif.js
var connect = require('connect')
var imgdata = [
0x47,0x49, 0x46,0x38, 0x39,0x61, 0x01,0x00, 0x01,0x00, 0x80,0x00, 0x00,0xFF, 0xFF,0xFF,
0x00,0x00, 0x00,0x21, 0xf9,0x04, 0x04,0x00, 0x00,0x00, 0x00,0x2c, 0x00,0x00, 0x00,0x00,
0x01,0x00, 0x01,0x00, 0x00,0x02, 0x02,0x44, 0x01,0x00, 0x3b
]
var imgbuf = new Buffer(imgdata)
var server = connect.createServer(
You can’t perform that action at this time.