Skip to content

Instantly share code, notes, and snippets.

View JChristensen's full-sized avatar
💭
Never test for an error condition that you don't know how to handle.

Jack Christensen JChristensen

💭
Never test for an error condition that you don't know how to handle.
View GitHub Profile
@JChristensen
JChristensen / luks-setup.md
Last active October 28, 2023 13:00
Encrypt an external disk or USB stick with LUKS

Encrypt an external disk or USB stick with LUKS

J.Christensen
Oct-2023

Introduction

This document describes how to create an encrypted volume using the Linux Unified Key Setup (LUKS) facility. We will create a single encrypted partition that takes up the entire device. The main aim is to create an encrypted external disk or USB stick, for backup purposes or just general offline, secure storage.

Warning!

Always be very careful when executing low-level device commands. Be sure to use the correct device or partition. Mistakes can, and most likely will, result in unrecoverable data loss.

@JChristensen
JChristensen / tbird-chrome.sh
Last active November 4, 2023 19:31
Bash script to create the userChrome.css file for Thunderbird v115 and restore the Menu Bar to its rightful place above the Unified Toolbar. Written for Linux Mint, should also work on Ubuntu and other Debian derivatives.
#!/bin/bash
# Create the userChrome.css file for Thunderbird to restore
# the Menu Bar to its rightful place above the Unified Toolbar.
# Run this script from the Thunderbird profile folder, usually something like
# ~/.thunderbird/xxxxxxxx.default/ or ~/.thunderbird/xxxxxxxx.default-release
# where "xxxxxxxx" is a random alphanumeric string.
# Thunderbird must not be running to use this script.
# From https://support.mozilla.org/en-US/questions/1422908, H/T to Toad-Hall.
# J.Christensen 04Oct2023
@JChristensen
JChristensen / fix-machine-id.sh
Created January 9, 2023 00:52
Script to generate unique machine ID for Linux Mint.
#!/bin/bash
# Regenerate /etc/machine-id and delete IPv6 lease information.
# Use this script to ensure unique machine IDs on each machine
# after installing Linux Mint.
# See https://github.com/linuxmint/linuxmint/issues/126
# and https://github.com/linuxmint/linuxmint/issues/361
#
# Copyright (C) 2019-2023 by Jack Christensen and licensed under
# GNU GPL v3.0, https://www.gnu.org/licenses/gpl.html
#
// Arduino DS3232RTC Library
// https://github.com/JChristensen/DS3232RTC
// Copyright (C) 2018 by Jack Christensen and licensed under
// GNU GPL v3.0, https://www.gnu.org/licenses/gpl.html
//
// Arduino library for the Maxim Integrated DS3232 and DS3231
// Real-Time Clocks.
// Requires PJRC's improved version of the Arduino Time Library,
// https://playground.arduino.cc/Code/Time
// https://github.com/PaulStoffregen/Time

A small UPS for a Raspberry Pi

https://gist.github.com/JChristensen/10470affa2ec984d4cac7ef70f16b7c2
Jack Christensen
May 2021

I recently purchased a PowerBoost 1000 and a 2500mAh LiPo battery from Adafruit to use as a small uninterruptible power supply (UPS) for a Raspberry Pi.

From a little testing, I could tell that the setup would power a Pi Zero W for quite some time, but I wasn't sure how long. Christopher Barnatt's recent Explaining Computers video inspired me to find out.

I set up a Pi Zero W as a headless machine with the latest version of Raspberry Pi OS Lite (04Mar2021).

@JChristensen
JChristensen / LCDLibBench.ino
Last active August 29, 2015 14:02
Liquid Crystal Library Benchmark
//Liquid Crystal Library Benchmark
//Jack Christensen 21Jun2014
//Standard Arduino library http://arduino.cc/en/Reference/LiquidCrystal
//FMalpartida library http://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home
//AFI library http://github.com/adafruit/LiquidCrystal
//Falcon Four library http://forums.adafruit.com/viewtopic.php?f=19&t=21586&p=113177
//Benchmark results, time to write 2 x 16-character lines to LCD.
//Run on 16MHz Arduino Uno compatible, Arduino v1.0.5.
//Library Mode Time Sketch Size
@JChristensen
JChristensen / mighty-1284p_v1.0.diff
Created May 2, 2014 18:59
Changes made to the Arduino 1.0 core files for maniacbug's mighty-1284p core.
diff --git a/arduino-1.0/hardware/arduino/cores/arduino/Arduino.h b/mighty-1284p/cores/standard/Arduino.h
index ebd374a..2e35a35 100644
--- a/arduino-1.0/hardware/arduino/cores/arduino/Arduino.h
+++ b/mighty-1284p/cores/standard/Arduino.h
@@ -45,7 +45,7 @@ extern "C"{
#define EXTERNAL 1
#define INTERNAL 2
#else
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284P__)
@JChristensen
JChristensen / LiquidTWI_test.ino
Created April 30, 2014 19:50
Testing Falcon Four's LiquidTWI library
#include <LiquidCrystal.h> //http://github.com/adafruit/LiquidCrystal
#include <LiquidTWI.h> //http://forums.adafruit.com/viewtopic.php?f=19&t=21586&p=113177
#include <Wire.h> //http://arduino.cc/en/Reference/Wire
#include <Streaming.h> //http://arduiniana.org/libraries/streaming/
//Comment one of the following two lines:
//LiquidCrystal lcd(0); //i2c address 0 (0x20)
LiquidTWI lcd(0); //i2c address 0 (0x20)
void setup(void)
@JChristensen
JChristensen / AVR Sleep
Last active August 15, 2024 14:22
AVR microcontroller sleep demonstrations
Simple demonstrations of putting AVR microcontrollers to sleep in power-down mode,
which results in minimum current. Coded with Arduino IDE version 1.0.4 (and with
the Arduino-Tiny core for the ATtiny MCUs, http://code.google.com/p/arduino-tiny/)
For ATmega328P, ~0.1µA.
For ATtinyX5 revisions that implement software BOD disable, ~0.1µA,
for ATtinyX5 revisions that don't, ~20µA.