Skip to content

Instantly share code, notes, and snippets.

View binary-person's full-sized avatar
💭
*insert status here*

Simon Cheng binary-person

💭
*insert status here*
View GitHub Profile
@binary-person
binary-person / EasyXterm.js
Last active June 5, 2021 23:41
readline wrapper for xterm.js
class EasyXterm {
commandListeners = [];
historyBuffer = ['']; // idx 0 is the latest
historyAt = 0;
cursorAt = 0; // 0 is at the end of commandBuffer. positive is left
hidden = false;
get commandBuffer() {
return this.historyBuffer[0];
}
set commandBuffer(value) {
@binary-person
binary-person / data.json
Last active May 28, 2021 18:38
shape data for diep.io. each index representing 10th of a second for 260 seconds. second data contains 277.7 seconds
{"Square":{"<1, 2>":[{"x":-89,"y":-539,"angle":-6.203125},{"x":-89,"y":-537,"angle":-6.21875},{"x":-89,"y":-534,"angle":-6.25},{"x":-89,"y":-532,"angle":-6.28125},{"x":-89,"y":-529,"angle":-6.296875},{"x":-89,"y":-527,"angle":-6.328125},{"x":-89,"y":-524,"angle":-6.359375},{"x":-89,"y":-522,"angle":-6.375},{"x":-89,"y":-519,"angle":-6.40625},{"x":-89,"y":-517,"angle":-6.421875},{"x":-89,"y":-514,"angle":-6.453125},{"x":-89,"y":-512,"angle":-6.46875},{"x":-89,"y":-509,"angle":-6.5},{"x":-89,"y":-507,"angle":-6.53125},{"x":-89,"y":-504,"angle":-6.546875},{"x":-89,"y":-502,"angle":-6.578125},{"x":-89,"y":-499,"angle":-6.609375},{"x":-89,"y":-497,"angle":-6.625},{"x":-90,"y":-494,"angle":-6.65625},{"x":-90,"y":-492,"angle":-6.671875},{"x":-90,"y":-489,"angle":-6.703125},{"x":-90,"y":-487,"angle":-6.71875},{"x":-91,"y":-484,"angle":-6.75},{"x":-91,"y":-482,"angle":-6.78125},{"x":-91,"y":-479,"angle":-6.796875},{"x":-92,"y":-477,"angle":-6.828125},{"x":-92,"y":-474,"angle":-6.859375},{"x":-92,"y":-472,"angle":-6.87
@binary-person
binary-person / format-milliseconds.js
Created March 6, 2021 17:50
format milliseconds to 'n days n hours n minutes n seconds' with correct punctuation
function formatMS(tempTime) {
var milliseconds = tempTime % 1000;
tempTime = Math.floor(tempTime / 1000);
var seconds = tempTime % 60;
tempTime = Math.floor(tempTime / 60);
var minutes = tempTime % 60;
tempTime = Math.floor(tempTime / 60);
var hours = tempTime % 24;
tempTime = Math.floor(tempTime / 24);
var days = tempTime;
@binary-person
binary-person / runFull
Last active October 10, 2019 20:21
Install wstun, anyproxy, and essentials for aws vm
#!/bin/bash
#AWS User Data: sudo -H -u ubuntu bash -c 'curl -o- https://gist.githubusercontent.com/scheng123/06c2123650bbd2872ab9c253557a0dc1/raw/runFull | bash'
#EXECUTE COMMAND: curl -o- https://gist.githubusercontent.com/scheng123/06c2123650bbd2872ab9c253557a0dc1/raw/runFull | bash
touch ~/.bashrc
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 10.16.3
npm install -g anyproxy MDSLab/wstun
sudo bash -c "printf \"@reboot tmux new-session -d -s pRunner 'sudo /home/ubuntu/.nvm/versions/node/v10.16.3/bin/node /home/ubuntu/.nvm/versions/node/v10.16.3/bin/anyproxy -p 1935 -w 9999'\\n@reboot tmux new-session -d -s sshSecondStage 'sudo /home/ubuntu/.nvm/versions/node/v10.16.3/bin/node /home/ubuntu/.nvm/versions/node/v10.16.3/bin/wstun -s 443'\\n@reboot tmux new-session -d -s portFowrd 'sudo /home/ubuntu/.nvm/versions/node/v10.16.3/bin/node /home/ubuntu/.nvm/versions/node/v10.16.3/bin/wstun -r -s 8443'\" > /var/spool/cron/crontabs/ubuntu"
sudo chmod go=,+r
@binary-person
binary-person / run
Last active October 8, 2019 22:28
Install AnyProxy with NVM and execute it with crontab too on bootup
#!/bin/bash
#AWS User Data: sudo -H -u ubuntu bash -c 'curl -o- https://gist.githubusercontent.com/scheng123/7985bbac79c0dc34c2c3a8f044ac066f/raw/run | bash'
#EXECUTE COMMAND: curl -o- https://gist.githubusercontent.com/scheng123/7985bbac79c0dc34c2c3a8f044ac066f/raw/run | bash
touch ~/.bashrc
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install 10.16.3
npm install -g anyproxy
sudo bash -c "echo \"@reboot tmux new-session -d -s pRunner 'sudo /home/ubuntu/.nvm/versions/node/v10.16.3/bin/node /home/ubuntu/.nvm/versions/node/v10.16.3/lib/node_modules/anyproxy/bin/anyproxy -p 8080 -w 80'\" > /var/spool/cron/crontabs/ubuntu"
sudo chmod go=,+rw /var/spool/cron/crontabs/ubuntu
@binary-person
binary-person / articleTemplate.html
Last active July 8, 2019 23:13
Text is just random text. Aim is to create article that would be recognized by pocket
<html>
<head>
<title>Adventures of Simon Cheng</title>
</head>
<body>
<h1>My Life Story</h1><article>
<p>We diminution preference thoroughly if. Joy deal pain view much her time. Led young gay would now state. Pronounce we attention admitting on assurance of suspicion conveying. That his west quit had met till. Of advantage he attending household at do perceived. Middleton in objection discovery as agreeable. Edward thrown dining so he my around to.
Building mr concerns servants in he outlived am breeding.
</p>
@binary-person
binary-person / config.lua
Last active April 19, 2019 17:27
Modified for Google Colab
hdf5._config = {
HDF5_INCLUDE_PATH = "/content/torch/hdf5-1.8.12-linux-x86_64-shared/include",
HDF5_LIBRARIES = "/content/torch/hdf5-1.8.12-linux-x86_64-shared/lib/libhdf5.so;/usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/libz.so;/usr/lib/x86_64-linux-gnu/libdl.so;/usr/lib/x86_64-linux-gnu/libm.so"
}
@binary-person
binary-person / install-deps
Last active August 8, 2021 00:24
Torch Install for Google Colab
#!/usr/bin/env bash
set -e
######################################################################
# This script installs required dependencies for Torch7
######################################################################
{
install_openblas() {
# Get and build OpenBlas (Torch is much better with a decent Blas)
hello world