This file contains hidden or 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
# I often need this IP for testing local websites in VirtualBox | |
echo -n `ifconfig | grep -Po "(?<=inet )\d*\.\d*\.\d*\.\d*(?=.*broadcast)"` | pbcopy | |
# Less Unix-y, somewhat more readable version | |
ifconfig | ruby -e "print STDIN.read.match(/inet (\d*\.\d*\.\d*\.\d*).*broadcast/)[1]" | pbcopy | |
# I use it like this in my .zshrc | |
alias ip='echo -n `ifconfig | grep -Po "(?<=inet )\d*\.\d*\.\d*\.\d*(?=.*broadcast)"` | pbcopy' |
This file contains hidden or 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] | |
unstage = reset HEAD # unstage | |
clear = reset --hard HEAD # erase uncommited file edits (destructive!) | |
uncommit = reset HEAD~1 # erase last commit but keeps related file edits | |
rollback = reset --hard HEAD~1 # erase last commit and related file edits (destructive!) |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 ) { | |