Skip to content

Instantly share code, notes, and snippets.

View gilmoreorless's full-sized avatar
💭
Probably procrastinating: http://bit.ly/lazy-oss

Gilmore Davidson gilmoreorless

💭
Probably procrastinating: http://bit.ly/lazy-oss
View GitHub Profile
@gilmoreorless
gilmoreorless / jquery-validator-extras.js
Created March 3, 2011 02:31
Extra validation methods for the jQuery Validate plugin
/*** Allow digits and whitespace ***/
// Method 1:
jQuery.validator.addMethod("digitsWhitespace", function(value, element) {
return this.optional(element) || /^[\d\s]+$/.test(value);
}, jQuery.validator.messages.digits);
// Method 2:
jQuery.validator.addMethod("digitsWhitespace", function(value, element) {
return jQuery.validator.methods.digits(value.replace(/\s/g, ''), element);
@gilmoreorless
gilmoreorless / colours.js
Created September 28, 2011 06:15
Brighten your day
var $all = jQuery('*'),
R = function (n) {
return ~~(Math.random() * n);
}
setInterval(function () {
$all.eq(R($all.length)).css('backgroundColor','rgb('+R(255)+','+R(255)+','+R(255)+')')
}, 10);
@gilmoreorless
gilmoreorless / proxy.js
Created April 1, 2012 23:12
Basic HTTP proxy that introduces random delays to responses, to help test network race conditions
#!/usr/bin/env node
/**
* INSTRUCTIONS
*
* npm install http-proxy
* node proxy.js
*/
var config = {
@gilmoreorless
gilmoreorless / api-ideas.js
Created May 20, 2012 04:25
Bluth API musings
/*** FUTURE API IDEAS ***/
// DYNAMIC URL (option 1)
cl.addPath('dynamic', '/items', 'post');
cl.dynamic.post();
cl.addPath('dynamic', '/items/:id', ['get', 'put', 'delete']);
cl.dynamic(3).get();
// DYNAMIC URL (option 2)
cl.addPath('dynamic', {
@gilmoreorless
gilmoreorless / 0_reuse_code.js
Created June 28, 2016 03:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@gilmoreorless
gilmoreorless / .block
Last active June 28, 2016 11:41
Draw an arrow between two points
license: cc-by-4.0
@gilmoreorless
gilmoreorless / .block
Last active June 29, 2016 02:45
Senate "How to Vote" connections
height: 700
license: cc-by-4.0
@gilmoreorless
gilmoreorless / .block
Last active June 30, 2016 07:42
Directional ring of nodes
license: cc-by-4.0
height: 600
@gilmoreorless
gilmoreorless / .block
Last active June 30, 2016 07:47
Senate "How to Vote" connections Ⅱ
height: 700
license: cc-by-4.0