Skip to content

Instantly share code, notes, and snippets.

View jochemstoel's full-sized avatar
💭
Dematerializing

Jochem Stoel jochemstoel

💭
Dematerializing
View GitHub Profile
function curry( arg ) {
var fn = this;
function curried( ...args ) {
return fn.apply( this, [arg, ...args] );
}
curried.curry = curry;
return curried;
}
@jochemstoel
jochemstoel / simple-promise-retry.js
Created September 1, 2018 04:48 — forked from briancavalier/simple-promise-retry.js
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@jochemstoel
jochemstoel / dutch_banks.json
Created August 23, 2018 16:42 — forked from wilgert/dutch_banks.json
All Dutch banks as JSON dictionary. Use this to calculate the BIC number by taking the bank_identifier part from the IBAN.
{
"ABNA":{
"BIC":"ABNANL2A",
"bank_name":"ABN AMRO BANK N.V"
},
"AEGO":{
"BIC":"AEGONL2U",
"bank_name":"AEGON BANK NV"
},
"ANDL":{
@jochemstoel
jochemstoel / nederlandse-gemeenten.json
Created August 23, 2018 16:24
Lijst van Nederlandse gemeenten per maart 2010, overgenomen van Wikipedia.
[
"Aa en Hunze",
"Aalburg",
"Aalsmeer",
"Aalten",
"Abcoude",
"Achtkarspelen",
"Alblasserdam",
"Albrandswaard",
"Alkmaar",
@jochemstoel
jochemstoel / utils.js
Created August 23, 2018 04:23 — forked from jankuca/utils.js
JavaScript Kit
(function () {
if (!Object.defineProperty) return;
Object.defineProperty(Function.prototype, 'initializing', {
value: false,
writable: true
});
Object.defineProperty(Function.prototype, '$super', {
value: function () {
@jochemstoel
jochemstoel / broadcast.js
Created August 22, 2018 16:29 — forked from wankdanker/broadcast.js
simple test cases for broadcast and multicast compatibility between node.js v0.4.x and v0.6.x
var dgram = require('dgram');
var socket = dgram.createSocket('udp4');
var testMessage = "[hello world] pid: " + process.pid;
var broadcastAddress = '255.255.255.255';
var broadcastPort = 5555;
socket.setBroadcast(true);
socket.bind(broadcastPort, '0.0.0.0');
function NotImplementedError(message) {
this.message = message || "";
}
NotImplementedError.prototype = Object.create(Error.prototype, {
constructor: { value: NotImplementedError },
name: { value: 'NotImplementedError' },
stack: { get: function() {
return new Error().stack;
}},
});
@jochemstoel
jochemstoel / dom-to-json.js
Created June 21, 2018 17:00 — forked from sstur/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
function toJSON(node) {
node = node || this;
var obj = {
nodeType: node.nodeType
};
if (node.tagName) {
obj.tagName = node.tagName.toLowerCase();
} else
if (node.nodeName) {
obj.nodeName = node.nodeName;
@jochemstoel
jochemstoel / client.js
Created June 10, 2018 02:43 — forked from jcarroyo/client.js
Node.js send file with pure socket (low level transfer)
var net = require('net');
var socket = new net.Socket();
socket.connect(5000, "127.0.0.1");
var fs = require('fs');
var path = require('path');
var packets = 0;
var buffer = new Buffer(0);
socket.on('data', function(chunk){
packets++;

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track