Skip to content

Instantly share code, notes, and snippets.

View davidbanham's full-sized avatar

David Banham davidbanham

View GitHub Profile
@davidbanham
davidbanham / gist:1131171
Created August 8, 2011 03:42
jade iteration value issue
- each item, ++i in cartItems
input(type="hidden",name="item_name_" + i,value=item.itemName)
input(type="hidden",name="amount_" + i,value=item.price)
@davidbanham
davidbanham / gist:1136212
Created August 10, 2011 05:48
Jade weirdness
This:
p
form
label Email Address:
input(type="text", name="email")
label Wedding Date
input(type="text", name="date")
Renders this:
div.cont
div.header
h1 Get started
p We're still putting the finishing touches on things right now.
p If you'd like to be notified when we launch, please enter your details below:
p
form
label Email Address:
input(type="text", name="email")
label Wedding Date
@davidbanham
davidbanham / gist:1139047
Created August 11, 2011 06:54
Reduce array to unique elements
var array = [0, 1, 2, 1, 3];
var uniques = [];
for ( var i in array ) {
uniques[array[i]] = array[i];
};
console.log(uniques);
// Returns [ 0, 1, 2, 3 ]
var http = require('http')
http.createServer(function (req,res) {
res.writeHead(200, {'Content-Type':'text/plain'});
res.end('Hello World! \n');
}).listen(1337,"127.0.0.1");
console.log('Server running ar http://127.0.0.1:1337//');
@davidbanham
davidbanham / gist:1215435
Created September 13, 2011 23:05
Jade filename option
davidbanham@David-Banhams-MacBook-Pro:~/jadepit$ jade test.jade
/Users/davidbanham/node_modules/jade/lib/runtime.js:115
throw err;
^
Error: Jade:4
2| p
3| | Look I'm a paragraph!
> 4| include head
@davidbanham
davidbanham / npm-logo.js
Created October 11, 2011 05:25 — forked from jfhbrook/npm-logo.js
run it!
require("colors");
var red = "█".red;
var white = "█".white;
console.log();
console.log([
" ooooooooooooooooooo",
" oXXXXoXXXXooXXXXXXo",
" oXooXoXXoXooXXoXoXo",
@davidbanham
davidbanham / gist:1315746
Created October 26, 2011 08:00
Battling with expresso
var server = require('../server'),
assert = require('assert');
module.exports = {
'GET /': function(done){
assert.response(server,
{ url: '/login' },
{ status: 200, headers: { 'Content-Type': 'text/html; charset=utf-8' }},
function(res){
assert.includes(res.body, '<body id="login_page">');
@davidbanham
davidbanham / gist:1407615
Created November 30, 2011 01:55
Jade info passing
res.render('couplesearch', {
title: "Honeymoon!",
couples: results
});
@davidbanham
davidbanham / gist:1407631
Created November 30, 2011 01:59
Set-Cookie header out of Express req
{"name":"Location","value":"https://3ahk.localtunnel.com/login#loginPage"},{"name":"Set-Cookie","value":"pinion.sid=9clqqOCzv2xjkvF0E6q9A0It.JWld7dqXBoCkUQboxVJ6Yu4Nb1HUJRZ7bdXNGVDe42g; path=/; expires=Mon, 28 Nov 2011 09:29:38 GMT; httpOnly"}],"cookies":[{"name":"pinion.sid","value":"9clqqOCzv2xjkvF0E6q9A0It.JWld7dqXBoCkUQboxVJ6Yu4Nb1HUJRZ7bdXNGVDe42g","path":"/","expires":"2011-11-28T09:29:38.000Z","httpOnly":true,"secure":false}