Skip to content

Instantly share code, notes, and snippets.

View geraldnilles's full-sized avatar

Gerald Nilles geraldnilles

  • Los Angeles, CA
View GitHub Profile
@geraldnilles
geraldnilles / README.md
Last active October 12, 2025 15:53
Simple Wifi Manager

Simple Wifi Manager

This is a simple bash script and systemd system file for manging mulitple wifi connections on linux. This allows me to maintain a very simple wifi connection state machine that is easy to understand, debug, and customize.

The bash script will look through all conf files in the wpa_supplicant directory, find the highest priority conf where the SSID matches, adjust the wpa_supplicant config, and restart the wpa_supplicant service.

The systemd service is configured to run 5-seconds after resuming from suspend.

Requirements

@geraldnilles
geraldnilles / 0-README.md
Last active July 19, 2022 22:34
Nanit Fabric Pattern

Nanit Fabric Pattern

The Nanit Smart Baby Monitor can monitor your baby's breathing using a CV algorithm. However, it requires a very specific pattern. Nanit sells baby cloths with this pattern, but my daughter was quite particular about the type of swaddle she sleeps in. Nanit sells a strap that you can put over other clothing, but for saftey reasons, you are not supposed to use it with swaddles. If you put the strap over swaddled arms, the strap could shimmy up over the baby's face overnight. To get around this, i ended up sewing the pattern directly to the brand of swaddle she liked. This worked pretty well.

Since sewing is slightly more permanent than velcro, I'll have to sew the strap to multiple different swaddles. I could buy additional straps for $20 a peice, but that can get expensive quickly. Instead, i found that there are many different websites that will print fabric patterns for you and print and ship a full yard of fabric fo

@geraldnilles
geraldnilles / 0-README.rst
Last active July 16, 2022 18:40
Using my COVID Test as an NRF52 EVK

Using my COVID Test as an NRF52 EVK

Background

A few weeks ago, I was in desperate need of a COVID test and the only one in stock at the store was the Ellume_ COVID Test. This test uses a smartphone to analyze the results and uses bluetooth to communicate. It was 25 USD and i was not happy about it, but what are you going to do?. Turns out this test is absolute trash. The Android App crash loops making the test unusable. I ended my using my wife's iPhone to test myself. When i was done, I decided to take it appart. Turns out, it is just a regular covid test (the strip with 2 lines), a few LEDs, a photodiode, and an NRF52 microcontroller. It basically just does what a normal human is capable of doing: make sure the control line is present and use the Test line to see if you are negative or positive. Completely overengineered.

In order to make me feel better about this terrible purchase, I figured i'd reverse engineer the schematic and use this COVID test as a bluetooth capabl

@geraldnilles
geraldnilles / README.rst
Last active October 8, 2022 03:30
Raspberry Pi SD Card Image Backup

Raspberry Pi SD Card Image Backup

This Gist describes how to backup and restore Raspberry Pi SD Card Images.

Motivation

I currently have Arch Linux running on a Raspberry Pi acting as my home network's public frontend. The router firewall is forwarding public ports to this device. It also manages my HTTPS certificates and keys. This Arch Linux OS was manually configured to my liking. If something went wrong with this Pi (i.e. fried SD card), i would like a way to quickly restore functionality without having to manually reconfigure everything.

@geraldnilles
geraldnilles / README.rst
Last active July 3, 2022 23:44
Decompressed Embedded mxfile from draw.io

Decompressed Embedded mxfile from draw.io

When exporting a document, Draw.IO lets you embed the actual Draw.IO XML file into the exported formats (PNG, SVG, PDF, etc..). This is a very compelling feature since i can push SVG images to my Github repo, view them directlhy in Github, and be able to easily modify the SVG file within github. I no longer need to manage the separate XML file.

THere are some usecases where i might want to programatically modify my XML file so it would be nice to have a programatic way to extract the XML from this SVG file.

The XML file is deflated when it is embedded in the metadata. This script was used to recover the actaul XML file.

Open the PNG or SVG data and extraxt the mxfile data. It is base64 encoded inside the header of the PNG, SVG and PDF files. Pase it in the script below.

@geraldnilles
geraldnilles / README.rst
Last active May 4, 2022 17:05
Read-only tmpfs overlay for entire rootfs using Arch Linux Arm on Raspberry Pi

Read-only tmpfs overlay for entire rootfs using Arch Linux Arm on Raspberry Pi

This inserts a few lines to the beginning of the init script that mounts the rootfs as Read-Only, and places a RW Ram-Disk overlay on top of the root. Any writes to the rootfs will be written to the volatile RAM memory and will not persist after reboot.

The goal is to prevent corruption of the rootfs on the Raspberry Pi during an unexpected power-loss. This is a good idea for any RPi projects that act as an "appliance" and perform a fixed function all day.

This can be applied to the vanilla ArchLinuxArm installation for the AARCH64 insalation: https://archlinuxarm.org/platforms/armv8/broadcom/raspberry-pi-4. This shoudl be performed after finishing configuration of the system.

This is based off of this Gist and adjusted to work with Arch on AARCH64: https://gist.github.com/paul-ridgway/d39cbb30530442dca416734c3ee70162