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 / 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 / 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 / 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 / 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 / andref.cpp
Last active September 5, 2024 22:13
Misusing C++ alternative tokens
#include <utility>
class my_class {
public:
compl my_class() {} // Destructor
};
int main() {
my_class example_obj;
my_class bitand example_ref = example_obj;
@ObjectBoxPC
ObjectBoxPC / makepassword.sh
Last active August 15, 2024 06:38
Quickly generate random passwords using built-in utilities (emulating Python's secrets.token_urlsafe: https://gist.github.com/ObjectBoxPC/89206ca79bb26fdc2112233ede121d9d )
#!/bin/sh
ENTROPY_BYTES=16
dd if=/dev/urandom bs="$ENTROPY_BYTES" count=1 2> /dev/null | \
base64 -w 0 | sed 's/=//g; s/+/-/g; s/\//_/g'
echo
@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 / 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;