Skip to content

Instantly share code, notes, and snippets.

View jochemstoel's full-sized avatar
💭
Dematerializing

Jochem Stoel jochemstoel

💭
Dematerializing
View GitHub Profile
@jochemstoel
jochemstoel / sec2time.js
Created September 5, 2018 21:47 — forked from vankasteelj/sec2time.js
Javascript - Seconds to Time (hh:mm:ss,ms) -> sec2time(593.685038) becomes 00:09:53,685
function sec2time(timeInSeconds) {
var pad = function(num, size) { return ('000' + num).slice(size * -1); },
time = parseFloat(timeInSeconds).toFixed(3),
hours = Math.floor(time / 60 / 60),
minutes = Math.floor(time / 60) % 60,
seconds = Math.floor(time - minutes * 60),
milliseconds = time.slice(-3);
return pad(hours, 2) + ':' + pad(minutes, 2) + ':' + pad(seconds, 2) + ',' + pad(milliseconds, 3);
}
@jochemstoel
jochemstoel / clean_audio.sh
Created September 3, 2018 15:15 — forked from devoncrouse/clean_audio.sh
Using Sox (http://sox.sourceforge.net) to remove background noise and/or silence from audio files (individually, or in batch).
# Create background noise profile from mp3
/usr/bin/sox noise.mp3 -n noiseprof noise.prof
# Remove noise from mp3 using profile
/usr/bin/sox input.mp3 output.mp3 noisered noise.prof 0.21
# Remove silence from mp3
/usr/bin/sox input.mp3 output.mp3 silence -l 1 0.3 5% -1 2.0 5%
# Remove noise and silence in a single command
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');

Keybase proof

I hereby claim:

  • I am jochemstoel on github.
  • I am jochemstoel (https://keybase.io/jochemstoel) on keybase.
  • I have a public key ASAzBTDNcD-RjUotvku7vHwe5VyPmkrPNEzn3Zw4qus9AQo

To claim this, I am signing this object:

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;
}},
});