Skip to content

Instantly share code, notes, and snippets.

Avatar

Joshua Koo zz85

View GitHub Profile
@zz85
zz85 / ascii_charts.js
Last active Dec 14, 2020
Ascii Charts
View ascii_charts.js
// '█' -> '▏'
times = (x) => new Array(x).fill(0);
var blocks = times(8).map((_, i) => String.fromCharCode(9608 + i));
var values = times(8).map(() => Math.random() * 10000);
// values = [0, 4, 10, 20, 50]
// values = [5, 5, 5, 5, 5]
// values = [ 0, 1,2,3,4,5,6,7,]
// values = [0, 0, 0]
View questions.html
<html>
<body>
<style>
body {
font-size: 20px;
text-align: center;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
'Droid Sans', 'Helvetica Neue', sans-serif !important;
padding: 40px;
@zz85
zz85 / snake_toCamel.js
Created Feb 19, 2020
Snake to Camel Case
View snake_toCamel.js
m = /\s+(([A-Z0-9]+_)*([A-Z0-9]+))\s+/g
locations = [];
while (match = m.exec(x)) {
console.log(match)
str = match[1].split('_')
.map(s => s[0].toUpperCase() + s.substring(1).toLowerCase())
.join('')
locations.push({
View after.sh
Testing ciphers using signature preferences of size: 1
Creating ThreadPool of size: 8
Digests: SHA256 ClientAuth: None Vers: Default ... PASSED
Digests: SHA384 ClientAuth: None Vers: Default ... PASSED
Digests: SHA1 ClientAuth: None Vers: Default ... PASSED
Digests: SHA384 ClientAuth: None Vers: Default ... PASSED
Digests: SHA1 ClientAuth: None Vers: Default ... PASSED
Digests: SHA224 ClientAuth: None Vers: Default ... PASSED
Digests: SHA224 ClientAuth: None Vers: Default ... PASSED
Digests: SHA256 ClientAuth: None Vers: Default ... PASSED
@zz85
zz85 / du.rs
Created Apr 29, 2019
Rust Disk Usage
View du.rs
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
@zz85
zz85 / drunk_videospeed.js
Last active Oct 28, 2018
drunk video script
View drunk_videospeed.js
/**
* 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 / postions.js
Last active Aug 24, 2018
Portfolio Positions
View postions.js
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 / animals.proto
Created Apr 27, 2018
Java Protobuf Any vs Oneof
View animals.proto
message Dog {
}
message Cat {
}
message Elephant {
View index.js
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 / README
Last active Mar 21, 2018
Audio Experiements
View README
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