Skip to content

Instantly share code, notes, and snippets.

View dshaw's full-sized avatar
🦄
Always bet on Node.js ✨

Dan Shaw dshaw

🦄
Always bet on Node.js ✨
View GitHub Profile
@maccman
maccman / juggernaut_channels.rb
Created June 26, 2012 04:56
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
@maccman
maccman / juggernaut.rb
Created June 26, 2012 02:49
Sinatra Server Side Event streaming.
# Usage: redis-cli publish message hello
require 'sinatra'
require 'redis'
conns = []
get '/' do
erb :index
end

I am thrilled to announce the arrival of a new stable version of Node.js.

Compared with the v0.6 releases of Node, this release brings significant improvements in many key performance metrics, as well as cleanup in several core APIs, and the addition of new debugging features.

tl;dr

githubAccount() { # Syntax: githubAccount <file>
# Check for Github account name
if [[ "$githubAccount" == '' ]]; then
if [[ ! -f "$file" ]]; then
# If .github doesn't exist then ask for the name and save it
echo -n "What is your Github name? "
read githubAccount
touch "$file"
echo "$githubAccount" > "$file"
else
@angus-c
angus-c / advice.js
Created June 3, 2012 20:12
an advice functional mixin
//usage
withAdvice.call(targetObject);
//mixin augments target object with around, before and after methods
//method is the base method, advice is the augmenting function
withAdvice: function() {
['before', 'after', 'around'].forEach(function(m) {
this[m] = function(method, advice) {
if (typeof this[method] == 'function') {
return this[method] = fn[m](this[method], advice);
@xk
xk / keys.js
Created May 19, 2012 11:07
7M keys hash and GC hiccups
// 2012-05-19 [email protected]
var o;
function boot () {
o= {};
var i= 7e6;
while (i--) {
var key= i.toString(36);
o[key]= { id:key };
}
@pamelafox
pamelafox / grunt.js
Created May 7, 2012 20:31
Grunt for a CSS/JS WebApp
/*global module:false*/
module.exports = function(grunt) {
var CSS_DIR = 'src/css/';
var JS_DIR = 'src/js/';
var BUILD_DIR = '../build/';
// Project configuration.
grunt.initConfig({
@NZKoz
NZKoz / aa_instructions.md
Created May 2, 2012 03:07
Back Up All Your Gmail
  • Install getmail (aptitude install getmail4)
  • Set Up Your Imap Server (tl;dr)
  • getmail
  • ruby date_based_archive.rb ~/Maildir/.Archive
@max-mapper
max-mapper / index.js
Created April 28, 2012 06:04
fs stream backpressure example
var fs = require('fs'),
stream = fs.createWriteStream('blah.txt', { flags: 'w', encoding: 'utf-8' }),
i = 0,
status;
stream.on('open', write)
function write() {
if (i > 100) return stream.end()
console.log(i)
var crypto = require('crypto'),
request = require('request'),
uri = 'https://queue.amazonaws.com/accountnumber/queuename',
qs = {
'AWSAccessKeyId': 'accesskey',
'Action': 'ReceiveMessage',
'AttributeName': 'All',
'Expires': '2012-04-22T22:52:43Z',
'MaxNumberOfMessages': '5',
'SignatureMethod': 'HmacSHA256',