Skip to content

Instantly share code, notes, and snippets.

View katopz's full-sized avatar
🦀
Rust me if you can

Todsaporn Banjerdkit katopz

🦀
Rust me if you can
View GitHub Profile
@katopz
katopz / youtube-auto-confirm.js
Last active November 6, 2019 06:06
To prevent annoying Youtube confirmation dialog box
const isBlock = () => {
// Check for existing dialog
const dialog = Array.from(document.querySelectorAll('paper-dialog'))[0]
if (!dialog) return false
if (getComputedStyle(dialog).display === 'none') return false
console.log('BLOCKED!!!')
return true
}
@katopz
katopz / sha-256.js
Last active September 16, 2019 10:22
sha-256-js
// Web : ref https://jameshfisher.com/2017/10/30/web-cryptography-api-hello-world/
async function sha256(str) {
const buf = await crypto.subtle.digest("SHA-256", new TextEncoder("utf-8").encode(str));
return Array.prototype.map.call(new Uint8Array(buf), x=>(('00'+x.toString(16)).slice(-2))).join('');
}
// Node
async function sha256(str) {
const crypto = require('crypto')
const hash = crypto.createHash('sha256')
@katopz
katopz / gcp-proof-file.json
Created August 26, 2019 12:52
gcp-proof-file.json
{
"@context": "https://w3id.org/chainpoint/v3",
"type": "Chainpoint",
"hash": "a6815bf709974ac6d76b790692e5ef9c407e6372b1cc26cdf6ba44a617914ecf",
"hash_id_node": "839033f0-c459-11e9-a2a3-01f3e4c4d74b",
"hash_submitted_node_at": "2019-08-21T21:20:34Z",
"hash_id_core": "859e5370-c459-11e9-be73-01c3a358a4f5",
"hash_submitted_core_at": "2019-08-21T21:20:38Z",
"branches": [
{
did:muport:QmVaAKnibxg3NC5ug3on1f3x3oRTbLjYxutg2uftYby9c6
@katopz
katopz / do-swap.sh
Created June 19, 2019 06:03
Set Swap 4GB, Swappiness 10.
# Execute
run() {
# Set Swap 4GB, Swappiness 10.
# ref : https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
# Turn the swapfile off if has any.
sudo swapoff -a
# Check current disk usage.
df -h
@katopz
katopz / Install protobuf 3.8.0 on Ubuntu 18.04 x86_64
Last active July 27, 2022 08:17 — forked from ryujaehun/Install protobuf 3.6.1 on Ubuntu 16.04
Install protobuf 3.8.0 on Ubuntu 18.04 x86_64
#! /bin/bash
# Make sure you grab the latest version https://github.com/protocolbuffers/protobuf/releases/
curl -OL https://github.com/protocolbuffers/protobuf/releases/download/v3.8.0/protoc-3.8.0-linux-x86_64.zip
# Unzip
unzip protoc-3.8.0-linux-x86_64.zip -d protoc3
# Move protoc to /usr/local/bin/
sudo mv protoc3/bin/* /usr/local/bin/
@katopz
katopz / keybase.md
Created March 9, 2018 07:17
keybase.md

Keybase proof

I hereby claim:

  • I am katopz on github.
  • I am katopz (https://keybase.io/katopz) on keybase.
  • I have a public key ASDMiDleOjn0S67Y5UyrYRM-novFdPVcZPM4ueXPktrMYAo

To claim this, I am signing this object:

@katopz
katopz / setup-zeromq.sh
Last active August 10, 2021 21:47 — forked from cdjhlee/zeromq_install.sh
Setup zeromq in Ubuntu 16.04
#!/usr/bin/bash
# Download zeromq
# Ref http://zeromq.org/intro:get-the-software
wget https://github.com/zeromq/libzmq/releases/download/v4.2.2/zeromq-4.2.2.tar.gz
# Unpack tarball package
tar xvzf zeromq-4.2.2.tar.gz
# Install dependency
@katopz
katopz / ts-dl.sh
Created August 16, 2017 15:49
Download .ts video file by ffmpeg via .m3u8
# Install ffmpeg
brew install ffmpeg
# Download
ffmpeg -i https://foo.com/bar.m3u8 -c copy -bsf:a aac_adtstoasc output.mp4
@katopz
katopz / drop.sh
Last active July 2, 2017 14:13
To create DigitalOcean droplet
# Get name andcs image from arguments
NAME=$1
IMAGE=${2:-"ubuntu-16-04-x64"}
# Get droplet option
DO_OPTION=$(tr -d '\n' < ./droplets.json | tr -d ' ')
DO_OPTION=${DO_OPTION/'$NAME'/$NAME}
DO_OPTION=${DO_OPTION/'$IMAGE'/$IMAGE}
# Create droplet