Skip to content

Instantly share code, notes, and snippets.

@swoodtke
swoodtke / gist:2582130
Created May 3, 2012 00:19
Upstart example for node.js application
#!upstart
description "Node.js Application Server"
author "Shawn Woodtke"
# Add dependencies on mongodb (or other database) if required
# start on started mongodb
# stop on stopping mongodb
respawn
@swoodtke
swoodtke / LineReader.coffee
Created February 20, 2012 20:09
Class to read a file line-by-line in Node.js
fs = require 'fs'
path = require 'path'
events = require 'events'
class LineReader extends events.EventEmitter
constructor: ->
@stream = null
@saved = null
_endStream: ->
@swoodtke
swoodtke / connection.c
Created October 2, 2011 12:34
A wrapper for connecting and binding to TCP/UDP sockets
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <stdio.h>