Skip to content

Instantly share code, notes, and snippets.

@balupton
balupton / README.md
Last active October 1, 2015 14:48
Bevry's Twilio Application using Node.js
@johnschimmel
johnschimmel / gist:1941724
Created February 29, 2012 15:36
Developing locally and deploying NodeJS on Heroku

Initial NodeJS setup

with heroku toolbelt installed run following in code directory (via Terminal)

npm install
git init
git add .
git commit -am "initial commit"
foreman start
@srohde
srohde / route.coffee
Created February 28, 2012 03:15
Node.js server-side compile Hogan.js templates
Hogan = require 'hogan'
fs = require 'fs'
# The templates route generates the JavaScript file
# for the server side compiled Hogan templates.
exports.templates = (req, res) ->
compileTemplate = (template, callback) ->
filename = __dirname + '/../templates/' + template + '.hogan'
fs.readFile filename, (err, contents) ->
if err
@mrb
mrb / lahey_pizza.txt
Created February 25, 2012 17:41
Lahey Pizza
The pizza recipe is based on the book "My Bread" by Jim Lahey, which I
HIGHLY recommend. It has bunch of recipes based around the idea of
"no knead" bread - basically long fermentation times take place of
lengthy, annoying kneading. You can make great loaves with a similar
technique to the pizza recipe below. This is a kind of "Roman" style
pizza where you stretch the dough very thin on two 13" x 18" sheet
pans, cut the ingredients very thinly, layer it, and bake it hot for
about 25 minutes. To make two pies:
3 3/4 cups or 500 grams Bread Flour
@nulltask
nulltask / app.js
Created February 21, 2012 17:32
Node.js network balanced cluster with Socket.IO
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, cluster = require('cluster');
var app = module.exports = express.createServer()
, io = require('./socket')(app);
@bennadel
bennadel / love.js
Created February 14, 2012 16:00
Building Executable Scripts For The Mac OSX Command Line With Node.js
#! /usr/local/bin/node
// ^-- Tell the terminal which interpreter to use for the execution
// ^-- of this script. For our purposes, we'll be using the Node.js
// ^-- interpretor (which was installed in the local BIN directory
// ^-- using HomeBrew.
// ---------------------------------------------------------- //
// ---------------------------------------------------------- //
@lkrids
lkrids / twitter_streaming.js
Created February 12, 2012 08:39 — forked from ryanmcgrath/twitter_streaming.js
Access the Twitter Streaming API with ease (Node.js).
var util = require('util'),
http = require('http'),
events = require('events');
var Twitter = function(opts) {
this.username = opts.username;
this.password = opts.password;
this.track = opts.track;
this.data = '';
};
@rubyonrails3
rubyonrails3 / hello.js
Created January 29, 2012 19:30
This is hello World in NodeJs with Socket.IO
var http = require('http'),
url = require('url'),
ios = require('socket.io'),
fs = require('fs');
var server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<h1>Hello NodeJs</h1>');
});
@charlesdaniel
charlesdaniel / basic_auth_nodejs_test.js
Created January 27, 2012 02:53
Example of HTTP Basic Auth in NodeJS
var http = require('http');
var server = http.createServer(function(req, res) {
// console.log(req); // debug dump the request
// If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object)
var auth = req.headers['authorization']; // auth is in base64(username:password) so we need to decode the base64
console.log("Authorization Header is: ", auth);
@lerouxb
lerouxb / weather.py
Created January 18, 2012 12:12
Get the current conditions for a city from Google's "hidden" weather API
#!/usr/bin/env python
def convert_mph(match):
try:
mph = int(match.group(0).split(' ')[0])
kph = mph*1.6
#return "%.1f kph" % (kph,)
return "%s kph" % (int(round(kph)),)
except:
return match.group(0)