Skip to content

Instantly share code, notes, and snippets.

View 1j01's full-sized avatar

Isaiah Odhner 1j01

View GitHub Profile
@1j01
1j01 / inspect-object-hack.md
Last active July 30, 2018 20:27
Node.js hack to inspect [Object object]

Ever gotten some output on the console like [Object object], with no explanation? Can't find where it's being logged? Maybe it comes right before some ludicrous error or crash. Sometimes you just need a hack.

JavaScript

var ots = Object.prototype.toString;
Object.prototype.toString = function() { try { return JSON.stringify(this); } catch (e) { return ots.apply(this); } };
notes = ['A', 'A#', 'B', 'C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#']
getFrequency = (noten)->
440 * 2 ** ((noten - 49) / notes.length)
getNoteN = (notestr)->
i = notes.indexOf notestr[0...-1]
octave = parseInt notestr[-1..]
octave -= 1 if i >= notes.indexOf 'C'