Skip to content

Instantly share code, notes, and snippets.

Walmik Deshpande walmik

Block or report user

Report or block walmik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@walmik
walmik / scribble-drummer.js
Last active Jul 19, 2019
This a simple script that will create a few MIDI files with a slight variation each time you run it with nodejs on the terminal
View scribble-drummer.js
// Make sure you have Node version 8+ installed locally and you have run `npm install scribbletune` before running this script
const scribble = require('scribbletune');
const ptn = 'xxxx'.repeat(7);
const A = 'xxx[x[RR]]';
const B = 'xx[x[RR]][x[RR]]';
const C = 'x-[x[RR]]';
const kick = scribble.clip({
pattern: ptn + A + ptn + B + ptn + A + ptn + C,
notes: 'c4',
View simpleMelody.js
const scribble = require('scribbletune');
const chords = scribble.getChordsByProgression('C4 minor', 'ii III ii v'); //i III ii v
const notes = [];
let pattern = '';
chords.split(' ').forEach((c, i) => {
const chord = scribble.chord(c);
if (i % 2 !== 0) {
// use 2 quarter notes
notes.push(chord[0]);
@walmik
walmik / riff.js
Last active Dec 23, 2018
Create a commonly used dance music riff using just Scribbletune
View riff.js
const scribble = require('scribbletune');
const getRandomPattern = function (count) {
let str = '';
for (let i=0; i < (count || 8); i++) {
str += Math.round(Math.random()) ? 'x-' : '-x';
}
return str;
}
@walmik
walmik / webaudio-seq.js
Created Feb 27, 2018
Code snippet to load a couple of wave files (from disc) and play em in a sequence
View webaudio-seq.js
window.onload = init;
var context;
var bufferLoader;
function BufferLoader(context, urlList, callback) {
this.context = context;
this.urlList = urlList;
this.onload = callback;
this.bufferList = new Array();
this.loadCount = 0;
View gist:b31feb7d3f59d6a12d7d
How to debug a #nodejs v0.10 app?
While using the usual means to debug a Node.js v0.10 app using node-inspector, we encounter the following issue where at every second:
`Failed to open socket on port 5858, waiting 1000 ms before retrying`
The fix for this was implemented only v0.11 onward. Here s a quick recipe to debug v0.10 Node.js apps by noting the process id of the node app. Original link: http://strongloop.com/strongblog/whats-new-nodejs-v0-12-debugging-clusters/
Install node-inspector:
npm install -g node-inspector
In a terminal window, navigate to the directory of your node app and start it:
@walmik
walmik / double-check.js
Created Oct 29, 2013
Given an array of integers and an integer return true if any 2 integers of the array add up to a number equal to the integer For example: fn ( [2,1,3,4], 4 ); should return true
View double-check.js
function doubleCheck(arr, intgr) {
var bool = false;
arr = arr.sort(function(a,b) {return a-b;});
console.log(arr);
while(arr.length) {
var num = arr.shift();
for(var i=0; i<arr.length; i++) {
console.log('iteration' + arr[i]);
if(num + arr[i] === intgr) {
return true;
You can’t perform that action at this time.