Chen Yong, @jiyinyiyong
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 getAbsoluteUrl = (function () { | |
var a; | |
return function (url) { | |
if(!a) a = document.createElement('a'); | |
a.href = url; | |
return a.href; | |
}; | |
})(); |
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 *step(fn) { | |
var arr = Array(fn.length); | |
for (var i = 0; i < arr.length; i++) { | |
arr[i] = (yield); | |
} | |
var gen = fn.apply(null, arr); | |
return gen; | |
} |
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
if (!Object.delegate) { | |
Object.delegate = function $delegate$(delgObj,obj) { | |
if (!obj) obj = {}; | |
if (Object.setPrototypeOf) return Object.setPrototypeOf(obj,delgObj); | |
return Object.assign(Object.create(delgObj),obj); | |
} | |
} |
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
// adapted from https://tonicdev.com/n3dst4/twelve-days-of-emoji | |
// full credit to n3dst4. I just rewrote this to be browser developer tools friendly. | |
const pressies = [ | |
"🐦🍐🌳", | |
"🐢🐦", | |
"🇫🇷🐔", | |
"📞🐦", | |
"💛💍", | |
"🐦🍳 ", | |
"🐦🏊", |
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
// credit: Louis Lazaris | |
document.onreadystatechange = function () { | |
switch (document.readyState) { | |
case 'loading': | |
console.log('loading...'); | |
break; | |
case 'interactive': | |
console.log('DOM is ready...'); | |
break; | |
case 'complete': |
with a hat tip to Sublime Text 2 Shortcuts
⌘; | autocomplete |
⌘⌥B | instant replay |
⌘⌥E | search across all tabs |
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 unique_keys(array) { | |
var values = {}; | |
for(var i = 0; i < array.length; i++) { | |
values[array[i]] = null; | |
} | |
return Object.keys(values); | |
} |
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
// jQuery.naturalWidth / jQuery.naturalHeight plugin for (already-loaded) images | |
// Triple-licensed: Public Domain, MIT and WTFPL license - share and enjoy! | |
(function($) { | |
function img(url) { | |
var i = new Image; | |
i.src = url; | |
return 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
# toggle iTerm Dock icon | |
# add this to your .bash_profile or .zshrc | |
function toggleiTerm() { | |
pb='/usr/libexec/PlistBuddy' | |
iTerm='/Applications/iTerm.app/Contents/Info.plist' | |
echo "Do you wish to hide iTerm in Dock?" | |
select ync in "Hide" "Show" "Cancel"; do | |
case $ync in | |
'Hide' ) |
OlderNewer