Skip to content

Instantly share code, notes, and snippets.

@Jachimo
Jachimo / piflavor.py
Created June 29, 2023 21:49
PiFlavor: Report model and version of a Raspberry Pi programmatically
#!/usr/bin/env python3
# Script to check the hardware version of a Raspberry Pi
# REQUIRES PYTHON 3.5+
import sys
# Following information based on https://elinux.org/RPi_HardwareHistory
pi_revisions = {
'9020' : '3 Model A+ (Sony, UK)',
'900021' : 'A+ (Sony, UK)',
@Jachimo
Jachimo / straightline_noise.pde
Last active August 6, 2018 05:06
Perlin noise in 2 dimensions using Processing 3.x, displayed using straight lines arranged in a grid
import processing.svg.*;
/* Example of Perlin noise in 2 dimensions represented using short straight lines */
// SET THESE
public static final int numCols = 10;
public static final int numRows = 50;
public static final float diameter = 50; // diameter in pixels (or line length)
public static final int max_loops = 3;
static int loopcount = 0;
@Jachimo
Jachimo / grid.pde
Last active August 6, 2018 00:44
Draw a 2D grid of objects, filling the viewport, using Processing 3.x
import processing.svg.*; // for SVG output
// SET THESE
int numCols = 50;
int numRows = 50;
void setup() {
size(500, 500); // for screen display
//size(864, 864, SVG, "new.svg"); // 9in x 9in SVG
background(255);
@Jachimo
Jachimo / README.md
Created June 2, 2018 02:29
Using ZeroTier to route between two UniFi USG LANs

Routing between two UniFi USG based LANs with ZeroTier

Intro

This is a quick explanation of how to configure both ZeroTier and two Ubiquiti UniFi USGs to allow routing between two IPv4 networks. Both networks are in private (RFC1918) address space and each one has its own DHCP service. There is no need for NAT between them, only IP routing.

The two networks are 192.168.1.0/24 (call this the "left" network) and 192.168.10.0/24 (the "right" network) but they can be anything. Also, you can have multiple CIDR blocks on one side or the other of the ZeroTier route; if you do, you just have to create more routing table entries.

@Jachimo
Jachimo / README.md
Created May 27, 2018 05:08
systemd init scripts for running Deluge on Debian 8

These are a couple of files to assist in getting Deluge running as a service (daemon) on Debian 8. There doesn't seem to be much in the way of good documentation for this online right now.

Basically, you want to follow the steps on this page, but use the scripts above, because they have the correct user and group IDs for Debian. Also, ignore the "User Management" section, since that is already done as part of the installation if you use apt-get:

But in case that page goes offline, here's the very short version:

@Jachimo
Jachimo / install-zerotier.cmd
Created May 26, 2018 18:41
One-line command for installing Zerotier on Linux that actually works (no MIT keyserver)
curl -s 'https://pgp.key-server.io/pks/lookup?op=get&search=0x1657198823E52A61' | gpg --import && if z=$(curl -s 'https://install.zerotier.com/' | gpg); then echo "$z" | sudo bash; fi
@Jachimo
Jachimo / flush_dns.sh
Created September 7, 2017 18:13
Mac-only commands for forcing a flush of the DNS cache
#!/usr/bin/env bash
sudo dscacheutil -flushcache
sudo killall -HUP mDNSResponder
logger "DNS cache manually flushed by $0"
@Jachimo
Jachimo / pingtest.sh
Last active September 7, 2017 18:06
Ugly but useful hack to repeatedly (at a broad interval, e.g. 10s or 30s) ping a server and log whether it replied. Does not use cron.
#!/usr/bin/env bash
## Sends a ping to a server and writes a failure or success log message
## Logs results to syslog; find and filter in Console, search for "PINGTEST"
# Change this as needed, must be server that responds to pings
PINGDEST=192.168.1.1
# Interval in seconds to send a ping (e.g. send every X seconds)
INTERVAL=10
@Jachimo
Jachimo / keybase.md
Created August 4, 2017 16:49
Keybase identity proof

Keybase proof

I hereby claim:

  • I am jachimo on github.
  • I am jwt (https://keybase.io/jwt) on keybase.
  • I have a public key ASBOdDl-_RIF8gXMr1MzM_3YuCm_trfewAw70pvNisCXXgo

To claim this, I am signing this object: