Skip to content

Instantly share code, notes, and snippets.

View humidair1999's full-sized avatar

Josh humidair1999

View GitHub Profile
@humidair1999
humidair1999 / gist:0ecdca1519282e1f7b36
Created April 9, 2015 18:37
Add pull request repos to a cloned repo directory easily
function add_pr_remotes() {
mv .git/config .git/config-orig
awk '/remote "origin"/ {
print $0
getline;
print $0
getline;
print $0
print "\tfetch = +refs/pull/*/head:refs/remotes/origin/pr/*"
@humidair1999
humidair1999 / gist:f60d5eba3a6112a795f1
Created April 9, 2015 18:39
Open the current repo's page in your browser
#!/usr/bin/env bash
# relies on OS X's version of `open`
open "http://github.com/$(git remote -v | head -1 | sed -E 's/.*[email protected]:(.*)\.git.*/\1/')"
@humidair1999
humidair1999 / gist:b5fef4b9b8d357368315
Created May 4, 2015 07:37
Simple JS Deferred/Promise implementation
// promise definition
var Promise = function() {
this.successCallbacks = [];
this.errorCallbacks = [];
};
Promise.prototype.then = function(successCallback, errorCallback) {
console.log('then()');
this.successCallbacks.push(successCallback);
@humidair1999
humidair1999 / gist:bcc909a2afb5ba61a503
Created May 13, 2015 23:09
console.log shim for older browsers
/* console shim */
(function() {
var f = function() {};
if (!window.console) {
window.console = {
log: f, info: f, warn: f, debug: f, error: f
};
}
}());
@humidair1999
humidair1999 / gist:bf594d004c53a86af032
Last active August 29, 2015 14:21
Count number of CSS selectors and rules across site's stylesheets
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);