Skip to content

Instantly share code, notes, and snippets.

View Veticus's full-sized avatar

Tim Veticus

  • Aarhus, Denmark
View GitHub Profile
@Veticus
Veticus / all_wav_to_320_mp3.fish
Created April 12, 2024 20:22
Fish one-liner: Convert all .wav files in directory to .mp3 at 320kbit/s
for wavfile in *.wav; ffmpeg -i $wavfile -b:a 320k (string replace -r '\.wav$' '.mp3' $wavfile); end
@Veticus
Veticus / cpr_mod11_check.py
Created March 4, 2024 08:37
Modulus 11 check, to validate CPR numbers
# Note that not all CPR numbers can be validated this way
# More info: https://cpr.dk/cpr-systemet/personnumre-uden-kontrolciffer-modulus-11-kontrol
def mod11check(cpr_to_check) -> bool:
sum2mod = 0
cpr_arr = [int(x) for x in str(cpr_to_check)]
for i in range(0, len(cpr_arr)):
sum2mod += cpr_arr[i] * [4, 3, 2, 7, 6, 5, 4, 3, 2, 1][i]
if sum2mod % 11 == 0:
return True
@Veticus
Veticus / memoisation_demo.py
Created September 11, 2023 16:28
Memoisation demo in python
# This is the memoization demo.
# First a wrapper is created, which can be used for each call of the fibonacci function.
# The wrapper will save (or cache) the result of each function call - index for a given set of arguments and keyword arguments.
from functools import wraps
from time import perf_counter
def memoize(func): # The memoisation needs to take a function, since it's a decorator.
cache = {}
@Veticus
Veticus / profile_this.py
Created August 7, 2023 09:47
speed diff in collection types is bonkers
def unique_sum_with_list(howMany):
sum = 0
seen_numbers = []
for n in range(howMany):
if n in seen_numbers:
continue
sum += n
seen_numbers.append(n)
print("list sum: " + str(sum))
return sum
@Veticus
Veticus / filename_cleaner.py
Created May 22, 2023 19:24
Makes filenames in a given path prettier.
# Traverses a given path and:
# 1: Converts filename from "spaces.are.dots" to "human readable", without breaking the filename/extension.
# 2: Strips extra stuff found in filename.
# NOTE: This assumes that all files in the path are the same extension.
from os import scandir, rename
extension = ".wav"
r1 = ".RECORDED.AT.AMAGER.BIO.AUGUST.2017"
r2 = ".FIRST.REHEARSAL.RECORDINGS"

SMD Resistor package markings

EIA-96 SMD Scheme

CODE MULTIPLIER
Z 0.001
Y or R 0.01
X or S 0.1
A 1

SMD Capacitor markings

Polarized caps

SMD/SMT package sizes (passives)

"Package" is the same as "Chip carrier" in this context.
term expanded examples
SMD Surface-mount devices Active and passive components
@Veticus
Veticus / publicDNSServers.md
Created October 5, 2021 05:34
My current list of public DNS servers. Used for various purposes.
Service IPv4 IPv6
Google Public DNS 8.8.8.8 2001:4860:4860::8888
Google Public DNS 8.8.4.4 2001:4860:4860::8844
Cloudflare 1.1.1.1 2606:4700:4700::1111
Cloudflare 1.0.0.1 2606:4700:4700::1001
Quad9 9.9.9.9 2620:fe::9
Quad9 149.112.112.112 2620:fe::fe
OpenDNS 208.67.222.222 2620:119:35::35
OpenDNS 208.67.220.220 2620:119:53::53
@Veticus
Veticus / show_starting_digit_distribution_from_PFRAND.py
Last active September 10, 2023 13:31
distribution of numbers by first digit, from 1.6 milion randomly generated numbers
import numpy as np
import matplotlib.pyplot as plt
dist_nums = [834109, 193930, 83203, 83448, 83712, 83123, 83335, 83304, 83044]
rangenums = [i for i in range(1, 10)]
dist_vals = list(zip(rangenums, dist_nums))
labels, values = zip(*dist_vals)
indexes = np.arange(len(labels))
width = 1