Skip to content

Instantly share code, notes, and snippets.

@kaubu
kaubu / extract_dir.sh
Created September 27, 2023 17:16
Extract all zip files (made by 7zip) inside of a directory, in parallel
#!/bin/sh
ls *.zip | parallel -j+0 --eta '7z x {} >/dev/null'
# 9(1)+4(2)+3(3)+2(4)+1(5)+1(6)+1(7)+1(8)+1(9)=
import math
slots: int = int(input("Slots: "))
spells = 0
for i in range(1, slots + 1):
# print(i)
new_spells = math.floor(slots / i)
@kaubu
kaubu / config.nu
Created November 18, 2023 02:00
NuShell config
# Aliases
alias ll = ls -l
alias la = ls -a
alias lla = ls -la
alias gs = git status
alias ga = git add .
alias gc = git commit
alias gcu = git commit -m 'Update'
alias gac = git add .; git commit
@kaubu
kaubu / env.nu
Created November 18, 2023 02:02
Nu environment
# Enforce Git timezone is UTC
$env.TZ = "UTC"
# Set default editor of Nushell
$env.EDITOR = "vim"
@kaubu
kaubu / romance.txt
Last active December 25, 2023 04:07
French and Latin Highlight list
Anglo-French
Anglo-Latin
Anglo-Norman
Norman
French
Old French
Middle French
Latin
Medieval Latin
Vulgar Latin
@kaubu
kaubu / english.txt
Created December 25, 2023 00:07
English Highlight List
Old English
Proto-Germanic
Proto-West Germanic
@kaubu
kaubu / foreign.txt
Last active December 25, 2023 13:30
Misc Foreign Highlight
obscure origin
unknown origin
uncertain origin
unclear origin
unknown etymology
unknown etymologies
borrowed
Old Norse
Norse
Icelandic
@kaubu
kaubu / toggle_scroll_lock_linux.sh
Created June 24, 2024 03:44
Toggle keyboard leds on Arch and Arch derivatives that require pressing the scroll lock button
# Get list of devices
ls /sys/class/leds/
# Find all that have "inputX::scrolllock" where X is an integer, and try the following command with all of them
# The one that worked for me was 6
# Toggle keyboard scroll lock leds on
sudo sh -c 'echo 1 > /sys/class/leds/input6::scrolllock/brightness'
# Toggle keyboard scroll lock leds off

Poetry for dependencies

poetry add <package> to add the package

poetry build

Dependencies: poetry add pylint mypy black isort

@kaubu
kaubu / assignable_ip.py
Created October 15, 2024 07:39
Given a prefix notation, calculate the possible number of IP addresses in a subnet
def calc_assignable(prefix):
import math
print(f"{int(math.pow(2, 32 - prefix) - 2):,}")