Skip to content

Instantly share code, notes, and snippets.

View wombleton's full-sized avatar

Rowan Crawford wombleton

View GitHub Profile
@wombleton
wombleton / generateId.js
Created February 5, 2010 00:36
jquery generateId that preserves existing ids and guesses appropriate prefixes, similar to Ext's id()
$.extend((function() {
var counts = {};
return {
generateId: function(prefix) {
prefix = (prefix || 'jq') + '-';
counts[prefix] = counts[prefix] || 0;
return prefix + counts[prefix]++;
}
}
})());
@wombleton
wombleton / timezones.rb
Created September 28, 2010 01:39
Create timezone transition data from the list of timezones in the "zones" variable. Depends on the installed ruby's Olson data being accurate.
require 'rubygems'
require 'tzinfo'
require 'json'
# Run to generate Olson => goog.i18n.TimeZone data.
zones = %w(UTC Pacific/Auckland)
FIFTY_YEARS_FROM_NOW = DateTime.now + 365 * 50
MINUTES_IN_HOUR = 60
@wombleton
wombleton / reply-to.js
Created November 12, 2010 22:18
Public Address In-Reply-To Improve
$('.reply-to').live('click', function() {
var hash = ($(this).attr('href') || '').split('#')[1];
if ($('#' + hash).length && hash) {
window.location.hash = hash;
return false;
}
});
@wombleton
wombleton / publicip.js
Created April 6, 2011 05:11
ExtJS VType For Public IP Addresses Complying With RFC 1918
Ext.apply(Ext.form.VTypes, {
publicip: function(v) {
var errorMessage = 'Invalid public IP address',
i,
parts = [];
v = Ext.util.Format.trim(v || '').split('.');
for (i = 0; i < v.length; i++) {
var num = parseInt(v[i]);
if (Ext.isNumber(num) && num >= 0 && num <= 255) {
parts.push(num);
@wombleton
wombleton / jquery.toobject.coffee
Created May 11, 2011 12:55
coffeescript jquery plugin converting a form element to a json object. based on form2object.js
###
Copyright (c) 2010 Maxim Vasiliev, Rowan Crawford
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@wombleton
wombleton / Ajax.Pjaxer.js
Created May 30, 2011 22:31
Prototype Pjax
/** Untested */
Ajax.Pjaxer = Class.create(Ajax.Updater, {
initialize: function($super, container, url, options) {
options = Object.clone(options);
options.headers = options.headers || {};
Object.extend(options.headers, {
'X-PJAX': 'true'
});
var onComplete = options.onComplete;
@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));
@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
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 / 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>'