Skip to content

Instantly share code, notes, and snippets.

View Genzer's full-sized avatar
⭕

Genzer Hawker Genzer

⭕
View GitHub Profile
@Genzer
Genzer / presigned.py
Last active June 11, 2025 07:58
Generate a S3 PreSigned URL for uploading files
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "boto3",
# ]
# ///
import argparse
import boto3
@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 September 9, 2026 23:48
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