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 testObject = { | |
id : 5, | |
name : 'foo' | |
} | |
function censor(censor) { | |
return (function() { | |
var i = 0; | |
return function(key, 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
/** | |
* Given a list of random comments, having dates and parentIds, this code | |
* sorts the list following parent-child relationships and dates. | |
* | |
* Notation: | |
* C1R2 stands for 'Second reply to first comment' | |
* C2R2R1R1 stands for '1st Reply to the 1st Reply to the | |
* 2nd Reply of the 2nd Comment' | |
* | |
* Input: |
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 log(n) { console.log(n); } | |
setTimeout(function A() { | |
setTimeout(function B() { | |
log(1); | |
setTimeout(function D() { log(2); }, 0); | |
setTimeout(function E() { log(3); }, 0); | |
}, 0); | |
setTimeout(function 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
var getValue = function(value, cb) { | |
setTimeout(function err() { | |
throw Error(); | |
}, 0); | |
return cb(null, value); | |
}; | |
var result = getValue(5, (err, a) => { | |
console.log(a); | |
}); |
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/bash | |
# This script confirms that the version we have now doesn't already exist in npm | |
GREEN='\033[0;32m' | |
RED='\033[0;31m' | |
CYAN='\033[0;36m' | |
NC='\033[0m' | |
# Version key/value should be on its own line |
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
$ brew install jq | |
$ echo "alias pasc='cat package.json | jq -r .scripts'" >> ~/.bashrc | |
$ source ~/.bashrc | |
$ pasc | |
{ | |
"start": "node server.js", | |
"test": "echo \"Error: no test specified\" && exit 1" | |
} |
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
// Replace this: | |
for (const value of myArray) { | |
console.log(value) | |
} | |
// with: | |
forEach(value => console.log(value), myArray) | |
const double = x => x * 2 | |
map(double, [1, 2, 3]) |
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 assert = require('assert'); | |
var options = { | |
'auth': { | |
'user': 'USER', | |
'pass': 'PASS', | |
'sendImmediately': false | |
} | |
}; |
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 assert = require('assert'); | |
var options = { | |
'auth': { | |
'user': 'USER', | |
'pass': 'PASS', | |
'sendImmediately': false | |
} | |
}; |
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
# Run this in conjunction with https://github.com/jishi/node-sonos-http-api | |
import urllib.request | |
import json | |
import time | |
BANNED_ARTISTS = ['drake'] | |
while True: | |
state = json.loads(urllib.request.urlopen("http://localhost:5005/state").read().decode('utf-8')) |
OlderNewer