Skip to content

Instantly share code, notes, and snippets.

Avatar

Cees Timmerman CTimmerman

View GitHub Profile
@CTimmerman
CTimmerman / epi_sir_basic.ipynb
Last active Jan 21, 2022 — forked from jph00/epi_sir_basic.ipynb
Basic SIR epidemic model
View epi_sir_basic.ipynb
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 Sep 19, 2021
YouTube Stream Downloader
View youtube-dl.py
"""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
View CollatzConjecture3n+1.py
"""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:
@CTimmerman
CTimmerman / Solar.md
Last active Jun 29, 2022
Water & Power
View Solar.md

In 2016, Organic Electronics reported 1.3 microns (about 1/100th the width of a human hair) being on par with glass cells, efficiency-wise. I think organic (carbon-based) material degrades faster, though. I guess it's several spray-on coats, bottom up:

  1. Insulating layer.
  2. Positive (p-type) layer with connections. Boron has vacant electron spaces.
  3. Negative (n-type) layer with connections. Solar radiation excites the electrons in the neutral part of the p-type layer enough to move to the n-type layer and via the connection back to the p-type layer, according to ACS. Seems to me putting the part to be exited first in the path of the photons would be better, but more electrons would soak up more photons.
  4. Insulating layer.

Excess potential between the connections could be used to [split water into ox

@CTimmerman
CTimmerman / based.py
Last active Mar 25, 2021
Convert floats to any base and back.
View based.py
"""Converts floats to/from any base.
2021-03-25 v1.1 by Cees Timmerman"""
import math
NUMERALS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def numeral(i):
try:
View README-python-framework-benchmark.md
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 Apr 13, 2021
Windows sucks, too.
View Windows_sucks.md
View random.sh
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 Jan 18, 2021 — forked from ohsqueezy/pygame-play-tone.py
Play a 440 Hz tone in Pygame
View pygame-play-tone.py
# 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
@CTimmerman
CTimmerman / Jenkinsfile.groovy
Created Dec 15, 2020 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
View Jenkinsfile.groovy
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"