Skip to content

Instantly share code, notes, and snippets.

View ymichael's full-sized avatar

Michael Yong ymichael

View GitHub Profile
@ymichael
ymichael / app.js
Created May 4, 2012 04:13 — forked from dbainbridge/app.js
How to use socket.io with Express 3
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, http = require('http');
var app = express();
var server = app.listen(3000);
@ymichael
ymichael / snippet.js
Created April 3, 2012 16:39 — forked from christopherdebeer/snippet.js
Node.js Express - Mobile detection
app.get('/', function(req, res){
var ua = req.header('user-agent');
if(/mobile/i.test(ua)) {
res.render('mobile.html');
} else {
res.render('desktop.html');
}
});
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal