Skip to content

Instantly share code, notes, and snippets.

View mberz's full-sized avatar
🎄
Holiday

Marco Berzborn mberz

🎄
Holiday
View GitHub Profile
@mberz
mberz / devcontainer.json
Last active November 11, 2025 13:30
VSCode Devcontainer for fenics/dolfinx docker containers with complex number support and some pre-defined plug-ins ((c) mberz CC-BY-4.0)
{
"name": "fenicsx",
"image": "ghcr.io/fenics/dolfinx/lab:v0.10.0",
"containerEnv": {
"PKG_CONFIG_PATH": "/usr/local/dolfinx-complex/lib/pkgconfig",
"PETSC_DIR": "/usr/local/petsc/",
"PETSC_ARCH": "linux-gnu-complex128-32",
"PYTHONPATH": "/usr/local/dolfinx-complex/lib/python3.12/dist-packages:/usr/local/lib:",
"LD_LIBRARY_PATH": "/usr/local/dolfinx-complex/lib:"
},
@mberz
mberz / threadedgenerator.py
Created October 31, 2022 09:45 — forked from everilae/threadedgenerator.py
Threaded generator wrapper for Python
# A simple generator wrapper, not sure if it's good for anything at all.
# With basic python threading
from threading import Thread
try:
from queue import Queue
except ImportError:
from Queue import Queue
import multiprocessing
import numpy as np
from scipy import signal as sgn
def _minimum_phase(signal, n_fft=None, truncate=True):
"""Calculate the minimum phase equivalent of a finite impulse response.
The method is based on the Hilbert transform of the real-valued cepstrum
of the finite impulse response, that is the cepstrum of the magnitude
spectrum only. As a result the magnitude spectrum is not distorted.
Potential aliasing errors can occur due to the Fourier transform based
@mberz
mberz / patch-edid.md
Created November 16, 2021 08:18 — forked from ejdyksen/patch-edid.md
A script to fix EDID problems on external monitors in macOS

patch-edid.rb

A script to fix EDID problems on external monitors in macOS.

Instructions

  1. Connect only the problem display.

  2. Create this directory structure (if it doesn't already exist):

@mberz
mberz / gist:ab8f2bfa90c677de2d2a69641d77563b
Created February 8, 2021 13:49
Running make in local temporary directory
mkdir /tmpnew
mount -t tmpfs tmpfs /tmpnew
TMPDIR=/tmpnew make
@mberz
mberz / oh-my-zsh-bira-conda-venv.md
Created January 18, 2021 11:26 — forked from Samyak2/oh-my-zsh-bira-conda-venv.md
Adding virtualenv and conda support to Oh My Zsh Bira theme
@mberz
mberz / create_directories.py
Created January 6, 2021 09:59
Create directories if they do not exist
dir_name = 'my_dir'
try:
os.makedirs(dir_name)
except OSError:
if os.path.exists(dir_name):
pass
else:
# Raise the exception on everything other than OSError
raise
@mberz
mberz / urllib3_download.py
Created December 7, 2020 20:39
Download a file using urllib3
import urllib3
import shutil
http = urllib3.PoolManager()
with open(filename, 'wb') as out:
r = http.request('GET', url, preload_content=False)
shutil.copyfileobj(r, out)
@mberz
mberz / wsl2-network.ps1
Created October 7, 2020 11:20 — forked from xmeng1/wsl2-network.ps1
WSL2 Port forwarding port to linux
$remoteport = bash.exe -c "ifconfig eth0 | grep 'inet '"
$found = $remoteport -match '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}';
if( $found ){
$remoteport = $matches[0];
} else{
echo "The Script Exited, the ip address of WSL 2 cannot be found";
exit;
}
@mberz
mberz / SConstruct
Last active June 29, 2020 08:43
SConstruct for Latex PDF compilation
# -*- mode: python -*-
# SCons build file
import os
# If using dot2tex, uncomment the following.
#
# LaTeX will not error out if dot2tex is not found, but without it, we can't
# generate our Graphviz graphs. Don't let execution continue if it isn't found.