Skip to content

Instantly share code, notes, and snippets.

View zz85's full-sized avatar

Joshua Koo zz85

View GitHub Profile
@zz85
zz85 / README
Last active August 31, 2018 07:00
OSX Terminal Shortcuts (/Working with Long Terminal Commands)
Movements
Esc - F (Forward a word)
Esc - B (Back a word)
Ctrl - A (Start of line)
Ctrl - E (End of line)
Ctrl - F (Next line)
Ctrl - B (Previous line)
Deletions
.glitch {
width: 100%
}
.hero-wrap .glitch:after,
.hero-wrap .glitch:before {
content: attr(data-text);
position: absolute;
width: 100%;
top: 0;
color: #222222;
@zz85
zz85 / video_record.html
Created December 12, 2016 15:24
Video PlaybackRate Not Respected with MediaRecorder
<html>
<body>
<script>
const video = document.createElement('video');
document.body.appendChild(video);
video.autoplay = true;
video.src = 'videos.mp4';
video.playbackRate = 2;
@zz85
zz85 / lights.html
Last active December 10, 2016 08:02
Christmas Lights for Novation Launchpad
<html>
<head>
</head>
<body>
<script>
// Christmas light hack for Web Audio Hack Day 2016
// with vanilla JS tested on chrome and the LaunchPad
let device;
let stop = 0;
@zz85
zz85 / otsu.js
Last active February 4, 2022 18:31
Otsu's method - Automatic Histogram Based Image Thresholding
// Read https://en.wikipedia.org/wiki/Otsu%27s_method (added this since JS examples in wikipedia didn't work)
function otsu(histData /* Array of 256 greyscale values */, total /* Total number of pixels */) {
let sum = 0;
for (let t=0 ; t<256 ; t++) sum += t * histData[t];
let sumB = 0;
let wB = 0;
let wF = 0;
@zz85
zz85 / print.js
Last active June 10, 2023 19:16
Pretty Print JSON in Ascii Tree
// TODO add colors
sample = { a: { b: { c: 1, moo: [3,2,1] } }, z: 'zzzz' }
const asciitree = require('ascii-tree');
function pretty_json(v) {
console.log(JSON.stringify( v, 0, 2 ))
}
@zz85
zz85 / hello.js
Last active July 5, 2016 07:14
Adele Hello Chat Bot
// Inspired by http://www.dailymail.co.uk/femail/article-3672152/Man-infuriates-Facebook-scammer-Adele-lyrics.html && simon toh
// ADELE Hello lyrics
HelloMsgs = `
Hello, it's me, I was wondering
If after all these years you'd like to meet to go over everything
They say that time's supposed to heal, yeah
But I ain't done much healing
Hello, can you hear me?
@zz85
zz85 / array_joining.js
Created June 23, 2016 05:34
Fastest Array Joins on Strings
var array = ['livechat', 'visitors', 'apple', 'display_name'];
function testConcat(y) {
return array.concat([y]);
}
function testDeconstruct(y) {
return [...array, y];
}
@zz85
zz85 / test.html
Last active June 21, 2016 01:51
Game API
<html>
<body>
<style>
body {
font-family: 'monospace';
font-size: 12px;
}
</style>
Hello Copter World!
<div id="debug"></div>
@zz85
zz85 / mesh_simplify.html
Last active November 7, 2023 02:10
Fast Quadric Mesh Simplification JS port
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - modifier - Fast Quadric Mesh Simplification</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: #f0f0f0;