Enjoy. Oh, and if you fancy cross-posting from ADN to Twitter, check out #twapp.
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
// Debouce a callback | |
var debounce = (function () { | |
// Save the previously used callbacks and timers | |
var cbs = [], | |
timers = []; | |
// When debounce is called, they're calling this function | |
return function (delay, cb) { | |
// Find or store this callback | |
var cbIndex = cbs.indexOf(cb); |
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
// Insert value into into array (via comparison cb) then call the done cb | |
var insert = function insert(item, arr, compare, done) { | |
if (!done) { | |
done = compare; | |
compare = false; | |
} | |
compare = compare || function (a, b, cb) { return cb(a < b); }; |
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 myModule = (function () { | |
// Private | |
var name = "AsyncJS"; | |
// Public | |
return { | |
getName: function () { | |
return name; | |
}, | |
setName: function (value) { | |
return (name = value); |
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
// Array | |
// pros: | |
// simple, no duplication of ports | |
// cons: | |
// a tld can be duplicated | |
{ | |
6000: [ | |
"api.name.dev", | |
"admin.name.dev" |
Why are am I here? Why am I alive, on this planet, at this time?
A big question? No, a deepity. In one reading, truth. In another, nonsense.
The word ‘why’ can be taken in two ways: why meaning for what purpose did x happen; and why meaning how did x happen. Let's look at ‘why am I here?’ from both perspectives.
In the first sense, the question can be rewritten as ‘for what purpose am I here?’. In the second, ‘how is it that I came to be here?’.
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
#!/bin/sh | |
# Github -> Bitbucket | |
# - Save this in /usr/local/bin as github-to-bitbucket | |
# - Then: | |
# cd /usr/local/bin | |
# chmod u+x github-to-bitbucket | |
# - Then restart your terminal | |
# - You should now have a github-to-bitbucket command |
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
// io.js | |
define(['jquery'], function ($) { | |
return $({}); | |
}); | |
... | |
// main.js | |
require(['io', 'toast'], function (io, toast) { | |
io.on('my_event', function () {}); |
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
#!/bin/sh | |
# Commit and sync to Github | |
# To install, run: | |
# cd /usr/local/bin && wget -O commit-and-sync https://gist.github.com/phuu/5680243/raw/gistfile1.sh && chmod u+x commit-and-sync | |
# then restart yaw terminals. | |
BRANCH="$(git symbolic-ref HEAD 2>/dev/null)" | |
# Reconnaissance |
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
#!/bin/sh | |
# install: | |
# cd /usr/local/bin && wget -O stage-me https://gist.github.com/phuu/5704768/raw/gistfile1.sh && chmod u+x stage-me | |
branch=`git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3-` | |
echo "Merging ⭠ $branch into ⭠ staging." | |
read -p "Is this correct? [y/N] : " -r | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then |