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
# First: | |
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done | |
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.* | |
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following: | |
#go to /usr/local/lib and delete any node and node_modules | |
cd /usr/local/lib | |
sudo rm -rf node* |
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
// Promise.all is good for executing many promises at once | |
Promise.all([ | |
promise1, | |
promise2 | |
]); | |
// Promise.resolve is good for wrapping synchronous code | |
Promise.resolve().then(function () { | |
if (somethingIsNotRight()) { | |
throw new Error("I will be rejected asynchronously!"); |
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 t(s, d) { | |
for (var p in d) | |
s = s.replace(new RegExp('{' + p + '}', 'g'), d[p]); | |
return s; | |
} | |
// Usage | |
var build = function(id, href) { | |
var options = { | |
id: id |
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
// Inspired by http://clubmate.fi/jquerys-closest-function-and-pure-javascript-alternatives/ | |
// Recursion implementation | |
function closestEl(el, fn) { | |
return el && (fn(el) ? el : closestEl(el.parentNode, fn)); | |
} | |
// "By Class" helper (depends on closestEl) | |
function closestByClass(el, classValue, skipSelf) { | |
var targetEl = skipSelf ? el.parentNode : el; |
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
html, | |
body { | |
height: 100%; | |
} | |
body { | |
background: #fffad5; | |
color: black; | |
} | |
.wrapper { | |
height: 100%; |
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 inherit(obj) { | |
function F() {} | |
F.prototype = obj; | |
return new F(); | |
} | |
// Usage | |
function A(){}; | |
A.prototype.someMethod = function(){}; | |
function 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 inherit = (function () { | |
var F = function () {}; | |
return function (C, P) { | |
F.prototype = P.prototype; | |
C.prototype = new F(); | |
C.uber = P.prototype; | |
C.prototype.constructor = C; | |
} | |
}()); |
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
.wrapper{ | |
float: left; | |
width: 100%; | |
background: yellow; | |
} | |
.content{ | |
margin-left: 200px; | |
} | |
.sidebar{ | |
width: 200px; |