Skip to content

Instantly share code, notes, and snippets.

@wvengen
wvengen / join_hypothesis_group.rb
Created July 17, 2026 13:06
Joining an Hypothesis group
#!/usr/bin/env ruby
#
# Joining an Hypothesis group is done through the web, and there is no API method to do so.
# Sometimes this is useful. Here is an implementation that logs into Hypothesis, and joins a group.
#
# Set the environment variables:
# HYPOTHESIS_USERNAME
# HYPOTHESIS_PASSWORD
# Then call the script with argument the Hypothesis group id.
# ruby join_hypothesis_group.rb abcd12345
@wvengen
wvengen / README.md
Last active January 15, 2026 11:08
Ruby memory analysis over time

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

@wvengen
wvengen / get-publitas.sh
Created October 11, 2018 09:10
Generate PDF from Publitas folder URL
#!/bin/sh
#
# Generates PDF from Publitas images (online folder service)
# Stores generated PDF and JSON (which may contains links).
#
# Requirements:
# - wget https://www.gnu.org/software/wget/
# - jq https://stedolan.github.io/jq/
# - imagemagick https://www.imagemagick.org/
#
@wvengen
wvengen / extend.sh
Last active September 27, 2025 02:40
Extend non-HiDPI external display above HiDPI internal display
#!/bin/sh
# extend non-HiDPI external display on DP* above HiDPI internal display eDP*
# see also https://wiki.archlinux.org/index.php/HiDPI
# you may run into https://bugs.freedesktop.org/show_bug.cgi?id=39949
# https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/883319
EXT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^eDP | head -n 1`
INT=`xrandr --current | sed 's/^\(.*\) connected.*$/\1/p;d' | grep -v ^DP | head -n 1`
ext_w=`xrandr | sed 's/^'"${EXT}"' [^0-9]* \([0-9]\+\)x.*$/\1/p;d'`
@wvengen
wvengen / upgrade-pg.py
Last active May 28, 2025 12:29
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 / 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 / scanner.rb
Last active February 22, 2024 13:31
Hack to use Android phone as barcode scanner for pc
#!/usr/bin/env ruby
#
# Hack to use Android phone as barcode scanner for pc.
#
# Installation and setup:
# * Enable usb debugging on your Android phone
# * Make sure you have an Android SDK installed
# * Make sure xdotool is installed (apt-get has it) http://www.semicomplete.com/projects/xdotool/
# * Build and install https://github.com/majido/clipper
# * Start service: `adb shell su -c \'am startservice ca.zgrs.clipper/.ClipboardService\'`
@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 / 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.