Skip to content

Instantly share code, notes, and snippets.

# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@fwielstra
fwielstra / api.js
Created June 14, 2011 14:46
An example NodeJS / Mongoose / Express application based on their respective tutorials
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@indexzero
indexzero / include.js
Created January 22, 2012 09:03
Find the source of your `sys` deprecation warnings in node@0.6.x
//
// Place this at the beginning of your node.js program before
// **any and all** require statements.
//
var util = require('util');
var _warning = util._deprecationWarning;
util._deprecationWarning = function () {
console.trace();
_warning.apply(util, arguments);

My comment on http://codeslinger.posterous.com/if-youre-using-nodejs-youre-doing-life-wrong


Wow, where to begin.

I normally don't reply to posts like this but today I just can't help myself.

First off, your experience w/ v8 inside some homegrown crawler as anecdotal evidence that it's buggy is kind of insane. That's not node, your bindings and, i will have to assume your DOM implementation for your crawler, are hardly getting the benefit of a large community testing and flushing out problems. If you create anything new, it'll be buggy, especially if it's complicated, and most especially if your expertise lies elsewhere (in your case I will assume it's Scala).

@jmibanez
jmibanez / gist:2140974
Created March 20, 2012 20:29
Using restify with connect
// Restify server config here
var server = restify.createServer({
name: 'restify-test',
version: '1.0.0',
});
// ...
// Connect config here
var connectApp = connect()
@nodokodo
nodokodo / style_guide.md
Created April 18, 2012 02:22 — forked from dominictarr/style_guide.md
style guide

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

@jaredhanson
jaredhanson / gist:2559730
Created April 30, 2012 16:20
Restify and Passport /cc Hal Robertson
// Based off example code from Hal Robertson
// https://github.com/halrobertson/test-restify-passport-facebook
// See discussion: https://groups.google.com/forum/?fromgroups#!topic/passportjs/zCz0nXB_gao
var restify = require('restify')
// config vars
var FB_LOGIN_PATH = '/api/facebook_login'
var FB_CALLBACK_PATH = '/api/facebook_callback'
var FB_APPID = '<<YOUR APPID HERE>>'
@jaredmorrow
jaredmorrow / gist:3053951
Created July 5, 2012 14:20 — forked from othiym23/gist:3050224
Getting SmartOS working under vmware

If you prefer VirtualBox or aren't running OS X, here are some instructions and a script to help you get started with SmartOS under VirtualBox. If you use VirtualBox, skip the first section and read the section on how to get the Node.js SmartMachine up and running.

Running SmartOS under vmware Fusion

  1. Start by downloading the latest live image
  2. When you run the new VM wizard, select "Continue without disk" on the first screen of the wizard.
  3. Select Sun Solaris / Solaris 10 64-bit on the next screen.
  4. You're going to get dumped to a config screen when the live image starts up, choose DHCP for the networking and defaults for everything else.
  5. Pretty much the first thing you're going to want to do is figure out how to SSH into the box once it boots and creates its storage pools, because trying to do stuff in the virtual console is miserable. There's no cut and paste
@rla
rla / code.js
Created August 4, 2012 20:53
Example JS client-side module
var kam = kam || {};
kam.group = function() {
var exports = {};
var Widget = kam.widget.Widget;
// Group groups items into box-like widget.
// Has title area.
@marknutter
marknutter / gist:3660257
Created September 6, 2012 20:47
Modification to angular-resource.js to allow for specification of which attributes to persist to the server on a per action basis
/**
* @license AngularJS v1.0.0rc12
* (c) 2010-2012 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, angular, undefined) {
'use strict';
/**
* @ngdoc overview