Skip to content

Instantly share code, notes, and snippets.

@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),
@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 / 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 / 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 / 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 / error_log.txt
Created October 20, 2015 18:40
Passenger Watchdog Apache2 output
[Tue Oct 20 18:24:44 2015] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[ 2015-10-20 18:24:45.0178 17289/1 age/Wat/WatchdogMain.cpp:1275 ]: Starting Passenger watchdog...
[ pid=17289, timestamp=1445365485 ] Process aborted! signo=SIGBUS(10), reason=BUS_ADRALN, si_addr=0x6a918f, randomSeed=1445365485
[ pid=17289 ] Crash log dumped to /var/tmp/passenger-crash-log.1445365485
[ pid=17289 ] Date, uname and ulimits:
Tuesday, October 20, 2015 06:24:45 PM UTC
SunOS 5.11 11.2 sun4v sparc
address space limit (kbytes) (-M) unlimited
core file size (blocks) (-c) unlimited
cpu time (seconds) (-t) unlimited
@JamesTheBard
JamesTheBard / error-log.txt
Created October 18, 2015 19:40
`passenger-status` output
/usr/ruby/1.9/lib/ruby/gems/1.9.1/gems/passenger-5.0.20/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb:64:in `flock': Bad file number - /tmp/passenger.nIYEc1p/lock (Errno::EBADF)
from /usr/ruby/1.9/lib/ruby/gems/1.9.1/gems/passenger-5.0.20/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb:64:in `block in locked?'
from /usr/ruby/1.9/lib/ruby/gems/1.9.1/gems/passenger-5.0.20/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb:63:in `open'
from /usr/ruby/1.9/lib/ruby/gems/1.9.1/gems/passenger-5.0.20/src/ruby_supportlib/phusion_passenger/admin_tools/instance.rb:63:in `locked?'
from /usr/ruby/1.9/lib/ruby/gems/1.9.1/gems/passenger-5.0.20/src/ruby_supportlib/phusion_passenger/admin_tools/instance_registry.rb:48:in `block (2 levels) in list'
from /usr/ruby/1.9/lib/ruby/gems/1.9.1/gems/passenger-5.0.20/src/ruby_supportlib/phusion_passenger/admin_tools/instance_registry.rb:44:in `each'
from /usr/ruby/1.9/lib/ruby/gems/1.9.1/gems/passe
@JamesTheBard
JamesTheBard / stdout_and_stderr.log
Created September 23, 2015 05:19
Passenger Run with EXTRA_CXXFLAGS=-DBOOST_MATH_DISABLE_STD_FPCLASSIFY environment variable.
Welcome to the Phusion Passenger Apache 2 module installer, v5.0.18.
This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.
Here's what you can expect from the installation process:
1. The Apache 2 module will be installed for you.
2. You'll learn how to configure Apache.
3. You'll learn how to deploy a Ruby on Rails application.
@JamesTheBard
JamesTheBard / stdout_and_stderr.log
Created September 23, 2015 04:39
Passenger compile run (Solaris 11.2/Ruby 1.9.3/Passenger 5.0.18)
Welcome to the Phusion Passenger Apache 2 module installer, v5.0.18.
This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.
Here's what you can expect from the installation process:
1. The Apache 2 module will be installed for you.
2. You'll learn how to configure Apache.
3. You'll learn how to deploy a Ruby on Rails application.
@JamesTheBard
JamesTheBard / gist:33567801b63aa8d96c34
Created September 22, 2015 00:54
Error log for passenger build (5.0.18/Solaris 11.2/Ruby 1.9.3)
In file included from ext/boost/system/system_error.hpp:14:0,
from ext/boost/thread/exceptions.hpp:22,
from ext/boost/thread/pthread/thread_data.hpp:10,
from ext/boost/thread/thread_only.hpp:17,
from ext/boost/thread/thread.hpp:12,
from ext/boost/thread.hpp:13,
from ext/oxt/thread.hpp:28,
from ext/common/agent/UstRouter/UstRouterMain.cpp:30:
ext/boost/system/error_code.hpp:222:36: warning: ‘boost::system::posix_category’ defined but not used [-Wunused-variable]
static const error_category & posix_category = generic_category();