This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# Fetch the number of pages in the pdf | |
NP=`pdfinfo "$1" | grep "Pages:" | sed 's/Pages:[ \t]*\(0-9\)*[ \t]*/\1/'` | |
# Fetch the title | |
TITLE=`pdfinfo "$1" | grep "Title:" | sed 's/Title:[ \t]*\(.*\)/\1/'` | |
# Create a target folder | |
NAME=`basename "$1" .pdf` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const Beeper::Tone ode_an_die_freude_tone_seq[60] = { | |
{.note = MusicalNotes::B4, .len = 200}, | |
{.note = MusicalNotes::Pause, .len = 50}, | |
{.note = MusicalNotes::B4, .len = 200}, | |
{.note = MusicalNotes::Pause, .len = 50}, | |
{.note = MusicalNotes::C5, .len = 200}, | |
{.note = MusicalNotes::Pause, .len = 50}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def polyval_fixed(coeffs, x, scale): | |
res = 0 | |
for c in coeffs: | |
res = (((x * res) >> scale) + c) | |
return res | |
def log2_approx(x): | |
if x < 1: | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
int32_t log2_f14(int32_t x) { | |
// We don't support zero or negative values, just return zero in that case | |
if (x <= 0) { | |
return 0; | |
} | |
// Compute the integer logarithm | |
int32_t log2_int = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
This module provides an `eval_in_sandbox` function that, on Linux systems, | |
executes arbitrary Python code in a secure and lightweight sandbox with | |
memory, I/O, and time limits. | |
---- | |
Copyright (c) 2023 Andreas Stöckel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
pacat \ | |
--device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor \ | |
--rate=48000 \ | |
--record | \ | |
opusenc \ | |
--expect-loss=25 \ | |
--max-delay=0 \ | |
--framesize=2.5 \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
class EnvGuard: | |
""" | |
Class used to temporarily set some environment variables to a certain value. | |
In particular, this is used to set the variable OMP_NUM_THREADS to "1" for | |
each of the subprocesses using cvxopt. | |
""" | |
def __init__(self, env={}): | |
self.env = env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compute_transfer_function(us, xs, dt=dt, smoothing=100.0): | |
Us = np.fft.fftshift(np.fft.fft(us)) | |
Xs = np.fft.fftshift(np.fft.fft(xs)) | |
fs = np.fft.fftshift(np.fft.fftfreq(len(us), dt)) | |
wnd = np.exp(-np.square(fs) / np.square(smoothing)) | |
wnd /= np.sum(wnd) * dt | |
UXs = np.fft.fftshift(np.fft.fft(Us * np.conj(Xs))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fuzzy_find(term, lst, threshold=0.75, shingle_len=3): | |
# Create a set of n-grams of length shingle_len | |
def shingle(s): | |
shingles = [] | |
for t in re.split(' ', s): | |
for i in range(max(1, len(t) - shingle_len)): | |
shingles.append(t[i:i+shingle_len]) | |
return set(shingles) | |
# Computes the Jaccard similarity between two sets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def zorder(N): | |
if N == 0: | |
return np.zeros((0, 0), dtype=np.int) | |
elif N == 1: | |
return np.zeros((1, 2), dtype=np.int) | |
else: | |
pnts = zorder(N - 1) | |
l = pnts.shape[0] | |
offs = 2 ** (N - 2) | |
res = np.zeros((4 * l, 2), dtype=np.int) |
NewerOlder