Skip to content

Instantly share code, notes, and snippets.

@jcready
jcready / MediaElementSource.js
Last active December 27, 2015 02:39
Processing Web Audio ChannelData from MediaElementSource.
var audioContext, audioProcess, audioSource,
result = document.createElement('h3'),
output = document.createElement('span'),
mp3 = 'http://songs.jonathancoulton.com/mp3/First%20of%20May.mp3',
ogg = 'http://upload.wikimedia.org/wikipedia/en/4/45/ACDC_-_Back_In_Black-sample.ogg',
gotData = false, data, audio = new Audio();
function connect() {
audioContext = window.AudioContext ? new AudioContext() : new webkitAudioContext(),
audioSource = audioContext.createMediaElementSource( audio ),
@jcready
jcready / timestamp.log.js
Created April 24, 2014 17:34
Timestamps for console.log()
(function(){
var log = console.log;
console.log = function(){
var timestamp = '['+new Date().toJSON().slice(14,-1)+']';
if (arguments.length) {
if (typeof arguments[0] === "string") {
var args = Array.prototype.slice.call(arguments, 0);
args[0] = "%s " + arguments[0];
args.splice(1, 0, timestamp);
return log.apply(console, args);
function MasterStore() {
this.datastore = {};
}
MasterStore.prototype.has = function(key, value){
if (value == null) return this.datastore.hasOwnProperty(key);
if (Array.isArray(value)) {
for (var i = 0; i < value.length; i++) {
if (this.datastore[key].indexOf(value[i]) < 0) {
return false;
  • a task list item
  • list syntax required
  • normal formatting, @mentions, #1234 refs
  • incomplete
  • completed
/* jshint newcap: false */
var B = require("bluebird/js/main/promise")();
var Bproto = B.prototype;
var deferredPrototype = B.pending().constructor.prototype;
deferredPrototype.makeNodeResolver = function() {
return this.asCallback;
};
var B = require("bluebird/js/main/promise")();
var Bproto = B.prototype;
var deferredPrototype = B.pending().constructor.prototype;
deferredPrototype.makeNodeResolver = function() {
return this.asCallback;
};
function bind(fn, ctx) {
a2p addr2line animate appletviewer8 ar as aserver awk base64 bashbug bashbug-64 bdftopcf bdftops berkeley_db_svc bmp2tiff build-classpath build-classpath-directory build-jar-repository bunzip2 bzcat bzcmp bzdiff bzgrep bzip2 bzip2recover bzless bzmore c++filt c2ph ca-legacy cairo-sphinx cal captoinfo catchsegv certutil chcon check-binary-files chrt chvt cksum clean-binary-files clear cmp cmsutil col colcrt colrm column comm compare composite conjure convert create-jar-links crlutil csplit curl cut d8 db_archive db_checkpoint db_codegen db_deadlock db_dump db_dump185 db_hotbackup db_load db_printlog db_recover db_stat db_upgrade db_verify deallocvt diff diff-jars diff3 dir dircolors dirname display du dumphint dvipdf dwp eject elfedit env eps2eps eqn eu-addr2line eu-ar eu-elfcmp eu-elflint eu-findtextrel eu-make-debug-archive eu-nm eu-objdump eu-ranlib eu-readelf eu-size eu-stack eu-strings eu-strip eu-unstrip expand expr extcheck8 factor fallocate fax2ps fax2tiff fc-cache fc-cat fc-list fc-match fc-query fc-s
(function(){
const EE = require('events')
const Stream = require('stream')
const promise = Symbol('StreamPromise')
Stream.prototype.constructor = function () {
EE.call(this)
this[promise] = new Promise((resolve, reject) => {
this.on('error', reject)
this.on('end', resolve)
@jcready
jcready / integration.async.await.js
Last active May 13, 2017 17:35
Node.js example of GitHub Integration auth process
// With async/await support
const fs = require('fs')
const jwt = require('jwt-simple')
const pem_file = '/path/to/github.pem' // the absolute path to your Application Pem Certificate issued by GitHub
const integration_id = 0 // GitHub Application Integration ID
const installation_id = 0 // once installed on an organization. The Organization Integration ID
const expire_seconds = 60 // number of seconds the jwt token expires (max ~600 but not designated by GitHub)
const slug = 'owner/repo' // name of repo for demo purposes
const privateKey = fs.readFileSync(pem_file)
isBalanced = (() => {
const braces = {
'{': [ 0, 1 ],
'}': [ 0, -1 ],
'[': [ 1, 1 ],
']': [ 1, -1 ],
'(': [ 2, 1 ],
')': [ 2, -1 ]
}
return function isBalanced (s) {