Skip to content

Instantly share code, notes, and snippets.

View zz85's full-sized avatar

Joshua Koo zz85

View GitHub Profile
@zz85
zz85 / flame_sunburst.html
Created September 28, 2017 11:21
Flamegraphs + Donuts Sunburst Charts
<html>
<body>
<script>
class File {
constructor(name, size) {
this.name = name;
this.size = size;
}
}
@zz85
zz85 / greenlet.js
Last active June 17, 2019 20:52
Greenlet.js Annotated
// This is @zz85's attempt to understand and annotate the greenlet.js lib
// from https://github.com/developit/greenlet/blob/master/greenlet.js
/** Move an async function into its own thread.
* @param {Function} fn The (async) function to run in a Worker.
*/
export default function greenlet(fn) { // greenlet takes in a function as argument
let w = new Worker( // creates a web worker
URL.createObjectURL( // that has a local url
new Blob([ // created from a blob that has the following content
@zz85
zz85 / DragControls.js
Last active October 22, 2021 13:05
Spline / Path Bend Modifier for Three.js
/*
* @author zz85 / https://github.com/zz85
* @author mrdoob / http://mrdoob.com
* Running this will allow you to drag three.js objects around the screen.
*/
THREE.DragControls = function ( _objects, _camera, _domElement ) {
if ( _objects instanceof THREE.Camera ) {
@zz85
zz85 / GPUComputationRenderer.js
Last active January 20, 2020 14:37
Faster Pixel Sort
/**
* @author yomboprime https://github.com/yomboprime
*
* GPUComputationRenderer, based on SimulationRenderer by zz85
*
* The GPUComputationRenderer uses the concept of variables. These variables are RGBA float textures that hold 4 floats
* for each compute element (texel)
*
* Each variable has a fragment shader that defines the computation made to obtain the variable in question.
* You can use as many variables you need, and make dependencies so you can use textures of other variables in the shader
@zz85
zz85 / README
Last active March 21, 2018 22:55
Audio Experiements
Idea: use web rtc/ web audio to record a short audio clip, do pitch changing on it
Links
- http://recordrtc.org/
- https://github.com/danielstorey/WebAudioTrack
- https://www.webrtc-experiment.com/msr/audio-recorder.html
@zz85
zz85 / index.js
Created March 13, 2018 08:26
PM2 IPC
const express = require('express')
const app = express()
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(4444, () => console.log('Example app listening on port 4444!'))
process.on('message', function(packet) {
console.log('process message received', packet, process.env.pm_id, process.env.NODE_APP_INSTANCE)
@zz85
zz85 / animals.proto
Created April 27, 2018 14:16
Java Protobuf Any vs Oneof
message Dog {
}
message Cat {
}
message Elephant {
@zz85
zz85 / postions.js
Last active July 26, 2022 18:54
Portfolio Positions
const Ib = require('ib');
var ib = new Ib()
function getPositions(ib, cb) {
ib.on('position', onPositions)
ib.reqPositions()
var positions = [];
var pending = null;
@zz85
zz85 / drunk_videospeed.js
Last active October 28, 2018 22:35
drunk video script
/**
* seeing how @thespite gets drunk
* https://twitter.com/thespite/status/1056264007450062848
*/
e = t => t < .5 ? 2 * t * t : -1 + (4 - 2 * t ) * t,
n = _ => performance.now(), cT = n(),
nT = cT,
cV = 1,
nV = 1,
@zz85
zz85 / du.rs
Created April 29, 2019 11:51
Rust Disk Usage
use std::io;
use std::fs::{self, DirEntry};
use std::path::Path;
use std::env;
/**
* compile: rustc du.rs
* run: compare
* /usr/bin/time -lp ./du ~/Documents
* /usr/bin/time -lp du -sk ~/Documents