Skip to content

Instantly share code, notes, and snippets.

View heetbeet's full-sized avatar

Simon Streicher heetbeet

View GitHub Profile
heetbeet /
Created December 17, 2019 19:52
Extract all email attachments from eml files
The MIT License (MIT)
Copyright (c) 2014 Patrick Olsen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
heetbeet /
Created March 17, 2023 07:24
VBA test valid South African ID


Tell me how to check for valid South african ID numbers. Are there checksums? It starts with yymmdd so at least you know that 009999 is an invalid start. Write a list of all things that can be considered


Valid South African ID numbers follow a specific format and contain a few checks that can be used to determine their validity. Here is a list of things you can consider when checking the validity of a South African ID number:

  1. Length: A valid South African ID number should be 13 digits long.
  2. Birthdate: The first six digits should represent the birthdate of the person in the format YYMMDD. This means that an ID number starting with "009999" would be invalid as you mentioned.
  3. Gender: The 7th to 9th digits indicate the gender of the person. A value of 0000-4999 represents a female, while 5000-9999 represents a male.
  4. Citizenship: The 10th digit represents citizenship. A value of 0 indicates a South African citizen, while 1 indicates a permanent resident.
heetbeet /
Last active November 21, 2023 08:37

I have a system where something akin to damage occurs over time. The damage goes from level 0 to level 10 in a type of scurve (starting at 0-ish at time=0, and ending at 10-ish after some period). This scurve is slightly stretched and different at different intensities. The whole surface can be modelled with a smooth function using some kind of made up extruded scurve. One simple example being:

def damage_func(duration_at_constant_intensity, intensity, *optimal_parameters):
   return extruded_scurve(duration_at_constant_intensity, intensity, *optimal_parameters) 

With an example of an extruded scurve:

heetbeet / Web app with automatic graph
Created November 15, 2023 14:40
Web app with automatic graph loading


To build a web application like the one in the uploaded image, you'd likely use HTML for the structure, CSS for styling, and JavaScript to make it dynamic. htmx is a JavaScript library that allows you to access AJAX, CSS Transitions, WebSockets, and Server Sent Events directly in HTML, making it easier to create interactive web applications without writing much JavaScript.

Here’s a high-level approach on how to build the retirement forecaster tool using htmx and how to host it:

  1. HTML Structure:

    • Create a form with input fields for current age, retirement age, current income, replacement ratio, current value of capital savings, monthly contributions, investment return rate, and inflation rate.
  • Add a section for displaying the graph and the calculated results like value of savings at retirement, salary at retirement, age at which capital will run out, and years after your capital runs out.
heetbeet / Sequence Probability
Created April 18, 2023 11:57
Sequence Probability Calculation


You have two sequences, a long one and a short one. The short one is 3 characters long, the long one is 40 characters long. They are comprised of characters from the latin alphabet (each char can be one of 26 possible chars). What is the probability of the shorter sequence occurring in the longer sequence? Keep everything symbolic right up to the end.


Let's denote the short sequence as S and the long sequence as L. The short sequence S has a length of 3 characters, while the long sequence L has a length of 40 characters. We want to find the probability of S occurring in L.

There are 26 possible characters for each position in both sequences, and there are (40-3+1) = 38 possible positions in the long sequence where the short sequence could be placed.

Let's compute the probability of the short sequence occurring at a specific position in the long sequence. Since there are 26 possible characters for each position and the characters are assumed to be independent, the probability of the sh

heetbeet / emdw-deps
Created January 25, 2022 06:59
Example wrapper for g++ build tools pipeline
cur_script="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
cur_dir="$(dirname "${cur_script}")"

Did you know you can install fonts without elevation?

The catch is that they're only available for the duration of your session. They are, however, available in all apps across the system.

Someone asked about how to do it on Facebook this week, and at first, I just pointed them at the install script for PowerLineFonts which loops through all the fonts in a folder and install them.

I've used this more than a few times to install some fonts, including the PowerLine ones, which are great:

$sa = New-Object -ComObject Shell.Application
heetbeet /
Last active January 11, 2021 19:00
Lazy guide for compiling Julia on Windows

Setup your environment

Get cygwin portable

  • Download and place cygwin-portable-installer.cmd in the base directory.
  • Edit cygwin-portable-installer.cmd and add the following line (for additional Cygwin dependencies) after line set CYGWIN_PACKAGES=bash-completion,...:

    set CYGWIN_PACKAGES=%CYGWIN_PACKAGES%,cmake,gcc-g++,git,make,patch,curl,m4,python3,p7zip,mingw64-i686-gcc-g++,mingw64-i686-gcc-fortran,mingw64-x86_64-gcc-g++,mingw64-x86_64-gcc-fortran (The list of packages is taken from [](
heetbeet /
Created August 26, 2020 14:18
Convert all bat files in a subdirectory to dos crlf format
find . -name '*.bat' -type f -print0 | xargs -0 unix2dos --
heetbeet / sync-time.bat
Created August 25, 2020 08:30
Manually sync microsoft time
@echo off
if "%~1" equ "isadmin" goto :runmain
powershell "Start-Process -FilePath '%~f0' -WorkingDirectory '%~dp0' -Verb RunAs -ArgumentList isadmin"
goto :eof
net start W32Time
w32tm /resync