Skip to content

Instantly share code, notes, and snippets.

View Genzer's full-sized avatar
⭕

Genzer Hawker Genzer

⭕
View GitHub Profile
@Genzer
Genzer / ThreadLocalChallenge.java
Last active October 5, 2022 02:38
ThreadLocal Learning Challenge
package com.grokhard.java.explore.threadlocals;
/**
* ThreadLocal Challenge
* ====
*
* This is a small challenge to test your understanding of Java's `Thread`
* and `ThreadLocal`.
*
* In order to pass the test, implement so that `Thread`s executing `taskChildren`
@Genzer
Genzer / fj.sh
Created December 30, 2021 09:31
Using Google Java Format in the shell
#!/usr/bin/env bash
# ==========================================
# = fj - Google Java Format in the shell =
# ==========================================
#
# This is a simple wrapper for Google Java Format CLI [1] (jar)
# so that it could be used easily in shell.
#
# This is created specifically for my own environment:
@Genzer
Genzer / README.md
Last active January 11, 2022 11:42
Use Retype (https://retype.com/) in Docker

Retypeapp Docker Image (unofficial)

This Docker image is built for my own purposes and is not an official made by Retype.

Overview

Since Retype is an executable binary built by .NET, the base image debian:bullseye-20211201-slim is enough. The binary is downloaded and put in /usr/local/bin/retype thus making it available in $PATH.

Usage Examples

@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
@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 / 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 / on_note_taking.md
Last active May 19, 2021 11:48
On note-taking
#!/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 / 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,
@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