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 / string-utils.js
Created December 3, 2018 14:43 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str){
return str.toLowerCase();
@jochemstoel
jochemstoel / unCamelCase.js
Created December 3, 2018 14:41 — forked from mattwiebe/unCamelCase.js
unCamelCase.js
/**
* Turns someCrazyName into Some Crazy Name
* Decent job of acroynyms:
* ABCAcryonym => ABC Acryoynm
* xmlHTTPRequest => Xml HTTP Request
*/
String.prototype.unCamelCase = function(){
return this
// insert a space between lower & upper
.replace(/([a-z])([A-Z])/g, '$1 $2')
@jochemstoel
jochemstoel / ffmpeg-compress-mp4
Created November 19, 2018 13:01 — forked from lukehedger/ffmpeg-compress-mp4
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@jochemstoel
jochemstoel / ISO-639-1-language.json
Created November 2, 2018 20:13 — forked from jrnk/ISO-639-1-language.json
ISO 639-1 Alpha-2 codes of languages JSON
[
{
"code": "ab",
"name": "Abkhaz"
},
{
"code": "aa",
"name": "Afar"
},
{
// Loads js files
function loadScripts(urlArray,cb) {
var scriptLoadCount = scriptLoadedCount = 0;
loadScript();
function loadScript() {
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
var url = (urlArray[scriptLoadCount].indexOf('?') == -1) ? urlArray[scriptLoadCount] + '?d=' + Math.random() : urlArray[scriptLoadCount] + '&d=' + Math.random()
@jochemstoel
jochemstoel / Note to Frequency
Created October 25, 2018 16:18 — forked from stuartmemo/Note to Frequency
Convert note to frequency
// Takes string of Note + Octave
// Example:
// var frequency = getFrequency('C3');
var getFrequency = function (note) {
var notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#'],
octave,
keyNumber;
if (note.length === 3) {
@jochemstoel
jochemstoel / node-walk.js
Created October 1, 2018 11:18 — forked from lovasoa/node-walk.es6
Walk through a directory recursively in node.js.
var fs = require("fs"),
path = require("path");
function walk(dir, callback) {
fs.readdir(dir, function(err, files) {
if (err) throw err;
files.forEach(function(file) {
var filepath = path.join(dir, file);
fs.stat(filepath, function(err,stats) {
if (stats.isDirectory()) {
@jochemstoel
jochemstoel / unless.js
Created September 27, 2018 00:20 — forked from samihda/unless.js
JavaScript unless macro with sweet.js
syntax unless = function (ctx) {
let test = ctx.next().value;
let body = ctx.next().value;
return #`if (!${test}) ${body}`;
}
var answer = 0;
unless (answer === 42) {
@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