Skip to content

Instantly share code, notes, and snippets.

@grantmichaels
grantmichaels / app.js
Created May 13, 2012 19:09 — forked from localshred/app.js
Experimentations in sinatra-style node.js
var util = require('util'),
http = require('http'),
router = require('./router');
console.log('creating server');
var app = http.createServer();
console.log('registering app');
router.registerApp(app);
@grantmichaels
grantmichaels / basic_auth_app.coffee
Created May 13, 2012 19:07 — forked from tbeseda/basic_auth_app.coffee
Basic HTTP Auth with Express for Node.js
express = require 'express'
app = express.createServer()
auth = express.basicAuth 'yourmom', 'p4ssw0rd'
app.get '/', auth, (req, res) ->
res.send your_super_secret_stuff
app.listen 3000, ->
console.log "Listening on #{port}"
@grantmichaels
grantmichaels / Publish a message
Created May 13, 2012 19:07 — forked from nivertech/Publish a message
Server-side Events with Node.js and Redis
linus@Newton:~$ redis-cli
redis 127.0.0.1:6379> publish /updates.foo "hello there!"
(integer) 1
redis 127.0.0.1:6379>
@grantmichaels
grantmichaels / Publish a message
Created May 13, 2012 19:03 — forked from linus/Publish a message
Server-side Events with Node.js and Redis
linus@Newton:~$ redis-cli
redis 127.0.0.1:6379> publish /updates.foo "hello there!"
(integer) 1
redis 127.0.0.1:6379>
@grantmichaels
grantmichaels / package.json
Created May 13, 2012 19:03 — forked from vesse/package.json
Stream live web cam video using Node.js and Gstreamer
{
"name": "streamingtest",
"version": "0.0.1",
"engines": {
"node": ">=0.6.0"
},
"dependencies": {
"express": "2.5.x",
"coffee-script": "1.2.x"
},
@grantmichaels
grantmichaels / pdf2png.js
Created May 13, 2012 19:03
PDF to PNG with Node.js and GhostScript
var exec = require('child_process').exec;
var fs = require('fs');
var util = require('util');
var http = require('http');
var url = require('url');
var PDFDocument = require('pdfkit'); // http://pdfkit.org/
http.createServer(function (req, res) {
@grantmichaels
grantmichaels / twitter_streaming.js
Created May 13, 2012 19:01 — 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 = '';
};
@grantmichaels
grantmichaels / server.js
Created May 13, 2012 19:01 — forked from esperia/server.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var util = require('util');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
@grantmichaels
grantmichaels / SignInWithTwitter.js
Created May 13, 2012 19:01 — forked from rhussmann/SignInWithTwitter.js
Simple 'sign in with Twitter' implementation in node.js
var http = require('http'),
sys = require('sys'),
URL = require('url'),
querystring = require('querystring'),
OAuth = require('oauth').OAuth;
var oa = new OAuth('https://api.twitter.com/oauth/request_token',
'https://api.twitter.com/oauth/access_token',
'YOUR APP CONSUMER KEY HERE',
'YOUR APP CONSUMER SECRET HERE',
@grantmichaels
grantmichaels / comet_client.coffee
Created May 13, 2012 19:01 — forked from emk/comet_client.coffee
Real-time Comet with Faye, Node.js and Coffee
# Client-side Comet code. See comet_server.coffee for instructions.
client = new Faye.Client '/faye', timeout: 90
# Attach a security key to all our subscription messages.
client.addExtension
outgoing: (msg, callback) ->
return callback(msg) unless msg.channel is '/meta/subscribe'
(msg.ext ?= {}).authToken = 'secret'
callback(msg)