Skip to content

Instantly share code, notes, and snippets.

var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8080, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8080/');
@tamzinblake
tamzinblake / regex_end_of_string.md
Created May 27, 2011 15:37
Javascript regex grammar quirk

This gist regards some confusion resulting from this StackOverflow question.

Refer to sections 15.5.4.10 and 15.5.4.11 of the spec - page 145ish.

Before any passes, the cursor is at the start of the string:

, " , f , o , o ,   , b , a , r , " ,
^

lastIndex = 0
@tamzinblake
tamzinblake / js2-mode-npm.md
Created June 1, 2011 20:54
Improved js2-mode for npm style
@tamzinblake
tamzinblake / errors.js
Created June 7, 2011 20:53
How errors pop out in my js-mode
// Showing how errors pop out in my js-mode standard indenting:
// (https://github.com/thomblake/js-mode)
// (courtesy of https://gist.github.com/357981 for the excellent examples)
// error in standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog"
e = "elf",
@tamzinblake
tamzinblake / comma.js
Created June 13, 2011 17:54
alternate comma-first style
//an alternate comma-first style soon to be supported by my js-mode
//The assumption is that you will consistently not put the first item in the
//list on the same line as the brace, and then want the commas / operators
//2 spaces back from there.
//normal cases:
var test = {
prop1: "value1"
@tamzinblake
tamzinblake / quantum_weirdness.el
Created June 16, 2011 16:46
perl quantum weirdness explained
;;;This gist refers to the problem referenced at http://www.perlmonks.org/?node_id=369247
;;;written in lispy format for clarity; the following is not necessarily valid lisp
;;;m is a variable currently equal to 20
;;;expression to be evaluated: (++m + m++)
;;;pretend pre-increment and post-increment exist in lisp - then, this is the expression:
(+ (++m) (m++)) ; m = 20
;;; `preincrement' increments the variable and returns the variable
(+ m (m++)) ; m = 21
;;; the following line is the magic - replace `postincrement' with `increment, then return original value'
@tamzinblake
tamzinblake / table.html
Created June 30, 2011 16:30
a 2-column table
<table>
<tr><td>cell content 1</td><td>cell content 2</td></tr>
<tr><td>cell content 1</td><td>cell content 2</td></tr>
<tr><td>cell content 1</td><td>cell content 2</td></tr>
<tr><td>cell content 1</td><td>cell content 2</td></tr>
<tr><td>cell content 1</td><td>cell content 2</td></tr>
<tr><td>cell content 1</td><td>cell content 2</td></tr>
<tr><td>cell content 1</td><td>cell content 2</td></tr>
<tr><td>cell content 1</td><td>cell content 2</td></tr>
<tr><td>cell content 1</td><td>cell content 2</td></tr>
@tamzinblake
tamzinblake / npm-debug.log
Created October 6, 2011 01:47
windows npm install fail
info it worked if it ends with ok
verbose cli [ 'c:\\node\\bin\\node.exe',
verbose cli 'c:\\node\\npm\\cli.js',
verbose cli 'install',
verbose cli 'npm',
verbose cli '-gf' ]
info using npm@1.0.93
info using node@v0.5.8
verbose config file C:\Documents and Settings\Administrator\.npmrc
verbose config file c:\node\etc\npmrc
@tamzinblake
tamzinblake / foo.js
Created October 12, 2011 20:31
javascript function prototype
function foo (p, v) {
if (arguments.length > 1) {
arguments.callee[p] = v
}
return arguments.callee[p]
}
function arrayFunction (arr) {
for (var i = 0; i < arr.length; i++) {
this[i] = arr[i]
@tamzinblake
tamzinblake / bar.js
Created October 12, 2011 20:50
simpler version
function bar (p) { return p }
function barcons () {}
barcons.prototype=bar
var c = new barcons
c(1)