Skip to content

Instantly share code, notes, and snippets.

View Genzer's full-sized avatar

Genzer Hawker Genzer

View GitHub Profile
@Genzer
Genzer / no_body_leaves.slack-workflow.json
Created May 30, 2025 07:01
A simple Slack Workflow that adds member who leaves again.
{
"workflow": {
"title": "No Body Leaves",
"description": "Invite who ever leaves the channel again",
"icon": "",
"input_parameters": {
"Ft08U92KCRPH__user_id": {
"type": "slack#/types/user_id",
"name": "Ft08U92KCRPH__user_id",
"description": "The user who left the channel",
@Genzer
Genzer / README.md
Last active January 13, 2025 10:04

Mitigate "Rate Limiting bypass" through AWS ALB if the application relies on X-Forwarded-For

This gist documents a tactic which works in a situation:

  • Your Software System runs behind an AWS Application Load Balancer (ALB)
  • Your Software System uses AWS WAF in conjunction with ALB.
  • Your Software System handles Rate Limiting by itself.
  • Your Software System Rate Limiting implementation make use of X-Forwarded-For header to determine the correct Client Source IPO.
@Genzer
Genzer / UuidShortener.java
Last active May 18, 2025 11:47
Shorten an UUIDv4 by encoding in Base64
import java.util.UUID;
import java.util.Base64;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
public class UuidShortener {
/* NOTE:
* The implementation was mostly copied from StackOverflow [1],
* as well as the hint of using BIG_ENDIAN [2].
@Genzer
Genzer / Loops.java
Last active November 29, 2024 08:53
Microbenchmarking using JBang and JMH
//DEPS org.openjdk.jmh:jmh-generator-annprocess:1.36
// --javaagent=ap-loader@maxandersen=start,event=cpu,file=profile.html
package com.grokhard.benchmarking;
import org.openjdk.jmh.*;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.stream.*;
import java.util.*;
@Genzer
Genzer / DnsResolver.java
Last active November 29, 2024 08:50
DnsResolver.java
import java.util.*;
import java.util.stream.*;
import javax.naming.Context;
import javax.naming.NameNotFoundException;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.DirContext;
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 \