Skip to content

Instantly share code, notes, and snippets.

View ObjectBoxPC's full-sized avatar

Philip Chung ObjectBoxPC

View GitHub Profile
@ObjectBoxPC
ObjectBoxPC / dvdbackup.Dockerfile
Created March 26, 2025 07:56
Rip DVDs from a Docker container
FROM debian:12-slim
RUN ["sed", "-i", "s/^Components: .*/Components: main contrib/", "/etc/apt/sources.list.d/debian.sources"]
RUN apt-get update && apt-get install -y libdvd-pkg dvdbackup
RUN ["dpkg-reconfigure", "libdvd-pkg"]
@ObjectBoxPC
ObjectBoxPC / joplin-update.py
Created March 26, 2025 07:50
Automatically update Joplin from GitHub
#!/usr/bin/env python3
import hashlib
import json
import re
import shutil
import subprocess
import tempfile
import urllib.request
@ObjectBoxPC
ObjectBoxPC / ezdiscid.c
Last active February 18, 2025 23:52
Simple program to extract MusicBrainz disc IDs from CDs
#include <stdio.h>
#include <string.h>
#include <discid/discid.h>
static const char* get_device(int argc, char** argv);
int main(int argc, char** argv) {
DiscId* discid;
const char* device;
int read_successful;
@ObjectBoxPC
ObjectBoxPC / ungoogled-chromium-debian-update.py
Last active March 26, 2025 07:35
Automatically update ungoogled-chromium on Debian
#!/usr/bin/env python3
import json
import re
import shutil
import subprocess
import tempfile
import urllib.request
USER_AGENT = "Ungoogled-Chromium-Debian-Update/1.0"
@ObjectBoxPC
ObjectBoxPC / pwdshort.sh
Last active January 11, 2025 23:45
Print the working directory in a compact form (originally created for tmux status bar customization)
#!/bin/sh
# Print a compact version of the current working directory.
# The home directory is replaced with ~, and long paths are truncated to the final part with < as a marker.
# Examples:
# /home/example/Documents becomes ~/Documents
# /example/of/a/really/really/long/path becomes <ly/really/long/path
# The maximum length can be set using the LIMIT variable.
LIMIT=20
@ObjectBoxPC
ObjectBoxPC / anagram.hs
Created October 18, 2023 12:45
Haskell program to check if two inputs (command-line arguments) are anagrams (in terms of the 26 letters in the English alphabet)
import Data.Char (toUpper)
import Data.List (sort)
import System.Environment (getArgs)
import System.Exit (exitWith, ExitCode(..))
data CheckAnagramError = NotEnoughArguments | EmptyInput
isAnagram :: String -> String -> Bool
isAnagram x y = normalize x == normalize y
where
@ObjectBoxPC
ObjectBoxPC / sort-prt-bus-schedules.user.js
Last active December 13, 2024 08:01
Userscript to sort Pittsburgh Regional Transit bus schedules numerically
// ==UserScript==
// @name Sort Pittsburgh Regional Transit bus schedules numerically
// @version 3
// @match https://www.rideprt.org/all-schedules/
// @grant none
// ==/UserScript==
// This script is dedicated to the public domain under Creative Commons CC0 1.0 Universal
// <https://creativecommons.org/publicdomain/zero/1.0/>
@ObjectBoxPC
ObjectBoxPC / makepin.py
Last active June 3, 2024 22:13
Quickly generate random numeric PINs
#!/usr/bin/env python3
# Usage: ./makepin.py [number of digits, default 4]
import secrets
import sys
digit_count = int(sys.argv[1]) if len(sys.argv) >= 2 else 4
pin = secrets.randbelow(10**digit_count)
@ObjectBoxPC
ObjectBoxPC / ruby-regex-word-confusion.txt
Last active February 5, 2023 21:45
Confusion about Ruby Regexp \p{Word} character class
$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux-gnu]
$ irb
irb(main):001:0> /\p{Word}/.match?("\u00B2") # Expected to be true based on description of \p{Word} in Regexp docs
=> false
irb(main):002:0> /\p{Number}/.match?("\u00B2") # U+00B2 is a Number character
=> true
@ObjectBoxPC
ObjectBoxPC / direct-password-input-treasurydirect.user.js
Last active October 23, 2023 09:02
Userscript to enable direct password input on TreasuryDirect login
// ==UserScript==
// @name Enable Direct Password Input on TreasuryDirect
// @version 1
// @include https://www.treasurydirect.gov/*
// @grant none
// ==/UserScript==
document.querySelector('input.pwordinput').readOnly = false;