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
/** | |
* ♫ A Little Reminder About JavaScript Boolean Evaluations ♫ | |
*/ | |
!!0 // false | |
!!NaN // false | |
!![] // true | |
!!new Array // true |
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
/** | |
* ♫ Firefox-Proof Focus Styles ♫ | |
* | |
* Define your focus styles this way: a.focus { outline: 2px solid hotpink; } | |
* Only mini-tiny-pico quirk is a slight delay before the focus style appears. | |
* | |
* https://gist.github.com/536465 | |
*/ | |
$('a').bind({ |
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
/* | |
* Returns an array of jQuery objects, grouped by specified number of elements. | |
* | |
* Say you have 17 <frameset> tags on your page... | |
* | |
* $('frameset').inGroupsOf(7); // => [ jQuery[0..6], jQuery[7..13], jQuery[14..16] ] | |
* | |
*/ | |
$.fn.inGroupsOf = function( countPerGroup ) { | |
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
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Clean-Markup Line Numbers™</title> | |
<style> | |
body { | |
width: 800px; | |
margin: 0 auto; | |
} |
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
this.$().animate({ | |
scale: 1, | |
translateX: 0, | |
translateY: 0, | |
top: document.body.scrollTop, | |
left: 0, | |
width: window.innerWidth, | |
height: window.innerHeight |
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 compressCSS = function(css) { | |
return css.trim() | |
.replace(/\s*([{}:;,>+~])\s*/g, '$1') // whitespace | |
.replace(/;}/g, '}') // trailing semicolons | |
.replace(/#(\w)\1(\w)\2(\w)\3\b/g, '#$1$2$3') // hex colors | |
.replace(/(\[[^=]+=)("|')([^"'\s]+)(\2)(\])/g, '$1$3$5') // useless attribute selector quotes | |
.replace(/\(('|")([^"'\s]+)(\1)\)/g, '($2)') // useless function quotes | |
} |
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
class String | |
def gsub_array! find, replace | |
find.each_index do |i| | |
self.gsub! find[i], replace[i] | |
end | |
self | |
end | |
def gsub_array find, replace | |
str = self.clone |
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 func(a, f) { | |
return function(args) { | |
args = args || {}; | |
args.__proto__ = a; | |
f.call(this, args); | |
}; | |
}; | |
var f = func({ foo: 10, bar: 20 }, function(args) { |
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
alias glog="git log --oneline --decorate" | |
alias gstatus="git status -sbu" | |
alias gdiff="git diff" | |
alias gadd="git add -p" | |
alias gcommit="git commit -v" | |
alias grebase="git rebase -i" | |
alias gpull="git pull --rebase origin" | |
alias gpush="git push origin" | |
alias gstash="git stash save" | |
alias gpop="git stash pop" |
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 'sinatra/base' | |
require 'sinatra/namespace' | |
class MyApp < Sinatra::Base | |
register Sinatra::Namespace | |
get '/' do | |
'Home' | |
end |
OlderNewer