Skip to content

Instantly share code, notes, and snippets.

View frafra's full-sized avatar

Francesco Frassinelli frafra

View GitHub Profile
@frafra
frafra / .pre-commit-config.yaml
Last active October 21, 2024 15:11
renv failure in nix-shell with pre-commit: libxml2.so.2: cannot open shared object file
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.3
hooks:
- id: style-files
@frafra
frafra / check_data.sh
Created October 7, 2024 14:54
check senorge data
#!/bin/bash
set -eu
lon=10.407
lat=63.431
echo "# seNorge GDAL test"
echo
echo "## Test info"
@frafra
frafra / taskspooler_memory.sh
Created August 23, 2024 06:37
A prototype of task spooler which avoids OOM
#!/bin/bash
set -xeu
export max=$((8*1024*1024*1024)) # 8 GB
memory_max() {
requested=$1
total=$(
find /sys/fs/cgroup/user.slice/ -wholename "*/run-*.*/cgroup.procs" |
@frafra
frafra / default.vcl
Created November 16, 2023 21:04
Allow GDAL vsicurl to fetch streamed replies and caching
vcl 4.1;
import dynamic;
backend default none;
sub vcl_init {
new d = dynamic.director(port = "80");
}
sub vcl_recv {
@frafra
frafra / zotero.js
Created August 21, 2023 12:22
zotero cookbook
// Add incremental Call Number
let items = Zotero.getActiveZoteroPane().getSelectedItems();
let callNumberLength = items.length.toString().length;
for (i=0; i<items.length; i++) {
let item = items[i];
if (!items[i].isRegularItem()) continue;
item.setField("callNumber", (i+1).toString().padStart(callNumberLength, "0"));
await item.saveTx();
}
@frafra
frafra / kroki.js
Last active April 25, 2023 14:12
Render with mermaid and kroki, with support for mdbook
// <script type="module">
var server = "https://kroki.io";
var libraries = [
"bytefield",
"c4plantuml",
"d2",
"ditaa",
"erd",
"graphviz",
"dot",
@frafra
frafra / functions.sh
Created February 8, 2023 08:14
debug tricks
function read_strace_file() {
strace --trace=file "$@" |&
sed --quiet 's;.*"\(/[^"]*\)".*;\1;p' |
sort --unique |
fzf --scheme=path |
xargs --no-run-if-empty less
}
export read_strace_file
@frafra
frafra / look_for_value.sql
Created October 10, 2022 16:27
Look if any column contains such a value
create function pg_temp.look_for_value(value text) returns
table(table_fullname text, column_name text)
language plpgsql as $$
declare
r record;
found bool;
begin
for r in select * from information_schema.columns
loop
table_fullname = format('%I.%I.%I', r.table_catalog, r.table_schema, r.table_name);
@frafra
frafra / v4l2loopback_on_fedora_34.md
Last active August 28, 2022 16:33 — forked from kevineduardo/v4l2loopback_on_fedora_34.md
How to install (and compile) the latest v4l2loopback kernel module on Fedora Workstation 34

How to install (and compile) the latest v4l2loopback kernel module on Fedora Workstation 34

Execute the commands below

sudo dnf install git kernel-devel kernel-headers dkms v4l-utils
git clone https://github.com/umlaeute/v4l2loopback.git
cd v4l2loopback
make
v=$(./currentversion.sh)
@frafra
frafra / add-mitmproxy-cert.sh
Last active March 31, 2022 10:34
mitmproxy snippets and examples
#!/bin/bash -xeu
path="/usr/local/share/ca-certificates/mitmproxy"
mkdir -p "$path"
curl -x mitmproxy:8080 mitm.it/cert/pem > "$path/mitmproxy.crt"
# System
update-ca-certificates
# Java