Skip to content

Instantly share code, notes, and snippets.

View Genzer's full-sized avatar

Genzer Hawker Genzer

View GitHub Profile
@Genzer
Genzer / migrate_git_to_git_lfs.sh
Created October 29, 2020 03:29
Migrate Git to Git LFS
#!/usr/bin/env bash
# Overview
# ----
# The following script is used for migrate a Git repository containing lots of binary file
# to use Git LFS.
#
# This script incorporates all steps described in the article "Convert Git to Git LFS" [1].
#
# Prerequisites:
@Genzer
Genzer / new_ssh_keys.sh
Created November 30, 2020 03:16
Generate a new SSH key pair in one line
#!/usr/bin/env bash
set -e
# Heavily copied from https://stackoverflow.com/questions/43235179/how-to-execute-ssh-keygen-without-prompt.
# Generate a SSH key using Ed25519 (instead of RSA) without a passphrase.
# The command will run silently.
ssh-keygen -o -t ed25519 -f /tmp/test.pem -N '' <<<y 2>&1 >/dev/null
@Genzer
Genzer / about.md
Created December 4, 2020 04:32
About Genzer
@Genzer
Genzer / TestCheckSumLargeRandomInpustStream.java
Last active July 12, 2023 05:06
Testing generating MD5/SHA256 checksum with arbitrary size InputStream
//usr/bin/env jshell
import java.io.InputStream;
import java.io.OutputStream;
import java.security.MessageDigest;
import java.security.DigestInputStream;
/**
* A super elegant way to produce a `InputStream` at any size using an iterating
* approach (Stream-like).
* This was copied from https://www.nurkiewicz.com/2014/07/building-extremely-large-in-memory.html
@Genzer
Genzer / random-bytes-stream.js
Created May 11, 2021 16:33
Create random bytes stream and buffer in Node.js
const util = require('util');
const stream = require('stream');
const pipeline = util.promisify(stream.pipeline);
const Readable = stream.Readable;
const PassThrough = stream.PassThrough;
const {randomBytes} = require('crypto');
// const RandomStream = function(options) {
// const {
// sizeInBytes,
#!/usr/bin/env bash
set -ueo pipefail
#
# This script is for converting .DAV video file created by CCTV camera [1] to .MP4.
#
# The script was used by me personally for converting the recorded video by an Android
# app gDMSS Lite to MP4. Tested mainly on MacOS Catalina.
#
@Genzer
Genzer / on_note_taking.md
Last active May 19, 2021 11:48
On note-taking
@Genzer
Genzer / convert_checksum_base64_and_hex.md
Created June 4, 2021 08:20
Checksum values between HEX and base64

Convert checksum between Hex and Base64 using CLI

From Hex to Base64

$> echo "da3968197e7bf67aa45a77515b52ba2710c5fc34" | xxd -r -p | base64
2jloGX579nqkWndRW1K6JxDF/DQ=

From Base64 to Hex

@Genzer
Genzer / docker_hub_rate_limit_check.sh
Created July 8, 2021 08:00
Check Docker Hub current Rate Limit
#!/usr/bin/env bash
docker_hub_rate_limit_check() {
# This function is implemented following instructions in Docker's guide.
# Usage is simple:
# - Run the function to verify the Rate Limit of your current IP (anonymous).
# - Passing with "username:password" to verify Rate Limit of your Docker Hub
# account.
#
@Genzer
Genzer / back.sh
Created October 7, 2021 07:51
go_back_parent_directories_quicker.sh
#!/usr/bin/env bash
# Do `cd ..` by x times.
# function back() { for x in {1..${1:-1}}; do cd ..; done }
#
back() {
local target="${1:-1}"
local full_path="$(pwd)"
# The script supports