Skip to content

Instantly share code, notes, and snippets.

View heri16's full-sized avatar

heri16 heri16

View GitHub Profile
@heri16
heri16 / ciphers.sh
Created February 5, 2025 11:19
Cloudflare Hardening Scripts to get great scores on https://www.ssllabs.com/ssltest/
#!/bin/sh
CF_API_TOKEN="redacted"
# check api token is valid
curl -X GET "https://api.cloudflare.com/client/v4/accounts/8bb6305b489fc12377ff03ffbcbadbc6/tokens/verify" \
-H "Authorization: Bearer $CF_API_TOKEN" \
-H "Content-Type:application/json"
# reset to defaults (includes weak ciphers)
curl --request PATCH \
@heri16
heri16 / 0-README.md
Last active April 19, 2025 08:54
Secure Number Masking for Postgres (Scrambling DB Primary Keys or sensitive data using NIST FF1 Format Preserving Encryption)

What

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:

https://example.com/order/053124
@heri16
heri16 / 0-README.md
Last active April 19, 2025 09:45
Secure Short Unique IDs (for generating Invites Codes or Promo Codes or URL slug from Postgres Database)

What

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:

https://example.com/order/FHxkSB1ai
@heri16
heri16 / CAPTIVE-PORTAL.md
Created April 1, 2024 10:52
CAPTIVE PORTAL DETECTION Domains and URLs

Captive Portal Detection

Browsers:

captive.apple.com, www.apple.com, clients3.google.com, clients4.google.com, connectivitycheck.gstatic.com, www.gstatic.com, edge-http.microsoft.com, msftconnecttest.com, detectportal.brave-http-only.com, detectportal.firefox.com, spectrum.s3.amazonaws.com

See: https://captivebehavior.wballiance.com/

@heri16
heri16 / 1-android-sdk.sh
Created February 7, 2024 14:13
Fdroid Quick Repository
#!/usr/bin/env zsh
curl -o commandlinetools-linux.zip https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip && unzip commandlinetools-linux.zip && rm commandlinetools-linux.zip
# Measure Bandwidth (using https://www.speedtest.net/apps/cli)
#wget https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-x86_64.tgz -O /tmp/speedtest.tgz
wget https://install.speedtest.net/app/cli/ookla-speedtest-1.2.0-linux-aarch64.tgz -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
heri16 / erlang-macos.sh
Created July 27, 2023 19:45
Erlang for bun:ffi
# Install asdf
brew install coreutils git
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.12.0
cat <<EOF >> ~/.zshrc
. "$HOME/.asdf/asdf.sh"
# append completions to fpath
fpath=(${ASDF_DIR}/completions $fpath)
# initialise completions with ZSH's compinit
autoload -Uz compinit && compinit
EOF
@heri16
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
COPY keybase-provision.sh /provision.sh
RUN chmod +x /provision.sh
CMD ["/provision.sh", "keybase", "chat", "send", "--channel", "'#general'", "stockbitcrypto", "'Hello World from bot'"]
package main
import (
"fmt"
"net/http"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
@heri16
heri16 / README.md
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)