Skip to content

Instantly share code, notes, and snippets.

@wvengen
wvengen / sign_via_url.rb
Last active January 30, 2025 11:12
Sign a Hypothesis Via URL
#!/usr/bin/env ruby
#
# Ruby implementation for signing Via URLs (proof of concept)
#
# Useful when SIGNED_URLS_REQUIRED is enabled and VIA_SECRET set.
# See https://github.com/hypothesis/via for more information.
#
require 'blake2b'
require 'jwt'
require 'uri'
@wvengen
wvengen / ly-server.py
Created February 26, 2024 11:06
Adding a custom export command to python-ly's ly.server
#!/usr/bin/env python3
#
# python-ly server that adds an a custom export command
#
# tested with python-ly version 0.9.8
# https://github.com/frescobaldi/python-ly
#
import copy
from http.server import HTTPServer
@wvengen
wvengen / README.md
Last active October 24, 2023 07:15
Nutriscore SVGs (for use on light background)

Nutriscore SVGs

Nutriscore logo's for use with light background (SVG), extracted from the Nutriscore's corporate graphic charter (dec 2022). For use on light background.

License

The author (me) does not claim any copyright, these files can be used freely. The logo's are probably in the public domain, though trademark law may apply. IANAL.

@wvengen
wvengen / upgrade-pg.py
Last active November 21, 2024 08:32
Major upgrade PostgreSQL on cloudnative-pg
#!/usr/bin/env python3
#
# Helper script to do major version upgrades of a cloudnative-pg based
# PostgreSQL cluster.
#
# Usage: python3 upgrade-pg.py <cluster-name> <new-pg-version>
#
# Example: python3 upgrade-pg.py my-backend-db 17.0
#
# Make sure to include major and minor version in the pg version.
@wvengen
wvengen / README.md
Last active August 1, 2022 07:08
Using trickle with Flatpak applications

Trickle is a command-line tool to throttle network bandwidth of other applications. You use it on the command-line to start the application. It uses LD_PRELOAD to override network-related calls. As a result, using it with containerized apps, like Flatpak, does not work out of the box.

To get trickle to function with a Flatpak application, the preloaded library needs to be available in the container. And it needs to be compatible with the software in the container (notably, a glibc version that is compatible).

First try

  1. Install trickle on your (host) system, on Debian/Ubuntu that would be apt install trickle.
  2. Make sure you have the flatpak application installed. I'm using com.slack.Slack as an example here.
  3. Run the flatpak application with trickle
@wvengen
wvengen / update-metabase-db-from-heroku.sh
Last active January 23, 2023 11:20
Update Metabase DB credentials from Heroku (for PostgreSQL)
#!/bin/bash
#
# Update database connections in Metabase from Heroku
#
# Tailor the following variables to your situation, set credentials in ~/.netrc (with: machine, login, password)
#
# Requirements:
# - curl
# - jq
# - heroku CLI
@wvengen
wvengen / scrapy_h2_proxy.py
Last active October 26, 2023 16:17
Scrapy download handler for HTTP/2 over a HTTP/1 proxy (TLS only).
"""
Download handler for HTTP/2 supporting proxy CONNECT over HTTP/1.
You can use this by configuring it in the spider settings:
DOWNLOAD_HANDLERS = {
'https': 'scrapy_h2_proxy.H2DownloadHandler',
}
Tested with Scrapy 2.5.0.
@wvengen
wvengen / pdf-zotero-unlink.py
Created May 21, 2021 08:43
Alternative for Zotero's "Unlink citations" in Google Docs
@wvengen
wvengen / launchpad_x.ctlr
Created June 17, 2020 13:06
Luppp controller definition for the Novation Launchpad X
{
"name": "Novation Launchpad X",
"author": "wvengen",
"link": "https://novationmusic.com/en/launch/launchpad-x",
"inputBindings": [
{
"status": 176,
"data": 89,
"action": "grid:launch_scene",
"scene": 0
@wvengen
wvengen / gather-fish-data-fishbase.rb
Last active March 3, 2020 12:27
Enriching ASFIS with Wikidata or FishBase
#!/usr/bin/env ruby
#
# We start with the list at:
# http://www.fao.org/fishery/collection/asfis
# Then we query FishBase (and SeaLifeBase) for the ID and NL name.
#
# Before running this script, make sure you have the ASFIS spreadsheet,
# and make sure you've created the CACHEDIR directory (which stores all
# requests, so you can run this again without having to wait for the requests).
#