Skip to content

Instantly share code, notes, and snippets.

View kevincennis's full-sized avatar
💭
this is dumb

Kevin Ennis kevincennis

💭
this is dumb
View GitHub Profile
@kevincennis
kevincennis / v8.md
Last active May 6, 2024 05:25
V8 Installation and d8 shell usage

Installing V8 on a Mac

Prerequisites

  • Install Xcode (Avaliable on the Mac App Store)
  • Install Xcode Command Line Tools (Preferences > Downloads)
  • Install depot_tools
    • $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
    • $ nano ~/.zshrc
    • Add path=('/path/to/depot_tools' $path)
@kevincennis
kevincennis / buffertowav.js
Last active February 17, 2024 14:05
Buffer to WAV
// assuming a var named `buffer` exists and is an AudioBuffer instance
// start a new worker
// we can't use Recorder directly, since it doesn't support what we're trying to do
var worker = new Worker('recorderWorker.js');
// initialize the new worker
worker.postMessage({
command: 'init',
@kevincennis
kevincennis / gist:3928503
Created October 21, 2012 21:03
Instant karaoke track with the Web Audio API
var url = 'http://static1.kevincennis.com/sounds/callmemaybe.mp3'
, audio = new Audio(url)
, context = new webkitAudioContext()
// 512 samples per frame, stereo input, mono output
, processor = context.createJavaScriptNode(512, 2, 1)
, sourceNode
audio.addEventListener('canplaythrough', function(){
sourceNode = context.createMediaElementSource(audio)
sourceNode.connect(processor)
@kevincennis
kevincennis / example.js
Last active October 25, 2023 11:21
Async Concurrent Queue
( async() => {
const items = 'abcdefghijklmnopqrstuvwxyz'.split('');
const concurrency = 10;
async function process() {
return new Promise( r => setTimeout( r, Math.random() * 1000 ) );
}
async function report({ item, processed, total, done }){
if ( done ) {
@kevincennis
kevincennis / markov.js
Last active April 7, 2023 17:44
Quick and dirty Markov chain text generator
// basic usage: new Markov(lotsOfText).generate()
// markov chain constructor
//
// @string input {example text}
// @integer len {optional # of words to output}
// @integer stateSize {optional chain order}
function Markov( input, len, stateSize ){
this.cache = Object.create(null)
this.words = input.split(/\s/)
@kevincennis
kevincennis / music.js
Last active April 21, 2022 02:30
simple, lightweight sequencer in javascript with the web audio api
// For more documentation and a newer version,
// check out the full repo: https://github.com/kevincennis/TinyMusic
@kevincennis
kevincennis / README.md
Created March 9, 2022 18:43
deno node compat mongo demo
npm i
deno run --unstable --compat --allow-all index.j
// see http://jsbin.com/okoxiq/3/edit
var src
, fftSize = 1024
, audio = new Audio()
, ac = new webkitAudioContext()
, analyser = ac.createAnalyser()
, timeData = new Uint8Array(fftSize)
, bar = document.querySelector('.bar')
, url = 'http://static1.kevincennis.com/sounds/callmemaybe.mp3';
@kevincennis
kevincennis / curry.js
Last active February 12, 2021 00:33
curry.js
function curry( fn ) {
var arity = fn.length;
return (function resolver() {
var mem = Array.prototype.slice.call( arguments );
return function() {
var args = mem.slice();
Array.prototype.push.apply( args, arguments );
return ( args.length >= arity ? fn : resolver ).apply( null, args );
};
@kevincennis
kevincennis / .nvmrc
Last active July 9, 2020 17:31
GraphQL Demo
10.6.0