Skip to content

Instantly share code, notes, and snippets.


Markus Linnala maage

View GitHub Profile
maage /
Last active November 25, 2022 20:23 — forked from april/
bash function for git log as JSON
# attempting to be the most robust solution for outputting git log as JSON,
# using only bash shell syntax, `git`, `sed` and `tr`.
# - uses traditional JSON camelCase
# - includes every major field that git log can output, including the body
# - proper sections for author, committer, and signature
# - multiple date formats (one for reading, ISO for parsing)
# - properly handle body values, even those that contain quotation marks and
# escaped characters
# - outputs as minimized JSON, can be piped to `jq` for pretty printing
maage / rtc-ds3231-ubuntu-19.10-rpi4.txt
Created January 19, 2020 19:51
High Accuracy Pi RTC (DS3231) installation in Ubuntu 19.10 in Raspberry Pi 4 Model B Rev 1.1
View rtc-ds3231-ubuntu-19.10-rpi4.txt
Base instructions are here:
But I've diverted my setup procedure somewhat because Ubuntu boot setup is different than Raspbian and setup does some things not needed.
To use RTC early in the boot add "fixrtc" to kernel boot command line. Correct file is "/boot/firmware/nobtcmd.txt".
This is implemented in "/usr/share/initramfs-tools/scripts/local-premount/fixrtc".
maage /
Last active November 18, 2018 19:54
How to handle \0 in bash
set -x
declare -a str
read_w_null() {
local a
while [ 1 = 1 ]; do
if IFS= read -r -d '' a; then
maage /
Last active November 16, 2018 12:18
Fix %config(noreplace) files without reinstalling package

You can fix %config(noreplace) files without deleting and reinstalling. If package is not essential, it is easiest way. But for every essentia package/config file it is not recommended to remove them.

Run this as root to preserve users and other stuff. Download package. Unpack it. Move files to fix over old ones. You need also to copy selinux context and maybe capabilities. Cpio does not know about them. You need to set them by hand before moving file in place.

You also need to copy file attributes, extended attributes and ACL entries if there is some.

sudo -i
maage / wpa_cli-raspbian9-example.txt
Last active October 25, 2022 16:38
wpa_cli with raspberrypi 3 raspbian 9 / stretch
View wpa_cli-raspbian9-example.txt
# You can use tab and partial match if unique
# show encoded passphrases
% wpa_passphrase 'SSID1' 'pass1'
% wpa_passphrase 'SSID2' 'pass2'
# Without these this data is saved into history file
# Need to define interface as /run/wpa_supplicant/ has p2p-dev-wlan0 to mess things up
% sudo wpa_cli -i wlan0
# If status is DISCONNECT, then you have device wrong or something wrong with the device.
maage / gist:c2c99571a17323466f02
Created March 6, 2016 20:46
Unstuck chrome after screenlock
View gist:c2c99571a17323466f02
# [13691:13691:0306/] glXGetSyncValuesOML should not return TRUE with a media stream counter of 0.
pkill -HUP -f '/chrome --type=gpu-process'