Skip to content

Instantly share code, notes, and snippets.

@JamesTheBard
JamesTheBard / apc_mini_output_mido.py
Last active November 15, 2018 09:11
AKAI APC Mini with Mido
# So, you want to turn some buttons on...
import mido
from mido import Message
# We're aiming for some specific values. The hex for turning a light green
# is pretty simple: 90 <button> <state>. The '90' is the MIDI command
# for 'note_on'. The 'note_on' command has two values that come after it:
# the note and it's velocity. Since this is a controller, it uses the note
# to signify which button to adjust, and it uses velocity to tell it how to
@JamesTheBard
JamesTheBard / set_ntp_settings.yaml
Last active January 29, 2024 14:55
Configure NTP Client for `timedatectl` via `systemd-timesyncd`
# vim:ts=2:sts=2:sw=2:et
#===========================================================
# NTP Configuration Playbook
#===========================================================
# This script will remove the 'ntp' daemon from each server
# and properly configure the 'systemd-timesyncd' daemon so
# that 'timedatectl' uses a specific NTP server. Remember
# to create a 'timesyncd.conf' file that holds your config
# in the same directory as this ansible playbook before
# running.
@JamesTheBard
JamesTheBard / main.cpp
Created October 25, 2022 01:14
How does one track states?
#include <Arduino.h>
#include <Serial.h>
#define THRESHOLD 1.23
String states[4] = {
"Ready to dock", // Phone is not in cradle || !ps1 & !ps2 & !ds
"Docking", // Phone is docking || ps1 & ps2 & !ds
"Is Docked", // Phone is docked in cradle || ps1 & ps2 & ds
"Ejecting" // Phone is ejecting || ps1 & ps2 & !ds
@JamesTheBard
JamesTheBard / 2022-day17.py
Created November 29, 2023 15:33
Day 17 of the Advent of Code 2022
from pathlib import Path
from typing import Union
from itertools import cycle
from dataclasses import dataclass
rocks = [
[0b00000, 0b00000, 0b00000, 0b11110],
[0b00000, 0b01000, 0b11100, 0b01000],
[0b00000, 0b00100, 0b00100, 0b11100],
[0b10000, 0b10000, 0b10000, 0b10000],
@JamesTheBard
JamesTheBard / 2022-day18.py
Created November 29, 2023 18:56
Day 18 of the Advent of Code 2022
from itertools import combinations as comb
from pathlib import Path
from typing import Union
adjacent = [
(1, 0, 0),
(0, 1, 0),
(0, 0, 1),
(-1, 0, 0),
(0, -1, 0),