Skip to content

Instantly share code, notes, and snippets.

@wvengen
wvengen / README.md
Last active October 4, 2016 17:44
Raspberry Pi HiFi audio options
@wvengen
wvengen / README.md
Last active October 10, 2016 08:05
Using redux-api with batch requests

redux-api provides an easy and flexible way to interface with REST APIs in Redux (e.g. when building a React app). It works pretty well when there you know beforehand what API calls you're going to make, and define them in its configuration object.

But when you want to make multiple calls to the same endpoint, and don't know beforehand how many, you're a bit out of luck. In my case, I had a product listing where each product had a category and a score. In a summary overview, I wanted to show a histogram of the scores for each category. That means: first a request to the categories endpoint, and then for each of the categories, a request to the histogram endpoint.

This is an example of how to do that.

screenshot

@wvengen
wvengen / README.md
Last active January 19, 2017 01:17
d3.chart.sankey (energy demo)
@wvengen
wvengen / README.md
Last active November 10, 2018 22:36
d3.chart.sankey (interactive demo)
@wvengen
wvengen / gen_wpa_sup.py
Created November 25, 2016 09:56
wifi export for network-manager
#!/usr/bin/env python
#
# Export network-manager WiFi connection details to a wpa-supplicant
# file. This can be saved to an Android device, so you have all your
# laptop's WiFi connections on your phone right away (root required).
#
# python gen_wpa_sup.py >foo
# adb push foo /sdcard/foo
# adb shell
# su -c 'cat /sdcard/foo >>/data/misc/wifi/wpa_supplicant.conf'
@wvengen
wvengen / update-freevpn.sh
Last active April 28, 2019 17:24
Update on-demand PPTP configuration for free VPNs
#!/bin/sh
#
# Update freevpn.se pptp configuration
#
# Since the password changes now and then, it's useful to update it automatically.
# Make sure you've installed lynx. Tested on Debian.
#
URL=https://www.freevpn.se/accounts/
PEERNAME=freevpn.se
@wvengen
wvengen / install_scrapyd.sh
Last active May 31, 2019 07:27
Installation script for scrapyd
#
# Installation script for scrapyd on Debian/Ubuntu
# http://scrapyd.readthedocs.org/
#
# - Latest scrapyd from Scrapy package repository
# - Password protection with http basic auth
# - HTTPS with self-signed certificate
# - Works on Amazon EC2
#
FQDN=scrapy.example.com
@wvengen
wvengen / README.md
Last active December 13, 2019 12:13
Run OpenLabeler with system Java

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 / README.md
Last active January 16, 2020 13:49
d3.chart.sankey (product demo)

d3.chart.sankey: Reusable D3 Sankey diagram using d3.Chart.

This diagram shows how the ingredients may contribute to the total sustainability of a chocolate bar through different issues.

@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).
#