This file contains 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
# Ported from https://github.com/jzaefferer/jquery-validation/blob/master/jquery.validate.js | |
creditcard = (value) -> | |
# accept only spaces, digits and dashes | |
if /[^0-9 \-]+/.test(value) | |
return false | |
nCheck = 0 | |
nDigit = 0 | |
bEven = false |
This file contains 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 prop(propName) { | |
return function(obj) { | |
var property = obj[propName]; | |
if (typeof property === 'function') { | |
return property(); | |
} else { | |
return property; | |
} | |
} | |
} |
This file contains 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('http').Server(function (req, res) { | |
require('fs').createReadStream(__dirname + require('url').parse(req.url).pathname).pipe(res); | |
}).listen(9000); |
This file contains 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
/** | |
* Errorable | |
* | |
* Provides functionality to react when server-side validations fail. | |
* This module exports 4 methods than you can use on your views. | |
* | |
* - onError | |
* - onSuccess | |
* - addError | |
* - removeError |
This file contains 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
#!/bin/sh | |
DIR=/var/www/your_app | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
NODE_PATH=/usr/local/lib/node_modules | |
BOUNCY = /usr/local/bin/bouncy | |
test -x $BOUNCY || exit 0 | |
case $1 in | |
start) |
This file contains 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
import random | |
print ''' | |
You meet a man on the street and he says, "I have two children and one is a son born on a Tuesday." | |
What is the probability that the other child is also a son? | |
''' | |
def get_combinations(): | |
children = ('s', 'd') | |
weekdays = tuple(range(1, 8)) |
This file contains 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 dir = __dirname + '/app/templates/conversations' | |
, finder = require('findit').find(dir) | |
, fs = require('fs') | |
, _ = require('underscore') | |
, templates = {} | |
, num_templates = 0 | |
, all_scanned = false | |
, jade = require('jade'); | |
function startServer() { |
This file contains 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
/*globals APP*/ | |
(function () { | |
var LOCATION = {} | |
, cache = {} | |
, jqXHR = null; | |
function _getCoords(place) { | |
return [ | |
place.centroid.latitude + ',' + place.centroid.longitude |
This file contains 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 j(){var a=[],b=0,c="",d=[],e="\033[3",f="\n";return function g(h){h?(a= | |
a.concat(h),b++):(h=new Date,a.map(function(a){a.call(g,function(a){if(!a)try{ | |
throw Error()}catch(b){d.push(e+"1mFailure:"+b.stack.split(f)[3]+e+"9m")}c+=e+(a | |
?"2m.":"1mF")})}),console.log([c,e+"9m"+(new Date-h)+"ms",b+" tests, "+c.length+ | |
" assertions, "+d.length+" failures",d.join(f)].join(f)))}} | |
// Example usage | |
var test = j(); | |
test([ |
This file contains 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
import Data.Char | |
import Numeric | |
rotate :: [a] -> [a] | |
rotate (x:xs) = xs ++ [x] | |
isRotated :: Eq a => [a] -> [a] -> Bool | |
isRotated xs ys = any (==xs) (take (length ys) $ iterate rotate ys) | |
binaryToChar :: String -> Char |
NewerOlder