Skip to content

Instantly share code, notes, and snippets.

View CTimmerman's full-sized avatar

Cees Timmerman CTimmerman

View GitHub Profile
@CTimmerman
CTimmerman / Jenkinsfile.groovy
Created December 15, 2020 04:37 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
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"
@CTimmerman
CTimmerman / fail.md
Last active May 19, 2024 22:01
Tech fails

If you don't learn from the past you're doomed to repeat it.

Audio

  • Dell Latitude 5501 sounds even worse than my MSI MS-16P7 due to ratting its plastic case. Interviews sound like a poor phone connection. Iron Maiden - Can I Play With Madness on the other hand is tolerable and even has some bass, almost enough for Robbie Williams - Angels, which sounds like a not-quite-tuned FM radio for the vocals (too little power), particularly noticable on U2 - Discotheque. Without "audio enhancements" disabled, its audio jack adds a rumble to videos like this. Worst audio hardware I've ever used, especially playing this. Then again, using my Logi
@CTimmerman
CTimmerman / http_ear.py
Created November 24, 2020 09:19
Simple debugging HTTP server
#coding: utf8
""" Simple debugging HTTP server
2020-11-20 v1.0 by Cees Timmerman
"""
import logging
from pprint import pformat as pf
from flask import Flask, request, make_response
app = Flask(__name__)
@CTimmerman
CTimmerman / penta.py
Created November 24, 2020 07:57
Euler's pentagonal formula
"""Euler's pentagonal formula, by Cees Timmerman, 2020-11-23.
https://www.youtube.com/watch?v=iJ8pnCO0nTY"""
import math
def get_lookback_index(x: int):
i = 0
a = 0
b = 1
steps = [1]
while i < x-1:
@CTimmerman
CTimmerman / App.jsx
Created November 18, 2020 20:52
GIF Maker
// from https://fireship.io/lessons/wasm-video-to-gif/
// formatted using prettier --write "src/**/*.{js,jsx}"
import React, { useState, useEffect } from 'react';
import './App.css';
import { createFFmpeg, fetchFile } from '@ffmpeg/ffmpeg';
const ffmpeg = createFFmpeg({ log: true });
function App() {
@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 March 18, 2024 20:32
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 May 2, 2024 19:09
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.