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
Sub ExportAllToCsv | |
document = ThisComponent | |
' Use the global string tools library to generate a base filename for each CSV | |
' based on the current prefixless filename | |
GlobalScope.BasicLibraries.loadLibrary("Tools") | |
DocumentName = Left(document.Namespace, Len(document.Namespace) - 1) | |
BasePath = Tools.Strings.DirectoryNameoutofPath(DocumentName, "/") | |
BaseFilename = Tools.Strings.GetFileNameWithoutExtension(DocumentName, "/") | |
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/bash | |
# Downloads NBDKit and builds a minimal version. This minimal version only | |
# installs basic plugins and filters, and the SSH plugin. | |
# For compilation to succeed, you'll need to install | |
# yum install gcc gcc-c++ libssh-devel openssl-devel autoconf automake libtool | |
# Also, best create a user nbdkit | |
# adduser --system --user-group --shell /sbin/nologin --home-dir /opt/nbdkit --create-home nbdkit |
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
# nbdkit.service | |
[Unit] | |
Description=nbdkit Service | |
After=nbdkit.socket | |
Requires=nbdkit.socket | |
[Service] | |
Environment="LD_LIBRARY_PATH=/opt/nbdkit/lib64" | |
Environment="TMPDIR=/var/lib/nbdkit/cache/" |
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) |
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 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
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
#!/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
#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
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 |