Skip to content

Instantly share code, notes, and snippets.

View Genzer's full-sized avatar

Genzer Hawker Genzer

View GitHub Profile
@Genzer
Genzer / back.sh
Created January 16, 2024 08:53
Quicker than typing cd ..
#!/usr/bin/env bash
#----------
# back
# Goes back to parent directory quicker.
#
# NUMBER - goes back to x levels by repeatedly calling `cd ..`.
# SUBPATH - a segment of a full path to go back.
#
# *KNOWN LIMITS*
@Genzer
Genzer / replacerJSONStringify.js
Last active October 23, 2023 06:44
Replace JSON.stringify to always remove property having value is null
function replacerJSONStringify() {
if (window.__JSON_stringify_replaced__ === true) {
return;
}
const _originalStringify = JSON.stringify;
// NOTE:
// ----
package com.grokhard.exploring.java.mapstruct;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValueCheckStrategy;
import org.mapstruct.NullValuePropertyMappingStrategy;
@Genzer
Genzer / new_ssh_key_pair.sh
Created February 1, 2023 14:04
Generate SSH Key Pair without prompt.
ssh-keygen -o -t ed25519 -f private-key-ed25519.pem -N '' -C "Some comment" <<<y 2>&1 >/dev/null
@Genzer
Genzer / storage_used_on_github.sh
Last active March 16, 2024 02:35
Calculate total storage of Git repositories on GitHub
#!/usr/bin/env bash
set -u -e -o pipefail
# INTRODUCTION
# ---
#
# This snippet it aggregrate the `size` of all repositories in an GitHub Orginazation
# to report the total used storage (approximately).
#
# PREREQUISITES
@Genzer
Genzer / unarchive_github_repository.sh
Last active October 26, 2022 09:15
Unarchive GitHub Repositories using CLI
#!/usr/bin/env bash
set -ueo pipefail
# INTRODUCTION
# ====
#
# This script was created as I wanted to unarchive multiple repositories in our company.
# Using the Web UI would take lots of time and I was lazy as hell. GitHub Rest API also
# did not support it.
# Luckily, I discovered an article [1] giving hint that GitHub GraphQL API did have a
@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