Skip to content

Instantly share code, notes, and snippets.

View Genzer's full-sized avatar

Genzer Hawker Genzer

View GitHub Profile
package com.grokhard.explorejavaconcurrency;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.Objects;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
#!/usr/bin/env bash
set -e -u -o pipefail
# Send, in sequential order, 10 requests and prints only the HTTP Status Code and the total time of the request
# with a Connnection Time Out in 5 seconds.
URL="$1"
{
for _ in {1..10};
do
@Genzer
Genzer / unarchive_github_repo.sh
Created June 12, 2024 07:27
Unarchive a GitHub repository using CLI
#!/usr/bin/env bash
set -ueo pipefail
get_repo_id() {
local -r org="$1"
local -r repo_name="$2"
cat <<_PAYLOAD_ \
| curl \
--silent \
--fail \
@Genzer
Genzer / fetch_tables_indices_size_in_database.sql
Last active March 5, 2024 05:00
Fetch Sizes of Tables and Indices in a Database
-- Source: https://stackoverflow.com/a/21738732/495558
-- NOTE: This script is adjusted from the original:
-- - Added Indices' size.
-- - Limited only those whose size exceeding 100MiB.
select
schema_name,
relname,
pg_size_pretty(table_size) as size,
@Genzer
Genzer / deploy.sh
Last active February 15, 2024 11:26
Temporary deploy an unofficial fix of feign-reactive to CodeArtifact
#!/usr/bin/env bash
set -u -e -o pipefail
git clone https://github.com/ramzes3333/feign-reactive
# Change version to 4.0.4.UNOFFICIAL
find feign-reactive -type f -name 'pom.xml' \
-exec \
@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