Skip to content

Instantly share code, notes, and snippets.

View idcrook's full-sized avatar

David Crook idcrook

View GitHub Profile
@smittytone
smittytone / dlist.zsh
Last active September 12, 2022 18:48
Z Shell function for macOS which detects and lists USB-connected serial devices
# Add to your `.zshrc` file or use the function's contents as a script.
#
# With the former, add the function, restart your terminal, connect
# a USB serial device, eg. a Raspberry Pi Pico, and then enter `dlist`
# at the command line.
#
# You should see something like this:
# `/dev/cu.usbserial-01AB8E0B`
#
# If you have only one device attached, you can include the function's
@drewkerr
drewkerr / get-focus-mode.js
Last active April 4, 2025 04:29
Read the current Focus mode on macOS Monterey (12.0+) using JavaScript for Automation (JXA)
const app = Application.currentApplication()
app.includeStandardAdditions = true
function getJSON(path) {
const fullPath = path.replace(/^~/, app.pathTo('home folder'))
const contents = app.read(fullPath)
return JSON.parse(contents)
}
function run() {
@codebytes
codebytes / DevMachineSetup.ps1
Last active January 2, 2025 02:42
DevMachineSetup
#Install WinGet
#Based on this gist: https://gist.github.com/crutkas/6c2096eae387e544bd05cde246f23901
$hasPackageManager = Get-AppPackage -name 'Microsoft.DesktopAppInstaller'
if (!$hasPackageManager -or [version]$hasPackageManager.Version -lt [version]"1.10.0.0") {
"Installing winget Dependencies"
Add-AppxPackage -Path 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
$releases_url = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
@akagr
akagr / em.scpt
Last active June 14, 2024 03:46
MacOS launch helper to start emacs daemon or attach to one
-- ███████╗███╗░░░███╗░█████╗░░█████╗░░██████╗
-- ██╔════╝████╗░████║██╔══██╗██╔══██╗██╔════╝
-- █████╗░░██╔████╔██║███████║██║░░╚═╝╚█████╗░
-- ██╔══╝░░██║╚██╔╝██║██╔══██║██║░░██╗░╚═══██╗
-- ███████╗██║░╚═╝░██║██║░░██║╚█████╔╝██████╔╝
-- ╚══════╝╚═╝░░░░░╚═╝╚═╝░░╚═╝░╚════╝░╚═════╝░
--
-- Open this script with 'Script Editor' on MacOS, then save it
-- inside /Applications as an 'Application', not 'Script'.
@Hermann-SW
Hermann-SW / SerialHttpsClient.ino
Created March 22, 2021 21:46
ESP01 sketch taking HTTPS GET URLs from Pico over serial, returning response to Pico
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <WiFiClientSecureBearSSL.h>
ESP8266WiFiMulti WiFiMulti;
@maxmacstn
maxmacstn / main.py
Last active February 21, 2025 01:43
Raspberry Pi Pico - CircuitPython volume knob
import digitalio
import board
import usb_hid
import time
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.mouse import Mouse
from adafruit_hid.keycode import Keycode
from adafruit_hid.consumer_control import ConsumerControl
from adafruit_hid.consumer_control_code import ConsumerControlCode
@enlavin
enlavin / main.py
Last active December 11, 2024 00:09
KMK circuitpython macropad firmware
import board
#from kmk.kmk_keyboard import KMKKeyboard
#from kmk.matrix import DiodeOrientation
#from kmk.keys import KC
# Updated to be compatible with the latest KMK release (which requires CircuitPython >= 7.0)
from kmk.kmk_keyboard import KMKKeyboard
from kmk.keys import KC
from kmk.scanners import DiodeOrientation
@AloisJanicek
AloisJanicek / org-protocol-to-wsl-emacs.reg
Created November 29, 2020 22:44
Org-protocol setup with emacs inside WSL
REGEDIT4
[HKEY_CLASSES_ROOT\org-protocol]
@="URL:Org Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\org-protocol\shell]
[HKEY_CLASSES_ROOT\org-protocol\shell\open]
[HKEY_CLASSES_ROOT\org-protocol\shell\open\command]
@="\"C:\\BIN\\org-protocol-to-wsl-helper.bat\" \"%1\""
@ednisley
ednisley / Helmet Mirror Mount - Ball.scad
Created September 13, 2020 17:45
OpenSCAD source code: Bike helmet mirror mount with ball clamp
// Bike helmet mirror mount - ball joint
// Ed Nisley KE4ZNU 2020-09
/* [Layout options] */
Layout = "Build"; // [Build, Show, Plate, Base, Clamp]
//-- Extrusion parameters
// Extrusion parameters
@kopwei
kopwei / k3s-cluster.md
Last active December 20, 2024 22:21
K3s and Rancher on Raspberry Pi 4 Cluster

Deploy K3s and Rancher on Raspberry Pi 4 cluster

Today I tried to setup a small Kubernetes cluster on top of 3 Raspberry Pi 4 (4GB Memory). Here is the steps to install the cluster.

IMG_3817

Preparation

I have 3 Raspberry Pi 4 stacked with PoE headers and connected to a PoE switch at home. The are connected to Internet through a home router. All Pis are equipped with a 64GB Samsung SDXC card flushed with Ubuntu 20.04 image.