Skip to content

Instantly share code, notes, and snippets.

@StefRe
StefRe / vsbuildtools.md
Last active August 13, 2025 12:02
Install VS Build Tools on Windows 10 without admin permissions for usage with Cython
  1. Install VS Build Tools using PortableBuildTools
    https://github.com/Data-Oriented-House/PortableBuildTools

  2. for version 14.44.17.14 it creates devcmd.bat in the vs_BuildTools folder

    • copy this devcmd.bat to VC\vcvarsall.bat
    • in vcvarsall.bat create an environment variable LIBPATH and set it to the same value as LIB
      (query_vcvarsall in distuils msvc9compiler needs LIBPATH in addition to LIB)
  3. set VS140COMNTOOLS to the vs_BuildTools\VC\Tools folder
    (this makes sure vcvarsall.bat is being found by distutils)

@StefRe
StefRe / busday_count.py
Last active May 10, 2025 17:17
Get number of business days between two dates
import holidays
import numpy as np
import pandas as pd
start = '2025-04-30'
end = '2025-05-06'
# holidays (end date is included)
h = holidays.country_holidays('DE', subdiv='SN')
print(h.get_working_days_count(start, end)- h.is_working_day(end))
@StefRe
StefRe / mpl_cm_opencv.py
Last active September 25, 2024 11:54
Use matplotlib colormap in OpenCV
def make_colormap_from_mpl(cm):
"""Create look-up table to convert grayscale to BGR-image.
The returned colormap can be used like
bgr_img = colormap[gray_img]
Args:
cm: Matplotlib colormap name, e.g. "autumn" or
colormap instance e.g. mpl.cm.autumn
@StefRe
StefRe / Export_IPython_notebook_without_prompts.md
Created May 17, 2024 07:25
VSCode: Export IPython notebook without prompts

It's not possible to configure the export function of vscode-jupyter by extra command line arguments passed to nbconvert. The feature request microsoft/vscode-jupyter#13918 was declined.

A workaround is to specify additional arguments in a configuration file jupyter_nbconvert_config.py in the .jupyter folder (its location can be shown by python.exe -m jupyter --path).

Contents of jupyter_nbconvert_config.py to hide prompts (equivalent to --no-prompt):

c = get_config()
@StefRe
StefRe / feltz_miller.py
Last active November 1, 2023 20:23
Testing Coefficients of Variation from multiple samples
import numpy as np
import scipy
def feltz_miller(*samples):
k = len(samples)
m_j = np.array([len(sample) - 1 for sample in samples])
cv_j = np.array([np.std(sample, ddof=1) / np.mean(sample) for sample in samples])
d = np.sum(m_j * cv_j) / np.sum(m_j)
@StefRe
StefRe / matplotlib tick label localization.py
Last active February 6, 2023 08:45
Matplotlib tick label localization
import locale
import platform
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
dates = np.arange(np.datetime64('2022-12-01'), np.datetime64('2022-12-02'), np.timedelta64(1, 'h'))
values = np.zeros_like(dates, dtype=int)
@StefRe
StefRe / so73466464.ipynb
Created August 26, 2022 12:19
SO73466464.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@StefRe
StefRe / tkinter_standard_fonts.py
Created January 25, 2022 11:33
Tkinter Standard Fonts and How to Scale them
import tkinter as tk
import tkinter.font
root = tk.Tk()
print('Standard fonts:')
for name in sorted(tk.font.names()):
config = tk.font.Font(name=name, exists=True).config()
print(f"{name:20.20}: {config['family']} {config['size']} {config['weight']}")
@StefRe
StefRe / kotlin_regex_condition.kt
Last active March 20, 2021 17:57
Kotlin regex condition
val scripts = listOf(
"""
if (1 != 0) {
document.writeln('valid');
}else{
document.writeln('invalid'); };
</script>""",
"""
if (0 != 0) {
import numpy as np
import perfplot
import matplotlib.pyplot as plt
plt.figure(figsize=(10,6))
xy = [51,52]
maxint = 10
def setup(n):