Skip to content

Instantly share code, notes, and snippets.

@ruzzbot
ruzzbot / ss-restrpc.coffee
Created January 10, 2013 17:13
ss-restrpc : a socketstream module that creates rest services
express = require 'express'
app = module.exports = express()
prefix = "api"
# The collection of models
models =
"writeoff": require '../models/writeoff'
###
# Create http interface for a model.<namespace>
@ruzzbot
ruzzbot / frequent-modules.md
Created November 21, 2012 03:06
Frequently Used Node.js Modules

Global Modules: npm install -g bbb coffee-script express geddy grunt houston jitsu mocha node-dev nib nodester-cli sinon socketstream stylus

Project Modules: restler (HTTP Requests) socket.io (websocket)

Deployment / Services: jitsu nodester-cli

@ruzzbot
ruzzbot / express-middleware.x-domain.js
Created November 1, 2012 22:43
express.js middleware to allow cross-domain access
var express = require('express'),
app = express();
app.use( function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept');
next();
});
@ruzzbot
ruzzbot / mixins.styl
Created October 17, 2012 03:26
stylus mixin boilerplate
//==================================================================== VARS
ani_speed = 0.5s
img_path( filename )
'assets/images/'+filename
font_path( filename )
'assets/fonts/'+filename
@ruzzbot
ruzzbot / graph.adjacency-list.js
Created October 11, 2012 04:15
Adjacency List for Undirected Graph
define([], function(app) {
var Graph = {},
adj = {}; //Map of adjacency lists for each node
//@nodes (int[])
Graph.init = function(nodes){
//your node labels are consecutive integers starting with one.
//to make the indexing easier we will allocate an array of adjacency one element larger than necessary
adj = adj.clone();
for (var i = 0; i < nodes.length; ++i) {
@ruzzbot
ruzzbot / user.coffee
Created October 10, 2012 19:13
simple-tests.jasmine.coffee
define [ "modules/user" ], (User)->
describe "User", ->
users = new User.Collection()
me = null
it "create new user", ->
users.create
"email" : "email@vml.com"
@ruzzbot
ruzzbot / dubstep.coffee
Created September 21, 2012 19:24
dubstep script
if _( others ).include( dubstep.banger )
for bassface in [1..140]
"WUB"
@ruzzbot
ruzzbot / stash
Created September 21, 2012 19:05
stash-ish : a temporary place to put code I'm unsure about adding
<script type="text/javascript">
// 2012-09-21 : RWM
(function(){
var countrysortinator = function(){
// Sort object
var sortinator = {
parse_countries : function($container){
var countries = [];
@ruzzbot
ruzzbot / vml-grunt.js
Created September 12, 2012 14:32
VML grunt.js buildscript (bbb)
// This is the main application configuration file. It is a Grunt
// configuration file, which you can learn more about here:
// https://github.com/cowboy/grunt/blob/master/docs/configuring.md
// http://net.tutsplus.com/tutorials/javascript-ajax/meeting-grunt-the-build-tool-for-javascript/
// If you need support for a pre-compiler or a new tool to play with, check out
// http://gruntjs.com/
module.exports = function(grunt) {
// directory paths
@ruzzbot
ruzzbot / music-file.coffee
Created August 2, 2012 16:48
A small script to find music files and store them to couchDB
fs = require 'fs'
ID3 = require 'node-id3'
findit = require 'findit'
cradle = require 'cradle'
db = new(cradle.Connection)().database('music')
allowed_files = [ 'mp3', 'aiff', 'wav', 'ogg' ]
mnt = [
'/Users/<username>/Music',
'/Users/<username>/Podcasts' ]