Skip to content

Instantly share code, notes, and snippets.

View arnobaer's full-sized avatar

Bernhard Arnold arnobaer

  • Institute of High Energy Physics, OeAW
View GitHub Profile
@arnobaer
arnobaer / .Xmodmap
Created August 26, 2024 10:58
xmodmap for german on english keyboards
! Map umlauts to RIGHT ALT + <key>
keycode 108 = Mode_switch
keysym e = e E EuroSign
keysym c = c C cent
keysym a = a A adiaeresis Adiaeresis
keysym o = o O adiaeresis Adiaeresis
keysym u = u U adiaeresis Adiaeresis
keysym s = s S ssharp
@arnobaer
arnobaer / fractional_prescales.cc
Created September 8, 2022 11:56
Prescale counter for fractional prescales with fixed precision.
// Prescale counter for fractional prescales with fixed precision.
#include <iostream>
#include <cmath>
#include <limits>
struct PrescaleCounter {
const size_t prescale_count;
const size_t single_step;
@arnobaer
arnobaer / ly.py
Created February 11, 2022 15:38
Darklyrics from cmus for your terminal.
#!/usr/bin/env python3
import subprocess
import urllib.request
import os
import re
import sys
def download(artist: str, album: str) -> str:
@arnobaer
arnobaer / k24xx.md
Last active October 18, 2021 10:40

SCPI Commands for Keithley SMUs

Command K2410 K2470
identity *IDN? *IDN?
reset *RST *RST
clear *CLS *CLS
get error :SYST:ERR? :SYST:ERR?
set beeper :SYST:BEEP:STAT <OFF,ON> n/a
set terminals :ROUT:TERM \ :ROUT:TERM \
import math
__all__ = ['round_half_away_from_zero']
def round_half_away_from_zero(n: float, decimals: int = 0) -> float:
multiplier: float = 10 ** decimals
return math.copysign(math.floor(abs(n * multiplier) + 0.5) / multiplier, n)
@arnobaer
arnobaer / bisect_unidirectional.py
Last active June 23, 2021 16:28
bisect for ascending and descending series
def bisect_asc(arr):
if len(arr):
return arr[-1] < arr[0]
return True
def bisect_cmp(arr):
if bisect_asc(arr):
return lambda x, y: x > y
return lambda x, y: x < y
def linspace(start, stop, count):
delta = (stop - start) / max(1, count - 1)
return [start + i * delta for i in range(count)]
def sample(data, count):
n = len(data)
count = min(n, count)
return [int(round(i)) for i in linspace(0, len(data) - 1, count)]
@arnobaer
arnobaer / const_map_at_default.hxx
Last active May 14, 2021 22:01
Yet another personal C++11 recipe book
template<typename T>
const typename T::mapped_type& at(const T& m, const typename T::key_type& k, const typename T::mapped_type& d)
{
try { return m.at(k); } catch (const std::out_of_range&) { return d; };
}
@arnobaer
arnobaer / L1Menu_Sample.py
Created May 4, 2021 07:29
Future L1Menu mockup
import l1menu
MU = l1menu.muon.pt(0)
MU_SNGL = MU.iso(12,13,14,15)
ETA_2p0 = (-2.0, 2.0)
MASS_MIN_1 = 1.0
MASS_MIN_7 = 7.0
MASS_MASS_7to18 = (7.0, 18.0)
@arnobaer
arnobaer / install-comet-pqc.sh
Created March 18, 2021 15:53
Installer GitBash on Windows
set -e
version=$1
if [ -z "$version" ]; then
echo "usage: $0 <version>"
exit 1
fi
install_dir="./envs/comet-pqc-$version"
if [ -d "$install_dir" ]; then
echo "directory already exists: $install_dir"
exit 1