Skip to content

Instantly share code, notes, and snippets.

@JamesTheBard
JamesTheBard / i3lock_pixelate
Created June 8, 2013 00:04
The cool pixelated i3lock script provided by Steffan Honig.
#!/bin/bash
#
# This is an easier-to-tweak version of Steffen Honig's i3lock
# script. If it doesn't work, it's his fault ;)
#
TEMP_FILE=/tmp/lock.png
TEMP_FILE_POST=/tmp/lock.modified.png
BAR_BG_COLOR="orange"
BAR_FONT_COLOR="white"
BAR_FONT="Source-Code-Pro-Black"
@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 / 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 / eventcmd
Created June 10, 2013 06:21
mcabber notification script
#!/bin/sh
echo "$1 $2 $3 $4" >> ~/test.mcabber.log
EVENT_TYPE=$1
EVENT_SUBTYPE=$2
JID=$3
FILE=$4
TITLE="Google Hangouts"
SOUND_FILE="$HOME/.mcabber/sounds/alert_47.wav"
ICON="$HOME/.mcabber/images/chat.png"
TIMEOUT=10000
@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 / download_tags.py
Created July 18, 2013 12:53
A quick update...
from django import template
from cms_downloads.models import FileRevisions
import os
register = template.Library()
def get_latest_download_by_name(file_name):
download_query = FileRevisions.objects.filter(name__name__startswith=filename).order_by('-version')[0]
if download_query.count == 0: download_query = None
return {'cms_download': download_query}
@JamesTheBard
JamesTheBard / clipcp
Last active December 18, 2015 05:39
Clipboard copy script for files.
#!/bin/bash
# Display some help text
usage() {
echo "clipcp - Copy the contents of a text file to the clipboard";
echo "Usage: clipcp FILE";
}
# 'Cat' the file and pipe it into the xsel program which throws whatever
# it gets onto the clipboard.
@JamesTheBard
JamesTheBard / get_song_mpd
Last active December 18, 2015 03:38
Perl script to grab mpd status and information.
#!/usr/bin/env perl
use Switch;
# Grab the first line from 'mpc' and throw it into
@song = split("\n", `mpc 2>&1`);
switch ($song[0]) {
case /Connection refused/ { print "MPD not running\n" }
case /^volume/ { print "Music playback stopped\n"}