Skip to content

Instantly share code, notes, and snippets.

@wvengen
wvengen / README.md
Last active August 1, 2022 07:08
Using trickle with Flatpak applications
View README.md

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)
View update-metabase-db-from-heroku.sh
#!/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 January 3, 2023 22:33
Scrapy download handler for HTTP/2 over a HTTP/1 proxy (TLS only).
View scrapy_h2_proxy.py
"""
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
View pdf-zotero-unlink.py
@wvengen
wvengen / launchpad_x.ctlr
Created June 17, 2020 13:06
Luppp controller definition for the Novation Launchpad X
View launchpad_x.ctlr
{
"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
View gather-fish-data-fishbase.rb
#!/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).
#
@wvengen
wvengen / README.md
Last active November 9, 2020 13:18
Seasonality in foods, international data
View README.md

Buying fruit and vegetables in-season makes a difference in sustainability. What information is there on this, also internationally? Eventually it would be nice to provide this in a common format, so that you can give your country, and find what food products are in-season.

Below are some seasonal calendars. Most are a calendar with what fruits, vegetables (and sometimes other foods) are in-season, per month or per season. This is often tied to local availability. If greenhouses are used to grow, the local option may not be the most sustainable one, only Milieu Centraal appears to talk about this.

@wvengen
wvengen / README.md
Last active December 13, 2019 12:13
Run OpenLabeler with system Java
View README.md

OpenLabeler is a pretty nice image annotation package, but I had issues getting it to run. Plus I'd rather use the system-supplied Java environment, instead of a bundled one, and install it for a user (not in the system).

This happens on a Debian or Ubuntu system (with apt and deb tools available).

  1. Download deb package of latest release.
  2. Extract its contents: dpkg-deb -x ~/.local/openlabeler openlabeler-1.2.0.deb
  3. Make sure you have OpenJDK 11 installed plus apt install libopenjdk-11-jre libopenjfx-java
  4. Cleanup directory structure: cd ~/.local/openlabeler && mv opt/OpenLabeler/* . && rmdir opt/OpenLabeler opt
@wvengen
wvengen / NOTES.md
Last active July 14, 2021 07:03
Semantic web of food notes
@wvengen
wvengen / get-publitas.sh
Created October 11, 2018 09:10
Generate PDF from Publitas folder URL
View get-publitas.sh
#!/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/
#