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
// Set a value at a string-designated path. | |
// | |
// Takes an object to be modified, a string path ('a.b') and a value to be set | |
// at that path. | |
// | |
// Returns the modified object (although the changes are made in place) | |
var set = function (obj, path, val) { | |
if (!obj || typeof obj !== "object") return obj; | |
if (!path || typeof path !== 'string') return obj; | |
var keys = path.split('.'), |
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
// Recursively sum integer properties of an object | |
var sumObject = function (source, target) { | |
Object.keys(source).forEach(function (key) { | |
if (typeof source[key] === "object") { | |
if (!target[key]) target[key] = {}; | |
target[key] = sumObject(source[key], target[key]); | |
} | |
if (typeof source[key] === "number") { | |
if (!target[key]) target[key] = 0; | |
target[key] += source[key]; |
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
/** | |
* Sandbox | |
* | |
* Use Backbone Events to create a generic event handler. | |
* http://backbonejs.org/#Events | |
*/ | |
define([], function () { | |
return { | |
create: function (parent) { |
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
# A ~/.gitconfig file | |
[user] | |
name = YOUR NAME | |
email = YOUR EMAIL | |
[github] | |
user = YOUR USERNAME | |
token = YOUR TOKEN | |
[core] | |
quotepath = false | |
editor = nvim |
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?’.