Skip to content

Instantly share code, notes, and snippets.

bikubi / iptables-nat.service
Created April 11, 2020 11:43
Very simple iptables NAT systemd service
# Very simplistic, use at your own risk. I am using this on Raspbian.
# put me into /etc/systemd/system
# systemctl start iptables-nat
# systemctl stop iptables-nat
# systemctl enable iptables-nat
# see:
# adapted from:
bikubi /
Last active April 10, 2019 12:51
Use Quasar variables in SCSS stylesheets (incomplete)

Quasar supports SCSS but the style variables won't be available.
Here's a possible workaround -- incomplete & untested, since I gave up, went ahead and used stylus. (This is guide is primarily directed at future me, should this become more compelling in the future.)

Install stylus-converter

yarn add --dev stylus-converter
bikubi / wp-blockgallery-fixsizes.php
Created March 13, 2019 11:37
hack to inject better sizes attribute into WordPress Gutenberg Gallery Block
/* Not really recommended, very dangerous. Will change entities.
* Adjust the xpath query & sizes to your needs.
add_filter('the_content', function ($content) {
try {
$preamble = '<?xml encoding="utf-8" ? >';
$doc = new DOMDocument();
$doc->preserveWhiteSpace = true;
bikubi /
Created March 1, 2019 12:39
Simple Purgecss setup for Roots Sage WordPress starter theme


  1. Sage doesn't come with Purgecss (or uncss, etc.)
  2. Say, we use Bulma -- suddenly dist/main.css grows by 400K!
  3. Let's purge it!
  4. Oh dang, we need to whitelist /\.wp-/, /\.post-type/, /myfancylightbox/...
  5. Wait we are whitelisting pretty much everything from /resource/assets/styles!
  6. Isn't there an option to purge /node_modules/**/* only?
  7. Nope.
  8. purgecss start ignore, strategically placed, to the rescue!
bikubi /
Last active March 26, 2021 12:42
Control a web radio stream on a Raspi with GPIO, a button and an LED.
#!/usr/bin/env python
import subprocess as sp
import RPi.GPIO as g
import time
import os
# see
# & listen to WFMU!
bikubi /
Created August 1, 2018 04:38
Correct Horse Battery: The Band
# see for what this is all about.
mkdir -v q
for s in {1..1000}; do
# generate "passwords"
bikubi /
Last active March 3, 2021 15:04
Helper script for Roots' Sage starter theme: make WPML's String Translation see WordPress's l10n gettext function in PHP Blade templates, like {{ __('Foo', 'domain') }}
# Scans blade templates for WordPress's gettext functions
# so WPML will pick them up for its String Translation.
# (WPML doesn't see something like {{ __('Hello World', 'sage') }}
# Put me into THEME/resources/assets/build
# so $fn will point to THEME/resouces and WPML can see it
# (and it's out of sage's way)
bikubi / .htaccess
Created May 16, 2018 10:44
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
bikubi /
Last active November 12, 2018 06:13
How to record a nice sounding podcast over Skype, using Linux

How to record a nice sounding podcast over Skype, using Pulse and Ardour

The situation: we record a podcast over Skype. We both have USB audio interfaces (Behringer U-Phoria UMC202 and 404, respectively). We each record our respective audio inputs and mix those later, manually adjusting the delay. Skype is only used for communication and is not involved in the recording.

There might be a way to do this without ardour, pulse-only. But since we have ardour in our workflow already, we prefer this way, even if it seems needlessly complicated.

Tested on Arch Linux; all referenced programs refer to Arch packages.

bikubi / wordpress-force-cropped-intermediates.php
Last active March 21, 2018 12:27
Force WordPress to use cropped intermediates for cropped image_sizes to maintain aspect ratios.
/* Force wp_get_attachment_image_src to always pick a cropped intermediate size.
* If we define a sequence of srcset-friendly image_sizes like this:
* add_image_size('gallery', 1000, 750, true);
* add_image_size('gallery_1', 707, 530, true);
* add_image_size('gallery_2', 500, 375, true);
* then WordPress might pick the image's original, _uncropped_, size, which
* might have a wrong aspect ratio. To limit wp_get_attachment_image() to
* cropped intermediates with the right aspect ratio only, we have to manually
* check the availability of the files.