Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar
💭
Amazed at Microsoft's poor UX.

Cees Timmerman CTimmerman

💭
Amazed at Microsoft's poor UX.
View GitHub Profile
@CTimmerman
CTimmerman / keybindings.json
Last active June 28, 2023 13:22
Visual Studio Code settings
[
{
"key": "ctrl+f9",
"command": "editor.debug.action.goToNextBreakpoint"
},
{
"key": "ctrl+shift+f9",
"command": "editor.debug.action.goToPreviousBreakpoint"
},
{
@CTimmerman
CTimmerman / coal_vs_coal_ash_energy_content.md
Last active May 15, 2025 17:35
Coal ash contains more energy than was gained from burning the coal.

Coal ash contains more energy than was gained from burning the coal.

https://www.world-nuclear.org/information-library/facts-and-figures/heat-values-of-various-fuels.aspx

Natural uranium, in FNR                28,000,000 MJ/kg [so 28e9 J/g]
Hard black coal (IEA definition)            >23.9 MJ/kg
Hard black coal (Australia & Canada)        c. 25 MJ/kg [so 25e3 J/g and 207.25 g/mol according to https://pubchem.ncbi.nlm.nih.gov/compound/1-Anthrylmethanolate]
Sub-bituminous coal (IEA definition)    17.4-23.9 MJ/kg
Sub-bituminous coal (Australia & Canada)    c. 18 MJ/kg
Lignite/brown coal (IEA definition)         <17.4 MJ/kg
@CTimmerman
CTimmerman / get_good.txt
Created May 7, 2020 17:10
How to get good.
https://www.youtube.com/watch?v=Y_B6VADhY84
1: Test early and often so you know where you were wrong.
2: Space out sessions so you know it's long term knowledge.
3: Do other stuff in between so it doesn't get boring.
@CTimmerman
CTimmerman / rainbow.py
Last active March 27, 2024 02:43
Rainbow terminal console text and/or background
"""Rainbow print loop using ANSI escape sequences. Press Ctrl+C to stop.
By Cees Timmerman
2020-03-06 First version.
2024-03-27 Fixed on Windows 11."""
import time
CSI = "\x1b[" # Control Sequence Introducer.
# https://en.wikipedia.org/wiki/ANSI_escape_code#Fe_Escape_sequences
# On Windows 11, C1 control code 155 "\x9b" only works the same in VS Code.
# https://github.com/microsoft/terminal/issues/10310
@CTimmerman
CTimmerman / radix_sort.py
Last active February 2, 2025 11:17
LSD radix sort in Python with speed- and doctest test.
"""Ported from https://www.java67.com/2018/03/how-to-implement-radix-sort-in-java.html
Sort an integer list in-place using least significant digit radix sort in Python.
Usage:
>>> x = [180, 50, 10, 30, 10, 29, 60, 0, 17, 24, 12]; radix_sort(x); x
[0, 10, 10, 12, 17, 24, 29, 30, 50, 60, 180]
Time Complexity of Solution:
Best Case O(k*n); Average Case O(k*n); Worst Case O(k*n),
where k is the length of the longest number and n is the
size of the input array.
@CTimmerman
CTimmerman / Flask_CRUD_demo.py
Last active May 9, 2022 10:00
Flask CRUD demo
# pylint: disable=broad-except, invalid-name, redefined-builtin
"""CRUD API demo in Python with Flask.
2019-08-29 https://blog.rapidapi.com/how-to-build-an-api-in-python/ simplified by Cees Timmerman.
2022-05-09 Polished.
"""
import random
from flask import Flask, request
@CTimmerman
CTimmerman / revert-a-commit.md
Created June 19, 2019 15:32 — forked from gunjanpatel/revert-a-commit.md
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}'

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@CTimmerman
CTimmerman / benchmark_fib.sh
Created May 28, 2019 18:16 — forked from deeplook/benchmark_fib.sh
Benchmark using Fibonacci numbers with Python, Cython and PyPy.
#!/usr/bin/env bash
echo "Benchmark for Fibonacci numbers with Python3, Cython and PyPy"
echo '
def fib(n):
"Return the n-th Fibonacci number."
i = 0
a, b = 0, 1
if n < 2:
@CTimmerman
CTimmerman / bottle_hello.py
Created May 28, 2019 17:51 — forked from drgarcia1986/bottle_hello.py
Python HelloWorld (WebFrameworks) Collection
# -*- coding: utf-8 -*-
from bottle import route, run
@route('/')
def index():
return '<h1>Hello World/h1>'
run(host='localhost', port=8000)
@CTimmerman
CTimmerman / benchmark_iteration.js
Created May 14, 2019 13:40
Benchmark iteration in JS.
/* Calculate the sum of upVotes, https://hackernoon.com/javascript-performance-test-for-vs-for-each-vs-map-reduce-filter-find-32c1113f19d7
Node v10.15.3 on Win10:
reduce: 0.171ms
101
for loop: 0.005ms
101
for each: 0.018ms
101
map: 0.062ms
101