View nodejs t goal
var t = require('./t'); | |
t.app(8888, { | |
routes: { | |
'^/$': function(req, res) { | |
t.respond("something something"); | |
}, | |
'^/test/$': function() { | |
} | |
} |
View chat.js
/* | |
Usage: | |
$ node chat.js | |
$ curl http://127.0.0.1:8124/say?one | |
// say! | |
$ curl http://127.0.0.1:8124/say?two | |
// say! | |
$ curl http://127.0.0.1:8124/ask | |
// ["one", "two"] | |
*/ |
View js prototypal inheritance
var sys = require('sys'); | |
var createObject = function (obj) { | |
function F () {}; | |
F.prototype = obj; | |
return new F; | |
}; | |
var button = (function () { |
View Understanding nodejs nextTick
var sys = require('sys'); | |
var print = function print(list) { | |
for (var i = 0; i < list.length; i++) { | |
var item = list[i]; | |
if (item.length) { | |
print(item); | |
} | |
else { | |
sys.puts(item); |
View gist:633864
git config --global color.diff always |
View bash colors
for i in $(seq 1 10); do echo -n $(tput setaf ${i}) ${i}; done |
View scope.js
var a = 1; | |
b = 3; | |
var s = 1; | |
(function () { | |
a = 2; | |
b = 4; | |
var c = 3; | |
d = 1; | |
s = 2; |
View proxy.js
// Kjør med noe ala disse | |
// $ node proxy.js www.google.no 80 | |
// $ node proxy.js www.vg.no 80 | |
// og sjekk localhost:3000 | |
var http = require('http') | |
, args = process.argv.splice(2, 2); | |
http.createServer(function (req, res) { | |
var options = { | |
host: args[0] || 'www.google.no' |
View gist:879167
#!/bin/sh | |
# Opens a git repo for people to pull/push | |
git daemon --reuseaddr --base-path=/ --export-all --verbose --enable=receive-pack |
OlderNewer