Skip to content

Instantly share code, notes, and snippets.

View benpickles's full-sized avatar
🏎️

Ben Pickles benpickles

🏎️
View GitHub Profile
@benpickles
benpickles / gist:4755435
Last active December 12, 2015 09:59 — forked from olly/gist:4754077
Regexp for validating a UK postcode.
require 'rspec/autorun'
ValidUKPostcode = /\A(
[A-PR-UWYZ]\d{1,2} \s? \d[ABD-HJLNP-UWXYZ]{2}| # A9 9AA or A99 9AA
[A-PR-UWYZ][A-HK-Y]\d{1,2} \s? \d[ABD-HJLNP-UWXYZ]{2}| # AA9 9AA or AA99 9AA
[A-PR-UWYZ]\d[A-HJKSTUW] \s? \d[ABD-HJLNP-UWXYZ]{2}| # A9A 9AA
[A-PR-UWYZ][A-HK-Y]\d[ABEHMNPRVWXY] \s? \d[ABD-HJLNP-UWXYZ]{2}| # AA9A 9AA
GIR \s? 0AA
)\z/ix
@benpickles
benpickles / gist:1312371
Created October 25, 2011 11:23
Finding model with custom IDs not working
var Activity = Model("activity", function() {
this.persistence(Model.REST, "/activity");
this.unique_key = '_id';
});
$(function() {
Activity.load(function() {
console.log(Activity.all())
var one_activity = Activity.find('fa7043e52b644cd3a7a2217edc0e8928');
console.log(one_activity)
Post('post', {
validations: {
presence: ['title', 'body'],
length: {
title: { min: 20 },
body: { max: 2000 }
}
}
})