Skip to content

Instantly share code, notes, and snippets.

View cptpiepmatz's full-sized avatar

Piepmatz cptpiepmatz

View GitHub Profile
@cptpiepmatz
cptpiepmatz / $encrypt-static-toml-experiment.md
Last active January 17, 2025 17:30
encryt static toml data experiment

Secure Secrets Example

This example demonstrates how to securely handle sensitive (see Security Note) data, such as API keys and passwords, in a Rust application. The setup ensures that sensitive strings are not included in the binary in plaintext and uses encryption to protect secrets during the build process.

How It Works

  1. Encryption during Build: The build.rs script encrypts the secrets.toml file using a predefined key (key) and saves the result as secrets.toml.encrypted.
  2. Decryption at Runtime: The main program decrypts the secrets.toml.encrypted file at runtime, parses the TOML content, and verifies the data structure.
  3. Static Parsing: The static_toml crate provides compile-time validation of the TOML structure. In this experiment, since the same TOML file (though encrypted) is used to build the data structure, deserialization after decryption should not fail unless there is an unexpected issue.
@cptpiepmatz
cptpiepmatz / BrokenCustomValuePlugin.rs
Created August 31, 2024 20:36
Minimal nushell plugin that creates broken custom values by using enums.
use nu_plugin::{
serve_plugin, EngineInterface, EvaluatedCall, MsgPackSerializer, Plugin, PluginCommand,
SimplePluginCommand,
};
use nu_protocol::{CustomValue, IntoValue, LabeledError, ShellError, Signature, Span, Type, Value};
use serde::{Deserialize, Serialize};
fn main() {
serve_plugin(&BrokenValuePlugin, MsgPackSerializer)
}
@cptpiepmatz
cptpiepmatz / global-npm.Dockerfile
Created July 25, 2024 11:30
Dockerfile for globally installing NPM packages. Specify the desired packages via the `PACKAGES` argument to easily set up your environment with Docker Compose.
ARG NODE_VERSION=latest
FROM node:${NODE_VERSION}
ARG PACKAGES
RUN npm install -g ${PACKAGES}
@cptpiepmatz
cptpiepmatz / Left-Hand-Palworld.ahk
Created February 3, 2024 23:04
I like to play with my mouse in the left hand. This AutoHotkey script maps some inputs which are comfortable for me to keys used by Palword.
#SingleInstance Force
#HotIf WinActive("Pal")
; Clone Right Modifier to Left Ones
RCtrl::LCtrl
RShift::LShift
; Remap Numpad Numbers (0-9) to Their Top-Row Counterparts
Numpad0::0
Numpad1::1
@cptpiepmatz
cptpiepmatz / _config.nu
Last active August 4, 2024 19:53
Nushell + Starship Config
# Append to config.nu
# Config Updates
$env.config.buffer_editor = "micro"
# Aliases
alias clip = clip.exe
# Starship
source ~/.cache/starship/init.nu
@cptpiepmatz
cptpiepmatz / backup-mhr.nu
Created September 12, 2023 08:53
Backup Monster Hunter Rise Steam Save Games
#!/usr/bin/env nu
# Constants
const STEAM_DIR = 'steam/dir'
const USER_ID = 'userid'
const TARGET_DIR = 'target/dir'
# Function to get the current date
def get-date [] {
date now | format date '%Y-%m-%d'
// ==UserScript==
// @name Nexus Mods - right/left arrow pagination
// @match https://www.nexusmods.com/*
// @grant none
// @version 1.0
// @author Tim 'Piepmatz' Hesse
// @description Add event listeners to the right and left buttons for the pagination to allow to page with the arrow keys
// ==/UserScript==
const ARROW_KEYS = {
@cptpiepmatz
cptpiepmatz / emojis.json
Last active March 24, 2025 19:34
A comprehensive list of names for emojis. This data is extracted from the Discord desktop client.
{
"emojis": {
"100": "💯",
"1234": "🔢",
">:(": "😠",
">:-(": "😠",
">=(": "😠",
">=-(": "😠",
":\")": "😊",
":-\")": "😊",
@cptpiepmatz
cptpiepmatz / getFreePort.ts
Last active February 7, 2022 10:56
Get free port via Node without packages/dependencies
import {createServer, AddressInfo} from "net";
/**
* Utility function to return a free port.
*
* Uses dummy server that listens to port 0 to let the OS assign the server a
* port.
* Then the server will be closed and the now open port will be returned.
*
* @return by OS assigned, free port
@cptpiepmatz
cptpiepmatz / prompt.ps1
Last active December 24, 2022 00:48
My personal Prompt Style for Powershell
$ESC = [char]27
switch ($env:ComputerName) {
"TIMSYOGA" {$computerName = "TY"}
"TIMSTOWER" {$computerName = "TT"}
default {$computerName = $env:ComputerName}
}
function ExitCode {
if (-not($?)) {