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
// very simple version of $X | |
// $X(exp); | |
// $X(exp, context, resolver, XPathResult.NUMBER_TYPE).numberValue; | |
// @source https:/raw.github.com/gist/29681 | |
function $X (exp, context, resolver, result_type) { | |
context || (context = document); | |
var Doc = context.ownerDocument || context; | |
var result = Doc.evaluate(exp, context, resolver, result_type || XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
if (result_type) return result; | |
for (var i = 0, len = result.snapshotLength, res = new Array(len); i < len; i++) { |
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 webviewProvider = (function() { | |
if (/\/FBIOS/i.test(navigator.userAgent) === true) { | |
return 'facebook'; | |
} | |
if (/Twitter for/i.test(navigator.userAgent) === true) { | |
return 'twitter'; | |
} | |
if (/Pinterest\//.test(navigator.userAgent) === true) { | |
return 'pinterest'; | |
} |
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
# bash alias | |
alias subl='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl' | |
# bash function, usage: $ st -p [projectname] -opt2 -opt3 | |
function st() { | |
if [ -n "$1" -a -n "$2" ]; then # if more than one argument | |
if [ "$1" = "-p" -o "$1" = "--project" ]; then # if arg1 is -p or --project | |
local projectfile="$2" | |
[[ $projectfile != *.sublime-project ]] && projectfile="$2.sublime-project" # detect if arg2 already includes the ext | |
if [ -e $projectfile ]; then # does project file exist? |
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
pwd | |
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh | |
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc | |
chsh -s /bin/zsh | |
exit |
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
Handlebars.registerHelper('linkify', function (text) { | |
text = text.replace(/(https?:\/\/\S+)/gi, function (s) { | |
return '<a href="' + s + '">' + s + '</a>'; | |
}); | |
text = text.replace(/(^|)@(\w+)/gi, function (s) { | |
return '<a href="http://twitter.com/' + s + '">' + s + '</a>'; | |
}); | |
text = text.replace(/(^|)#(\w+)/gi, function (s) { |
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() { | |
var φ = 1.618033988749895, | |
ρ = 180 / Math.PI; | |
var vertices = [ | |
[1,φ,0], [-1,φ,0], [1,-φ,0], [-1,-φ,0], | |
[0,1,φ], [0,-1,φ], [0,1,-φ], [0,-1,-φ], | |
[φ,0,1], [-φ,0,1], [φ,0,-1], [-φ,0,-1] | |
]; |
NewerOlder