Skip to content

Instantly share code, notes, and snippets.

(function() {
let action = 'barks';
let foo = function() {
console.log('foo', action);
};
})();
console.log(typeof foo);
let Foo = function() {
this._name = 'Foo';
};
Foo.prototype.bark = function() {
console.log(this._name, ' barks');
};
let foo = new Foo();
let fooBark = foo.bark;
https://github.com/altercation/solarized/issues/146
export PATH=$PATH:~/.bin:~/.nvm
export DOCKER_HOST=tcp://localhost:4243
export PS1="\[\033[1;32m\]`hostname`\[\033[0m\] \[\033[1;35m\]\u\[\033[0m\]:\[\033[1;33m\]\w\[\033[0m\]$ "
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export PATH=$PATH:/usr/local/share/gcutil
source ~/.nvm/nvm.sh
@snowmantw
snowmantw / gist:f6ae1533f31bb820dbc5
Created December 8, 2015 14:56
Static decorator check.
function procedure(instance, method, description) {
//console.log(description)
description.value.__procedure = true;
var org = description.value;
if (instance.__procedureDefined) {
throw new Error('Already has one procedure');
}
instance.__procedureDefined = true;
description.value = function() {
@snowmantw
snowmantw / gist:15d20541e63ad938f85a
Created December 2, 2015 11:56
Raptor result for Cold + Warm switching for FFOS Music v2
| Metric | Mean | Median | Min | Max | StdDev | 95% Bound |
| -------------------------- | ---- | ------ | ---- | ---- | ------ | --------- |
| firstTabAppearing | 0 | 0 | 0 | 0 | 0 | 0 |
| songsTabSwitching-cold | 23 | 23 | 23 | 23 | 0 | 23 |
| songsTabAppearing-cold | 953 | 953 | 953 | 953 | 0 | 953 |
| albumsTabSwitching-cold | 991 | 991 | 991 | 991 | 0 | 991 |
| albumsTabAppearing-cold | 1863 | 1863 | 1863 | 1863 | 0 | 1863 |
| artistsTabSwitching-cold | 1909 | 1909 | 1909 | 1909 | 0 | 1909 |
| artistsTabAppearing-cold | 2899 | 2899 | 2899 | 2899 | 0 | 2899 |
| playlistsTabSwitching-cold | 2935 | 2935 | 2935 | 2935 | 0 | 2935 |
@snowmantw
snowmantw / gist:bd9722e9a6e4320b62fb
Created November 5, 2015 08:29
await + async + generator + destruct + iterable
async function f(e) {
var p = new Promise((r) => {
setTimeout(() => {r(e)}, 1000);
})
return p;
}
function* makeSimpleGenerator(array){
var nextIndex = 0;
while(nextIndex < array.length){
TodoListManager.prototype.onItemChecked = function(event) {
// Do something when the Todo item is clicked.
var checked = event.target.classList.contains('checked');
var todoId = Number.parseInt(event.target.dataset.todoId, 10);
this._listTodoItem[todoId].checked = checked;
};
TodoListManager.prototype.start = function() {
window.addEventListener('click', this.onItemChecked)
};
@snowmantw
snowmantw / gist:f87e307de02eed8ebeeb
Last active October 15, 2015 10:06
Closure capture
(function() {
var someArray = [1, 2, 3];
var body = document.querySelector('body');
body.addEventListener('click', function() {
// Note: 'someArray' is neither an parameter nor a global variable.
// Will print '1,2,3' in console when clicking.
console.log(someArray.join(','));
// And since this function will be triggered later,
// you can see closure is accross the time & space (LOL)
});
@snowmantw
snowmantw / gist:26777b20e5782c63e915
Last active August 29, 2015 14:27
It's a reducer, actually
// "pure" version
[1, 2, 3, 4].reduce(function(acc, elem) {
var result = [];
// Generate multiple "elements".
for (var i = 0; i < elem; i++) {
result.push(i);
}
// And generate the new "array" as the new accumulator.
return acc.concat(result);
}, [])