This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parents(node) { | |
var nodes = [node] | |
for (; node; node = node.parentNode) { | |
nodes.unshift(node) | |
} | |
return nodes | |
} | |
function commonAncestor(node1, node2) { | |
var parents1 = parents(node1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function($) { | |
var NONBLANK = /\S/ | |
var SPLITTER = /[^a-z0-9-]+/i | |
function countWords(string) { | |
var trimmed = string.replace(/^\s+|\s+$/g, "") | |
if (NONBLANK.test(trimmed)) { | |
return trimmed.split(SPLITTER).length | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Thankyou Bartosz Blimke! | |
# https://twitter.com/bartoszblimke/status/198391214247124993 | |
module LastRequest | |
def last_request | |
@last_request | |
end | |
def last_request=(request_signature) | |
@last_request = request_signature |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Peity events example</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script> | |
<script src="http://benpickles.github.com/peity/jquery.peity.js"></script> | |
<script> | |
// Apply Peity once. | |
$(function() { | |
$("#pie").peity("pie") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Repo | |
REPOS = %w( | |
benpickles/js-model | |
benpickles/peity | |
ismasan/hash_mapper | |
ismasan/jbundle | |
markevans/dragonfly | |
mloughran/api_cache | |
mloughran/em-hiredis | |
mloughran/juggler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////// | |
// IN CONSOLE // | |
//////////////// | |
Blah = Model("blah", { | |
persistence: Model.localStorage(), | |
find_by_uid: function(uid) { | |
return this.detect(function() { | |
return this.uid == uid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
if [ $# -eq 0 ]; then | |
cat <<USAGE | |
Convert multiple media files to MP3 and add them to iTunes in one line. | |
Usage: | |
$ 2mp3 list of files to convert | |
USAGE | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
require 'rubygems' | |
require 'mocha' | |
class Foo | |
def self.say_hello_to(name) | |
Bar.hello(name) | |
end | |
end |