Skip to content

Instantly share code, notes, and snippets.

View tobychui's full-sized avatar
🔥
Deadline fighting my Master thesis

Toby Chui tobychui

🔥
Deadline fighting my Master thesis
View GitHub Profile
@tobychui
tobychui / textfile_loader.js
Created March 5, 2023 09:18
Vanilla Javascript (JS) implementation of a file selection dialog that open and read local text files
let input = document.createElement('input');
input.type = 'file';
input.multiple = true;
input.onchange = e => {
let files = e.target.files;
for (var i = 0; i < files.length; i++){
let read = new FileReader();
read.readAsBinaryString(files[i]);
read.onloadend = function(){
//Content of the file selected
@tobychui
tobychui / batchconv.sh
Created August 4, 2022 13:04
Convert all mkv files in this folder into mp4 using ffmpeg
#/bin/bash
mkdir "./h264"
for i in *.mkv; do ffmpeg -i "$i" "./h264/${i%.*}.mp4"; done
@tobychui
tobychui / install-go.sh
Created August 5, 2021 05:16
Go installer script for Linux ARM SBC
#/bin/bash
echo "Input the go arch to install (arm/arm64/amd64)"
read -p "Architecture: " arch
if [ "$arch" = "arm" ]; then
echo "Installing arm version of go"
wget https://golang.org/dl/go1.15.3.linux-armv6l.tar.gz
fi
if [ "$arch" = "arm64" ]; then
echo "Installing arm64 version of go"
@tobychui
tobychui / gzipmiddleware.go
Created February 17, 2021 02:59
Golang gzip middleware module
package gzipmiddleware
import (
"compress/gzip"
"io"
"io/ioutil"
"net/http"
"strings"
"sync"
)