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 addEvent(obj, evType, fn){ | |
if (obj.addEventListener){ | |
obj.addEventListener(evType, fn, false); | |
return true; | |
} else if (obj.attachEvent){ | |
var r = obj.attachEvent("on"+evType, fn); | |
return r; | |
} else { | |
return 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
// Return an object who's members match a reference array of keys | |
// reference=["b","c","f","r"]; | |
// obj={"a":1, "b":2, "c":3, "d":4, "r":18}; | |
// _.filterObj(obj, reference) | |
// => { b : 2, c : 3, r : 18} | |
_.mixin( { | |
filterObj : function( obj, reference ) { | |
if ( reference && typeof reference == 'object' ) { reference=_.keys( reference ); } | |
var intersect = _.intersect(reference, _.keys(obj)), retObj= {}; | |
_.map( intersect, function( el) { retObj[el]=obj[el];}) |
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
// for contrasting text color | |
// Original article: http://24ways.org/2010/calculating-color-contrast | |
function getContrastYIQ(hexcolor){ | |
var r = parseInt(hexcolor.substr(0,2),16); | |
var g = parseInt(hexcolor.substr(2,2),16); | |
var b = parseInt(hexcolor.substr(4,2),16); | |
var yiq = ((r*299)+(g*587)+(b*144))/1000; | |
return (yiq >= 131.5) ? 'black' : 'white'; | |
} |
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
#ygk -rt -nailaj -ckws* -morril -vieiraflytrap -jason_michael -realtoranselmo -KingstonFronts -frontsingame -JoeDKtown -bbbaugh2 -buyingsolo -thebrickriocan -ddsnorth -moradio1043 -kingstonteam -whiglive -west_surgeoner -tmj_on_nursing -shima_ygk -AtomicaKingston -ChienNoirBistro -KEYS_Employment -983FLYFM -989THEDRIVE -FM96Ktown -west76grill -Sold85 -jmillard01 -tourismkingston -megaloskingston -dianegiberson -brenda_slomka -I2W2013 -rsourcetweets -tmj_ON_health -ygktraffic -ygkrts |
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
ygktraffic -rt -from:YGKTraffic -from:cityofkingston -mt -ckws -dog -thank -thanks -love -/via -ticket -sidewalk -sidewalks |
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
# from http://snippets.dzone.com/posts/show/5002 | |
alias dierails='ps -a|grep "/usr/local/bin/ruby script/server"|grep -v "grep /usr"|cut -d " " -f1|xargs -n 1 kill -KILL $1' | |
alias resetrails='ps -a|grep "/usr/local/bin/ruby script/server"|grep -v "grep /usr"|cut -d " " -f1|xargs -n 1 kill -HUP $1' |
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
// custom layout width for blueprint based layouts | |
// Original: http://www.consulenza-web.com/progetti/jquery_blueprint/ | |
// from http://james.padolsey.com/javascript/regex-selector-for-jquery/ | |
jQuery.expr[':'].regex = function(elem, index, match) { | |
var matchParams = match[3].split(','), | |
validLabels = /^(data|css):/, | |
attr = { | |
method: matchParams[0].match(validLabels) ? |
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
c={} | |
e="someMethod"; | |
preProcessPost =function(c,e) { | |
var e1=e+"Pre",e2=e+"Process",e3=e+"Post"; | |
c[e]=function(o){ | |
if (this[e1](o)) { | |
this[e2](o); | |
this[e3](o); | |
} | |
}; |
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
// assuming jQuery for its extend method. | |
// Calling program does this, and passes-in the options | |
var options = { validate: true, name: "bar" }; | |
function myThing ( options ) { | |
// Internally your program does this | |
var empty = {} | |
var defaults = { validate: false, limit: 5, name: "foo" }; |
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/bash | |
# First install 't', the Twitter command line client: https://github.com/sferik/t#readme | |
# This is a Ruby gem and if you are on Mac OS X or any flavour of *nix you're probably got Ruby. | |
# Next ensure you have 'curl' installed (on Mac OS X you probably do) | |
# Given these two prerequisites then... | |
# Step 1: Grab the latest #ygk fluff filter from Gist #4297661 in raw form |