Skip to content

Instantly share code, notes, and snippets.

@AllThingsSmitty
AllThingsSmitty / url.js
Created March 28, 2015 14:46
Get an absolute URL with JavaScript
var getAbsoluteUrl = (function () {
var a;
return function (url) {
if(!a) a = document.createElement('a');
a.href = url;
return a.href;
};
})();
@th507
th507 / currying-with-generator.js
Last active August 29, 2015 14:23
Currying with generator
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;
}
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);
}
}
@tiye
tiye / hmr-sharing.md
Last active November 10, 2015 05:10
My sharing on HMR, generate slide with https://github.com/adamzap/landslide

Hot Module Replacing with Webpack


Me

Chen Yong, @jiyinyiyong

@addyosmani
addyosmani / 12-days.js
Last active February 3, 2016 18:31
12 Days of Christmas in ES2015 - paste this into your DevTools console!
// 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 = [
"🐦🍐🌳",
"🐢🐦",
"🇫🇷🐔",
"📞🐦",
"💛💍",
"🐦🍳 ",
"🐦🏊",
@AllThingsSmitty
AllThingsSmitty / readyState.js
Last active March 9, 2016 19:59
Using readyState to show document state
// 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':
@mbbroberg
mbbroberg / iterm2.textile
Last active February 21, 2017 07:05
A gathering of useful shortcuts for others new to iTerm2

iTerm2 – Useful Shortcuts (Mac OS X)

with a hat tip to Sublime Text 2 Shortcuts

The Awesome

⌘; autocomplete
⌘⌥B instant replay
⌘⌥E search across all tabs
@sofish
sofish / array_unique.js
Last active July 11, 2017 01:36
Array Unique
function unique_keys(array) {
var values = {};
for(var i = 0; i < array.length; i++) {
values[array[i]] = null;
}
return Object.keys(values);
}
// 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;
}
@lg0
lg0 / toggleiTerm2icon
Last active January 11, 2018 02:51
show/hide iTerm2 Dock icon
# 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' )