Skip to content

Instantly share code, notes, and snippets.

View zz85's full-sized avatar

Joshua Koo zz85

View GitHub Profile
@zz85
zz85 / gist:069b2c1662f20a9ab3a1cc1e97b28ad1
Created July 22, 2022 23:35 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
@zz85
zz85 / ascii_charts.js
Last active December 14, 2020 16:44
Ascii Charts
// '█' -> '▏'
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]
@zz85
zz85 / questions.html
Created June 5, 2020 19:59
Happy fun times
<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 February 19, 2020 07:12
Snake to Camel Case
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({
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 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
@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 / 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 / animals.proto
Created April 27, 2018 14:16
Java Protobuf Any vs Oneof
message Dog {
}
message Cat {
}
message Elephant {
@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)