Skip to content

Instantly share code, notes, and snippets.

View stephanlachnit's full-sized avatar

Stephan Lachnit stephanlachnit

View GitHub Profile
@stephanlachnit
stephanlachnit / si_photon_abs_length.py
Created August 31, 2023 10:54
Plot Absorption Length of Photons in Silicon
#!/usr/bin/env python3
# SPDX-License-Identifier: Unlicense
import numpy as np
import matplotlib.pyplot as plt
# Data from https://doi.org/10.1002/pip.4670030303
# wavelength in nm, alpha in cm^-1, abs length in um
wavelength = np.linspace(250, 1450, num=121)
alpha = np.array([1.84e+06,1.97e+06,2.18e+06,2.36e+06,2.24e+06,1.73e+06,1.44e+06,1.28e+06,1.17e+06,1.09e+06,1.04e+06,1.02e+06,6.97e+05,2.93e+05,1.50e+05,9.52e+04,6.74e+04,5.00e+04,3.92e+04,3.11e+04,2.55e+04,2.10e+04,1.72e+04,1.48e+04,1.27e+04,1.11e+04,9.70e+03,8.80e+03,7.85e+03,7.05e+03,6.39e+03,5.78e+03,5.32e+03,4.88e+03,4.49e+03,4.14e+03,3.81e+03,3.52e+03,3.27e+03,3.04e+03,2.81e+03,2.58e+03,2.38e+03,2.21e+03,2.05e+03,1.90e+03,1.77e+03,1.66e+03,1.54e+03,1.42e+03,1.30e+03,1.19e+03,1.10e+03,1.01e+03,9.28e+02,8.50e+02,7.75e+02,7.07e+02,6.47e+02,5.91e+02,5.35e+02,4.80e+02,4.32e+02,3.83e+02,3.43e+02,3.06e+02,2.72e+02,2.40e+02,2.10e+02,1.83e+02,1.57e+02,1.34e+02,1.14e+02,9.59e+01,7.92e+01,6.40e+01,5.11e+01,3.99e+01,3.02e+01,2.26e+01,1.63e+01,1.11e+01,8.00e+
@stephanlachnit
stephanlachnit / membuf.hpp
Last active March 26, 2024 06:10
C++17 std::streambuf implementation in memory with efficient resizing and possibility to keep the buffer after exit
// SPDX-FileCopyrightText: 2023 Stephan Lachnit <stephanlachnit@debian.org>
// SPDX-License-Identifier: MIT
#include <algorithm>
#include <cstdlib>
#include <ios>
#include <streambuf>
// std::streambuf implementation in memory with efficient resizing and possibility to keep the buffer after exit
template<std::streamsize BLOCK_SIZE = 1024>
@stephanlachnit
stephanlachnit / vecbuf.hpp
Created January 20, 2023 22:42
C++17 streambuf based on std::vector
// SPDX-FileCopyrightText: 2023 Stephan Lachnit
// SPDX-License-Identifier: MIT
#include <streambuf>
#include <string>
#include <vector>
template<class CharT = char, class Traits = std::char_traits<CharT>>
class vecbuf : public std::basic_streambuf<CharT> {
public:
@stephanlachnit
stephanlachnit / blocking_queue.hpp
Last active January 19, 2023 17:34
C++17 blocking queue with timeout and shutdown request
// SPDX-License-Identifier: Unlicense
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <deque>
#include <mutex>
#include <optional>
#include <queue>
@stephanlachnit
stephanlachnit / clean_apt-cacher-ng_cache.sh
Last active May 21, 2023 11:05
Clean apt-cacher-ng cache
#!/bin/sh
# Cleans apt-cacher-ng cache
# SPDX-FileCopyrightText: 2022 Stephan Lachnit <stephanlachnit@debian.org>
# SPDX-License-Identifier: 0BSD
systemctl stop apt-cacher-ng
rm -rf /var/lib/apt/*
rm -rf /var/cache/apt/*
rm -rf /var/cache/apt-cacher-ng/
mkdir -p /var/cache/apt-cacher-ng/{headers,import,packages,private,temp}
chown apt-cacher-ng:apt-cacher-ng -R /var/cache/apt-cacher-ng
@stephanlachnit
stephanlachnit / download_minecraft_server_jar.py
Last active January 20, 2022 22:39
Get the latest Minecraft server.jar (including snapshots)
#!/usr/bin/python3
#
# SPDX-FileCopyrightText: 2021 Stephan Lachnit <stephanlachnit@debian.org>
#
# SPDX-License-Identifier: MIT
import hashlib
import os.path
import sys
@stephanlachnit
stephanlachnit / config.txt
Created March 20, 2021 16:27
Pi Zero W headless low power config
# Pi Zero W headless low power config
# Disable hardware interfaces
dtparam=i2c_arm=off
dtparam=i2c_vc=off
dtparam=i2s=off
dtparam=spi=off
# Disable audio
dtparam=audio=off
@stephanlachnit
stephanlachnit / bethe_weizsaecker_binding.py
Created May 25, 2020 12:17
Create Graphs for Bethe-Weizsäcker binding energy per nukleon
# SPDX-License-Identifier: Unlicense
import matplotlib.pyplot as plt
import numpy as np
# Graph Limits
Zmin = 1
Zmax = 200
Nmin = 1
@stephanlachnit
stephanlachnit / xorg.conf
Last active April 8, 2020 20:02
xorg.conf for Xiaomi Mi Notebook Air 13.3 2018 with proprietary Nvidia drivers
Section "Device"
Identifier "intel-gpu"
Driver "modesetting"
BusID "PCI:0:2:0"
VendorName "Intel Corporation"
BoardName "UHD Graphics 620"
EndSection
Section "Device"
Identifier "nvidia-gpu"
@stephanlachnit
stephanlachnit / cl_devices.cpp
Last active November 17, 2018 21:51 — forked from dogukancagatay/Makefile
List OpenCL devices and platforms using C++
#include <iostream>
#include <CL/cl.hpp>
int main(int argc, char *argv[]) {
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
int platform_id = 0;
int device_id = 0;