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 / move_files.rs
Created October 13, 2024 10:25
A simple implementation to rename files when on the same device or move them by copy and delete if not.
use std::{fs, io, path::Path};
pub fn move_recursively(from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<(), io::Error> {
if !to.as_ref().exists() {
fs::create_dir_all(to.as_ref())?;
}
let from_meta = from.as_ref().metadata()?;
let to_meta = to.as_ref().metadata()?;
@zekroTJA
zekroTJA / curseforge-download-mod.sh
Created May 24, 2024 17:02
Downlaod a via ID and version from curseforge via the API.
#!/bin/bash
mod_id="$1"
version="$2"
get_file_id() {
local loader="$1"
local version="$2"
curl -Ls "https://www.curseforge.com/api/v1/mods/${mod_id}/files?pageIndex=0&pageSize=20&sort=dateCreated&sortDescending=true&removeAlphas=true" \
@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="[email protected]:<REPO>"
BRANCH="main"
TMP_DIR="/tmp/vault_backup"
export GIT_AUTHOR_NAME="vault_backup"
export GIT_AUTHOR_EMAIL="[email protected]"
@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.