Skip to content

Instantly share code, notes, and snippets.

View StevenBlack's full-sized avatar
🇨🇦

Steven Black StevenBlack

🇨🇦
View GitHub Profile
@StevenBlack
StevenBlack / jQuery-Blueprint.js
Created December 15, 2012 18:21
Custom layout width for blueprint based layouts
// 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) ?
@StevenBlack
StevenBlack / kill-reset-rails.sh
Created December 15, 2012 18:17
Create aliases to kill and reset Rails
# 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'
ygktraffic -rt -from:YGKTraffic -from:cityofkingston -mt -ckws -dog -thank -thanks -love -/via -ticket -sidewalk -sidewalks
@StevenBlack
StevenBlack / TwitterSpamFilterForYGK.txt
Last active December 9, 2015 16:38
Twitter SPAM filter for #ygk -- strips out the tweets from some well-known #ygk hashtag abusers. Feel free to tweak this list for your own use.
#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
@StevenBlack
StevenBlack / githubIssuesSuggestion.md
Last active December 7, 2015 16:37
Suggestion for Github's Issues UI.

I have a suggestion for the Github UI in Issues.

Currently in Issues: one types Issue #17 or just #17 and this resolves to a link of the Issue. This is great!

Cool suggestion: Use of the existing Issue mini icon so the link rendering looks like this, where the current state of the issue is displayed.

Bonus Points: Hovering on the Issue link displays the Issue title in a tooltip.

@StevenBlack
StevenBlack / pr.md
Created November 7, 2015 04:44 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@StevenBlack
StevenBlack / underscore.mixin.filterObj.js
Created February 7, 2011 19:13
Underscore.js _mixin: _.prune
// 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];})
@StevenBlack
StevenBlack / addEvent.js
Created September 27, 2010 20:13
generic addEvent listner
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;
}
@StevenBlack
StevenBlack / scrollbarWidth.js
Created September 27, 2010 13:12
Calculate scrollbar width
// from http://jdsharp.us/jQuery/minute/calculate-scrollbar-width.php
function scrollbarWidth() {
var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');
// Append our div, do our calculation and then remove it
$('body').append(div);
var w1 = $('div', div).innerWidth();
div.css('overflow-y', 'scroll');
var w2 = $('div', div).innerWidth();
$(div).remove();
return (w1 - w2);
@StevenBlack
StevenBlack / jquery-tmpl comment by BorisMoore
Created June 29, 2010 15:04
jquery-tmpl comments by BorisMoore
A template context corresponds to an instance of a rendered template, in the HTML DOM. It has fields:
'data' - the data item that was rendered using the template,
'tmpl' - the template that was used, 'nodes' - the HTML elements that were created and were inserted into the DOM,
'parent' - the parent template context, in the case of nested templates, e.g. using the {{tmpl }} tag.
tmplcmd provides the following commands:
'update' - re-render the template. The data, tmpl, or expandos on the template context, may have been modified, so the resulting HTML may be different than the previously rendered HTML. - Use update(ctx) to update (i.e. refresh/render the HTML in the DOM) a template context 'ctx' - or update(dataItem, contexts) to find the template context within an array 'contexts' that corresponds to that dataItem, and update that one. - You can also pass an array of contexts or data items as first parameter, and update them all at once.
'remove' - removes the rendered elements from the DOM. - Use remov