Skip to content

Instantly share code, notes, and snippets.

View heri16's full-sized avatar

Heri Sim heri16

View GitHub Profile
heri16 /
Last active May 24, 2024 15:28
Secure Number Masking for Postgres (Scrambling DB Primary Keys or sensitive data using NIST FF1 Format Preserving Encryption)


This is open-source code that lets you secure or mask numbers (within Postgresql DB) for use as unique IDs that are 6-digits or more.

This is what they look like:
heri16 /
Last active April 26, 2024 09:08
Secure Short Unique IDs (for generating Invites Codes or Promo Codes or URL slug from Postgres Database)


This is open-source code that lets you generate short unique identifiers from numbers (within Postgres DB). These IDs are URL-safe, can encode several numbers, and do not contain common profanity words.

This is what they look like:
heri16 /
Created April 1, 2024 10:52

Captive Portal Detection



heri16 /
Created February 7, 2024 14:13
Fdroid Quick Repository
#!/usr/bin/env zsh
curl -o && unzip && rm
# Measure Bandwidth (using
#wget -O /tmp/speedtest.tgz
wget -O /tmp/speedtest.tgz
tar -xzvf /tmp/speedtest.tgz -C /usr/sbin/
rm -f /tmp/speedtest.tgz /usr/sbin/speedtest.*
chmod +x /usr/sbin/speedtest
/etc/init.d/qosify stop
speedtest --format=tsv > /tmp/speedtest.tsv &&
BANDWIDTH_DOWN="$(($(cut -f6 /tmp/speedtest.tsv) / 125000))mbit" &&
heri16 /
Created July 27, 2023 19:45
Erlang for bun:ffi
# Install asdf
brew install coreutils git
git clone ~/.asdf --branch v0.12.0
cat <<EOF >> ~/.zshrc
. "$HOME/.asdf/"
# append completions to fpath
fpath=(${ASDF_DIR}/completions $fpath)
# initialise completions with ZSH's compinit
autoload -Uz compinit && compinit
heri16 / Dockerfile
Last active April 6, 2023 08:53
Automate login to keybase using Expect TCL
FROM keybaseio/client:stable-slim
RUN apt-get update && apt-get install -y expect
RUN chmod +x /
CMD ["/", "keybase", "chat", "send", "--channel", "'#general'", "stockbitcrypto", "'Hello World from bot'"]
package main
import (
heri16 /
Last active October 19, 2021 10:56
Binary encoding of OUCH messages in Elixir

Reuse logic in Elixir

Here are commons ways to reuse logic in Elixir:

1a. Move Function to other module (guards, pattern-matching) 1b. Protocol - Polymorphism

  1. Behaviour Dynamic-func - with def method_name(implemetation, args)
heri16 / flatten_array.ex
Created August 26, 2021 16:19
Elixir Flatten array (with tail recursion)
defmodule FlattenArray do
@doc """
Accept a list and return the list flattened without nil values.
## Examples
iex> FlattenArray.flatten([1, [2], 3, nil])
iex> FlattenArray.flatten([nil, nil])