Skip to content

Instantly share code, notes, and snippets.

View zekroTJA's full-sized avatar
🚀
Fuck it, ship it!

Ringo Hoffmann zekroTJA

🚀
Fuck it, ship it!
View GitHub Profile
@zekroTJA
zekroTJA / cache.rs
Created December 12, 2023 12:58
Simple Cache with hit and miss counter in Rust.
use core::hash::Hash;
use std::collections::HashMap;
pub struct Cache<K, V> {
m: HashMap<K, V>,
hits: usize,
misses: usize,
}
impl<K, V> Cache<K, V> {
@zekroTJA
zekroTJA / go.mod
Created June 17, 2023 07:09
A simple exporter accumulating Redis Keys and exposing a Prometheus metrics exporter endpoint.
module exporter
go 1.20
require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/joho/godotenv v1.5.1
github.com/kelseyhightower/envconfig v1.4.0 // indirect
@zekroTJA
zekroTJA / goup.sh
Created April 5, 2023 06:50
A super simple script to update and backport your local Go installation.
#!/bin/bash
function error {
echo "❌ Error: $1"
exit 1
}
[ "$1" == "-h" ] || [ "$1" == "--help" ] && {
echo "Usage: $0 (version)"
echo ""
@zekroTJA
zekroTJA / vaulwarden-backup.sh
Created March 26, 2023 11:28
VaultWarden backup script
#!/bin/bash
DATA_DIR="<BITWARDEN DATA PATH>"
REPO_URL="git@github.com:<REPO>"
BRANCH="main"
TMP_DIR="/tmp/vault_backup"
export GIT_AUTHOR_NAME="vault_backup"
export GIT_AUTHOR_EMAIL="vault_backup@example.com"
@zekroTJA
zekroTJA / bench.sh
Last active November 17, 2022 08:40
Simple benchmark to compare compile times between Rust and Go
#!/bin/bash
# Example Results: https://docs.google.com/spreadsheets/d/1wYMqYTVqrG2nG9ZcBTJFxFwT4VC2Fg5GmGEhmQoP8Ns/edit?usp=sharing
GO_CODE="package main
import \"fmt\"
func main() {
fmt.Println(\"Hello world!\")
}"
@zekroTJA
zekroTJA / country_date_formats.csv
Created October 17, 2022 09:43 — forked from mlconnor/country_date_formats.csv
Listing of countries with their preferred date formats, ISO3166 code, ISO629-2
ISO 3166 Country Code ISO639-2 Country Code Country ISO 3166 Country Code ISO639-2 Lang Language Date Format
ALB AL Albania sqi sq Albanian yyyy-MM-dd
ARE AE United Arab Emirates ara ar Arabic dd/MM/yyyy
ARG AR Argentina spa es Spanish dd/MM/yyyy
AUS AU Australia eng en English d/MM/yyyy
AUT AT Austria deu de German dd.MM.yyyy
BEL BE Belgium fra fr French d/MM/yyyy
BEL BE Belgium nld nl Dutch d/MM/yyyy
BGR BG Bulgaria bul bg Bulgarian yyyy-M-d
BHR BH Bahrain ara ar Arabic dd/MM/yyyy
@zekroTJA
zekroTJA / golang-download-latest.sh
Created June 24, 2022 09:29
Download the latest version of Golang
#!/bin/sh
VERSION=$(curl -sL https://go.dev/VERSION?m=text)
curl -L "https://dl.google.com/go/${VERSION}.linux-amd64.tar.gz" | tar -C /usr/local -xzvf -
@zekroTJA
zekroTJA / encrypt.md
Last active March 2, 2022 10:32
My GPG Public Key

If you want to send me something encrypted with my public key, just follow the steps below.

curl -o zekro-pub.gpg https://gist.githubusercontent.com/zekroTJA/fdfbf810ec0dcc73e8252e7e9fe55615/raw/68456b64f44997445abca5a893c314e93b635172/pub.gpg
gpg --import zekro-pub.gpg
gpg -er 916D525B760FEEC7951D79C27EE525875D532A17 secret.txt

This downloads the GPG public key do your current directory as zekro-pub.gpg. After that, it imports the key to your GPG keystore. Eventually, it encrypts the given file - in this case secret.txt - and stores it as secret.txt.gpg.

#!/bin/bash
set -x
set -e
apt install -y software-properties-common
wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add -
sudo add-apt-repository 'deb https://apt.corretto.aws stable main'
apt update -y
apt install -y java-16-amazon-corretto-jdk
@zekroTJA
zekroTJA / dgrs-oldest-user.py
Last active October 12, 2021 03:34
Get the oldest user account from a dgrs cache.
import redis
import argparse
import json
import datetime
def inject_creation_date(u):
uid = int(u.get('id'))
ts = (uid >> 22) + 1420070400000
u['created_date'] = datetime.datetime.fromtimestamp(