Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
Tea, Earl Grey, hot.

Jeff Geerling geerlingguy

:shipit:
Tea, Earl Grey, hot.
View GitHub Profile
@geerlingguy
geerlingguy / setup.yml
Created Dec 27, 2022
Pi Rack Pro setup script for the Pis in the Pi Rack Pro
View setup.yml
# Run this playbook with ansible-playbook -i inventory setup.yml
# In the inventory file, create a group named [rpi] with all the Pis in it
---
- hosts: rpi
become: true
vars:
lcd_library_repo: 'https://github.com/geerlingguy/SKU_RM0004.git'
lcd_library_version: 'jeff-custom'
@geerlingguy
geerlingguy / handbrake-batch.sh
Created Oct 24, 2022
Handbrake CLI batch transcoding script
View handbrake-batch.sh
#!/bin/bash
#
# This script requires HandBrakeCLI. On macOS, at least, you need to download
# and install it separately from Handbrake.
#
# See: https://handbrake.fr/downloads2.php
if [ -z "$1" ] ; then
TRANSCODEDIR="."
else
@geerlingguy
geerlingguy / cache-purge.yml
Last active Nov 30, 2022
Cache purge script to clear Nginx + Cloudflare cache for a given set of URLs.
View cache-purge.yml
---
- hosts: webserver
become: true
gather_facts: false
vars:
# API token should be created with cache_purge permissions.
cloudflare_purge_zone: [zone id from cloudflare]
cloudflare_purge_token: "{{ lookup('env','CLOUDFLARE_PURGE_TOKEN') }}"
cloudflare_purge_body:
@geerlingguy
geerlingguy / stable-diffusion-webui-on-ubuntu.txt
Last active Oct 14, 2022
Install Stable Diffusion WebUI on Ubuntu 22.04 with Nvidia GPU
View stable-diffusion-webui-on-ubuntu.txt
# First install Docker and docker-compose following this guide:
# https://docs.docker.com/engine/install/ubuntu/
#
# Make sure you add your user to the `docker` group:
sudo usermod -aG docker $USER
# ...then log out and log back in to make that take effect. (I actually had to reboot, le sigh)
# Second install the NVIDIA Container Toolkit following this guide:
# https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#setting-up-nvidia-container-toolkit
@geerlingguy
geerlingguy / stable-diffusion-ubuntu-2204-nvidia
Last active Oct 10, 2022
Install Stable Diffusion on an Nvidia GPU PC running Ubuntu 22.04
View stable-diffusion-ubuntu-2204-nvidia
# Note: This will only work on (which?) GPUs.
# Install Conda (latest from https://docs.conda.io/en/latest/miniconda.html#linux-installers)
wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh
bash Miniconda3-py39_4.12.0-Linux-x86_64.sh
# follow the prompts, restart your Terminal session, and run `conda` to confirm it installed.
# Install git and curl, and clone the stable-diffusion repo
sudo apt install -y git curl
cd Downloads
@geerlingguy
geerlingguy / stable-diffusion-ubuntu-2004-amd.sh
Last active Dec 3, 2022
Install Stable Diffusion on an AMD GPU PC running Ubuntu 20.04
View stable-diffusion-ubuntu-2004-amd.sh
# Note: This will only work on Navi21 GPUs (6800/6900+).
# See: https://github.com/RadeonOpenCompute/ROCm/issues/1668#issuecomment-1043994570
# Install Conda (latest from https://docs.conda.io/en/latest/miniconda.html#linux-installers)
wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh
bash Miniconda3-py39_4.12.0-Linux-x86_64.sh
# follow the prompts to install it, and run `conda` to make sure it's working.
# Install git and curl, and clone the stable-diffusion repo
sudo apt install -y git curl
@geerlingguy
geerlingguy / arducam-hawk-eye-setup.sh
Last active Nov 14, 2022
ArduCam Hawk-Eye 64MP camera setup
View arducam-hawk-eye-setup.sh
# Download the pivariety driver install script and make it executable
wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
chmod +x install_pivariety_pkgs.sh
# Install libcamera dev and apps
./install_pivariety_pkgs.sh -p libcamera_dev
./install_pivariety_pkgs.sh -p libcamera_apps
# Install the Hawk-Eye kernel driver
./install_pivariety_pkgs.sh -p 64mp_pi_hawk_eye_kernel_driver
@geerlingguy
geerlingguy / cm4-fan.sh
Last active Apr 30, 2022
Fan controller script for the CM4 IO Board EMC2301 and PWM fans
View cm4-fan.sh
#!/bin/bash
#
# Jeff Geerling's super-rudimentary fan controller script for the CM4.
#
# Use:
# 1. Download this script to a path like `/opt/cm4-fan.sh`
# 2. Run it with: `nohup bash /opt/cm4-fan.sh`
# 3. Profit!
#
# You should wrap it in a systemd unit file if you want it to persist and come
@geerlingguy
geerlingguy / systembuttons.py
Last active Oct 17, 2021
Python 3 version of Null 2 systembuttons.py
View systembuttons.py
#!/usr/bin/python3
# Shutdown and volume control
import keyboard
import time
import os
INITIAL_VOLUME = "25%"
def shutdown():
@geerlingguy
geerlingguy / photogrammetry.sh
Last active May 24, 2021
Photogrammetry automation script using COLMAP and OpenMVS
View photogrammetry.sh
#!/bin/bash
# Photogrammety automation script.
#
# Based on https://peterfalkingham.com/2018/04/01/colmap-openmvs-scripts-updated/
# Adapted from https://www.instructables.com/Free-Photogrammetry-on-Mac-OS-From-Photos-to-3D-Mo/
#
# See full guide on Jeff Geerling's blog:
# TODO
#
# Usage: