Skip to content

Instantly share code, notes, and snippets.

View davidbanham's full-sized avatar

David Banham davidbanham

View GitHub Profile
@davidbanham
davidbanham / gist:1124941
Created August 4, 2011 10:43
Invalid URL wierdness
level=error,message=Invalid URL requested: /static-classified-data/motor/news-image/Solah1.jpg
level=error,message=Invalid URL requested: /static-classified/images/motoring/nissan.gif
level=error,message=Invalid URL requested: /static-classified/js/searchbar.js
level=error,message=Invalid URL requested: /static-classified/searchprinter.jsp
level=error,message=Invalid URL requested: /static-watchlist/watch_list_malay.html
level=error,message=Invalid URL requested: /static-classified/images/previous-icon.png
level=error,message=Invalid URL requested: /static-classified/images/property/turnberry_villas.gif
level=error,message=Invalid URL requested: /static-classified/searchprinter.jsp
level=error,message=Invalid URL requested: /static-classified/searchprinter.jsp
level=error,message=Invalid URL requested: /static-gtp/gtp_carousel.html
@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:1186032
Created September 1, 2011 12:02
Dynamically generate a file download in express without touching the filesystem
var express = require('express');
var app = require('express').createServer();
app.listen('3030');
app.get('/', function(req, res) {
res.contentType('text/plain');
res.send('This is the content', { 'Content-Disposition': 'attachment; filename=name.txt' });
});
@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">');