Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar

Cees Timmerman CTimmerman

View GitHub Profile
@CTimmerman
CTimmerman / FixRealtekPoppingSound.ps1
Created January 16, 2024 19:16 — forked from supermarsx/FixRealtekPoppingSound.ps1
Fix popping sound on some Realtek sound cards, realtek audio crackling patch
# Enable Realtek driver power management, this is the default value
REG ADD "HKCU\Software\Realtek\RAVCpl64\PowerMgnt" /v "Enabled" /t REG_DWORD /d 1 /f
# Disable Realtek driver power management, sometimes fixes realtek popping sound
REG ADD "HKCU\Software\Realtek\RAVCpl64\PowerMgnt" /v "Enabled" /t REG_DWORD /d 0 /f
# Replace XXXX with the corresponding key that has "Realtek" in the "DriverDesc", find using regedit
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e96c-e325-11ce-bfc1-08002be10318}\XXXX\PowerSettings" /v "IdlePowerState" /t REG_BINARY /d "ffffffff" /f
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e96c-e325-11ce-bfc1-08002be10318}\XXXX\PowerSettings" /v "PerformanceIdleTime" /t REG_BINARY /d "ffffffff" /f
# Example if class is in 0000
@CTimmerman
CTimmerman / epi_sir_basic.ipynb
Last active January 21, 2022 15:13 — forked from jph00/epi_sir_basic.ipynb
Basic SIR epidemic model
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@CTimmerman
CTimmerman / youtube-dl.py
Last active September 19, 2021 03:22
YouTube Stream Downloader
"""YouTube Stream Downloader
2021-08-16 v1.0 by Cees Timmerman
2021-09-18 v1.1 Better error handling. Revert to XML captions as conversion to SRT is broken in pytube 11.0.1 for https://www.youtube.com/watch?v=AOZw1tgD8dA
"""
import logging, os, re
import pytube
from pytube.cli import on_progress
@CTimmerman
CTimmerman / CollatzConjecture3n+1.py
Created July 31, 2021 10:15
Collatz conjecture
"""Collatz conjecture. Inspired by https://www.youtube.com/watch?v=094y1Z2wpJg
2021-07-31 by Cees Timmerman
"""
def collatz(n: int) -> int:
return 3*n+1 if n%2 else n//2
def collatz_count(start: int) -> int:
step = 0
while True:

Heat and power

I have district heating from a combined heat and power plant, which should be 80+% efficient. A solar air to water heat pump could be more efficient at 29% * usually 200% but sometimes 400% (For reference, traditional gas boilers only go up to 94%.) = 58% to 116%, the latter might require ground instead of air. CO2 is a relatively safe refrigerant.

According to ChatGPT: The efficiency of a typical modern steam turbine in a power plant is around 30-40%. Fuel cells can achieve efficiencies in the range of 40% to 60% or even higher for solid oxide fuel cells (SOFCs). Those and molten carbonate fuel cells (MCFCs) are used in combined hea

@CTimmerman
CTimmerman / based.py
Last active March 25, 2021 21:02
Convert floats to any base and back.
"""Converts floats to/from any base.
2021-03-25 v1.1 by Cees Timmerman"""
import math
NUMERALS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def numeral(i):
try:
@CTimmerman
CTimmerman / README-python-framework-benchmark.md
Created February 24, 2021 11:36 — forked from nhymxu/README-python-framework-benchmark.md
Flask vs Falcon vs FastAPI benchmark
gunicorn run:app --workers=9
gunicorn run:app --workers=9 --worker-class=meinheld.gmeinheld.MeinheldWorker

Macbook Pro 2015 Python 3.7

Framework Server Req/s Max latency +/- Stdev
@CTimmerman
CTimmerman / Windows_sucks.md
Last active March 24, 2024 21:03
Windows sucks, too.

Windows sucks, too!

Audio

Apps

echo -e '"$RANDOM returns a pseudorandom integer between 0 and 32767" - False.'
(( r = 1 ))
until ((r <= 0 || r >= 32767))
do
(( r = $RANDOM ))
done
echo -e "$r.\nSemicolons replace newlines:"
(( r = 5)); while ((r < 10)); do echo $r; (( r ++ )); done
echo "Ranges include end:"
@CTimmerman
CTimmerman / pygame-play-tone.py
Created January 18, 2021 19:22 — forked from ohsqueezy/pygame-play-tone.py
Play a 440 Hz tone in Pygame
# Generate a 440 Hz square waveform in Pygame by building an array of samples and play
# it for 5 seconds. Change the hard-coded 440 to another value to generate a different
# pitch.
#
# Run with the following command:
# python pygame-play-tone.py
from array import array
from time import sleep