Skip to content

Instantly share code, notes, and snippets.

@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
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):
@StefRe
StefRe / 2Dinterpolation.py
Created June 11, 2020 20:48
2D interpolation
from scipy import interpolate
import numpy as np
array = np.array([[0,20,10], [0,10,5]])
new_shape = (2, 21)
f = interpolate.interp2d(np.linspace(0, new_shape[1], array.shape[1]), np.linspace(0, new_shape[0], array.shape[0]), array)
new_array = f(np.linspace(0, new_shape[1], new_shape[1]), np.linspace(0, new_shape[0], new_shape[0]))
# array([[ 0. , 2. , 4. , 6. , 8. , 10. , 12. , 14. , 16. , 18. , 20. ,
@StefRe
StefRe / test_hook.py
Created April 19, 2020 07:58
Pytest report hooks
import pytest
# ----- general -----
@pytest.fixture(scope="function",
params=['none', 'setup', 'call', 'teardown', 'setup+call',
'setup+teardown', 'call+teardown', 'setup+call+teardown'])
def resource(request):
param = request.param
print('setup')
if 'setup' in param:
@StefRe
StefRe / CustomJodaFormat.java
Created January 16, 2020 12:25
Custom joda date format with Jackson serialization
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import com.fasterxml.jackson.datatype.joda.cfg.JacksonJodaDateFormat;
import com.fasterxml.jackson.datatype.joda.ser.LocalDateSerializer;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.LocalDate;