Skip to content

Instantly share code, notes, and snippets.

@MrPandir
MrPandir / measure.nu
Created April 15, 2025 13:50
Nushell performance measurement utility
# Measures the average execution time of a specified function over a given number of iterations
export def main [
func: closure # The function (closure) to be executed
iterations: int = 10000 # Number of iterations to run the function
] {
let start_time = date now
1..($iterations) | each { |_| do $func } | ignore
let end_time = date now
@MrPandir
MrPandir / read_env_file.py
Last active April 13, 2025 21:02
Lightweight Python .env file reader and environment variable loader
from pathlib import Path
def get_env_data_as_dict(path: Path | str) -> dict[str, str]:
with open(path, "r") as f:
return dict(
list(map(str.strip, line.replace("\n", "").split("=")))
for line in f.readlines()
if not line.startswith("#")
)
@MrPandir
MrPandir / chat-to-input.js
Last active March 21, 2025 14:19
Inserts single words from Twitch chat into specified websites
// ==UserScript==
// @name Twitch Chat Answer Inserter
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Inserts single words from Twitch chat into specified websites
// @author MrPandir
// @match https://slovo.win/*
// @updateURL https://gist.githubusercontent.com/MrPandir/f3d2b2c3c2fca98ac0fd4052288c2917/raw/chat-to-input.js
// @downloadURL https://gist.githubusercontent.com/MrPandir/f3d2b2c3c2fca98ac0fd4052288c2917/raw/chat-to-input.js
// @grant none
@MrPandir
MrPandir / carapace.nu
Last active March 30, 2025 16:46
My rewritten carapace configuration file for nushell.
use std "path add"
def cache [] {
let func = $in
let version = version | get version
let path = $nu.temp-path | path join "carapace-cache" $version
try {
open $path