Skip to content

Instantly share code, notes, and snippets.

View wombleton's full-sized avatar

Rowan Crawford wombleton

View GitHub Profile
var obj = {
name: 'Good McGoodson',
last_menstrual_period: 41
};
validate(obj, [ "name.length between 1 and 100", "lmp between 0 and 40"]]); // returns ["lmp must be between 0 and 40"]
@wombleton
wombleton / sha.js
Last active December 18, 2015 13:59
Node & command line differ in hash they return ... what am I doing wrong?
// \n at the end!
console.log(require('crypto').createHash('sha1').update('blob 14\0Hello, World!\n').digest('hex'));
$> 8ab686eafeb1f44702738c8b0f24f2567c36da6d
$> db.tiles.find({}).sort({ 'voteCount': 1, 'hash': 1}).skip(1000).limit(10).explain()
{
"queryPlanner" : {
"plannerVersion" : 1,
"namespace" : "heroku_app35335042.tiles",
"indexFilterSet" : false,
"parsedQuery" : {
"$and" : [ ]
},
"winningPlan" : {
body {
font-family: "Helvetica", "sans-serif";
width: 400px;
float: left;
}
#banner {
background: #f7b;
color: #fff;
padding: 1px;
var express = require('express'),
app = express();
app.configure(function() {
app.use(express.bodyParser());
});
/**
*/
app.get('/', function (req, res) {
@wombleton
wombleton / xkcd.js
Created September 19, 2012 11:00
xkcd.com large comic navigation
// Paste this in the address bar and then use zoom in/out to navigate easier
// you may need to type in "javascript:" in the address bar manually
javascript:$('#comic').css('overflow', '');$('#topContainer, #bottom, .comicNav, #comic > img:first-child').hide()
// firefox does not allow you to do this from the address bar. For that, open the Scratchpad (Shift + F4) and execute:
$('#comic').css('overflow', '');$('#topContainer, #bottom, .comicNav, #comic > img:first-child').hide()
@wombleton
wombleton / errors.txt
Created February 28, 2012 23:19 — forked from jimsynz/errors.txt
grammar
1.9.3-p0 :002 > Crimson::Parser.parse('nil')
Exception: Parse error: Expected one of -, 0, nil at line 1, column 4 (byte 4) after .
from /Users/jnh/Dev/Toys/CrimsonScript/lib/crimson/parser.rb:12:in `parse'
from (irb):2
from /Users/jnh/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
1.9.3-p0 :003 > Crimson::Parser.parse('0')
Exception: Parse error: Expected one of -, 0, nil at line 1, column 2 (byte 2) after .
from /Users/jnh/Dev/Toys/CrimsonScript/lib/crimson/parser.rb:12:in `parse'
from (irb):3
from /Users/jnh/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
execve("/usr/local/bin/node", ["node", "test.js"], [/* 38 vars */]) = 0
brk(0) = 0x2b7a000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fce53525000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=124100, ...}) = 0
mmap(NULL, 124100, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fce53506000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
@wombleton
wombleton / sop.xml
Created August 11, 2011 10:41
sop from legislation.govt.nz
<?xml version="1.0" encoding="UTF-8"?>
<sop id="DLM3931700" irdnumbering="no" raised.by="Government" sop.no="265" stage="published" xml:lang="en-NZ" year="2011" year.imprint="2011"><date>Thursday, 4 August 2011</date><billref>Aquaculture Legislation Amendment Bill (No 3)</billref><body id="DLM3931701"><heading>Proposed amendments</heading><motion>Hon Phil Heatley, in Committee, to move the following amendments:</motion><sop.amend id="DLM3931702"><clause.ref>Clause 13: new section 25A</clause.ref><sop.para><text><emphasis style="italic">Subsections (9) and (10)</emphasis>: to omit these subsections (lines 19 to 28 on page 21) and substitute the following subsections:</text><instrument.amend close.quote="no" open.quote="yes" quote="1"><subprov quote="1" skeleton="no"><label auto.number="no" denominator="yes" quote="1">9</label><para><text>The chief executive must decline the application, if the applicant does not lodge—</text><label-para quote="1" skeleton="no"><label auto.number="no" denominator="yes" quote="1
@wombleton
wombleton / badger.js
Created June 15, 2011 05:03
The ultimate in jQuery plugins
(function($) {
var index = 0,
words = ['badger', 'badger', 'badger', 'badger', 'badger', 'mushroom']
$.extend({
badger: function() {
return words[index++ % words.length];
}
});
}(jQuery));