Skip to content

Instantly share code, notes, and snippets.

View ObjectBoxPC's full-sized avatar

Philip Chung ObjectBoxPC

View GitHub Profile
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)
View anagram.hs
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
ObjectBoxPC / sort-prt-bus-schedules.user.js
Last active October 7, 2023 14:28
Userscript to sort Pittsburgh Regional Transit bus schedules numerically
View sort-prt-bus-schedules.user.js
// ==UserScript==
// @name Sort Pittsburgh Regional Transit bus schedules numerically
// @version 2
// @include
// @grant none
// ==/UserScript==
// This script is dedicated to the public domain under Creative Commons CC0 1.0 Universal
// <>
ObjectBoxPC /
Created July 24, 2023 16:23
Quickly generate random numeric PINs
#!/usr/bin/env python3
# Usage: ./ [number of digits, default 4]
import secrets
import sys
if len(sys.argv) < 2:
digit_count = 4
ObjectBoxPC / ruby-regex-word-confusion.txt
Last active February 5, 2023 21:45
Confusion about Ruby Regexp \p{Word} character class
View ruby-regex-word-confusion.txt
$ 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 / direct-password-input-treasurydirect.user.js
Last active October 23, 2023 09:02
Userscript to enable direct password input on TreasuryDirect login
View direct-password-input-treasurydirect.user.js
// ==UserScript==
// @name Enable Direct Password Input on TreasuryDirect
// @version 1
// @include*
// @grant none
// ==/UserScript==
document.querySelector('input.pwordinput').readOnly = false;
ObjectBoxPC / phishingurl.txt
Last active March 19, 2022 00:45
Analysis of a URL in an Amazon phishing e-mail
View phishingurl.txt
# URL in the phishing e-mail is
# Times are UTC-7
$ wget -O /dev/null ''
--2022-03-18 13:30:42--
Resolving (,,, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: [following]
--2022-03-18 13:30:42--
ObjectBoxPC / envelope.tex
Created January 30, 2022 10:23
XeLaTeX template document for printing addresses on envelopes
View envelope.tex
%Note on rotation: It may be a good idea to rotate the page when printing,
%so that the envelope is in a "portrait" orientation in the printer.
%I tried to use lscape to rotate the text, but that doesn't seem to work with textpos.
%The solution for now is to use an external tool like pdftk
%or the settings in some PDF viewers and printer drivers.
%Suggestions on how to achieve proper rotation in TeX are welcome.
%Envelope dimensions (in inches) (US #10 envelopes are 9 1/2 in. x 4 1/8 in.)
ObjectBoxPC /
Created January 4, 2022 09:00
Quickly generate random passwords using built-in utilities (emulating Python's secrets.token_urlsafe: )
dd if=/dev/urandom bs="$ENTROPY_BYTES" count=1 2> /dev/null | \
base64 -w 0 | sed -e 's/=//g' -e 's/+/-/g' -e 's/\//_/g'
ObjectBoxPC /
Last active January 4, 2022 09:03
Dump payload from a SMART Health Card
# This code is dedicated to the public domain under
# Creative Commons CC0 1.0 Universal <>
import base64
import json
import sys
import zlib
shc = input()
ObjectBoxPC / StrConv.hs
Created May 31, 2021 09:50
Programs to transform text strings
View StrConv.hs
module StrConv (strConv, charify) where
import System.Environment
import System.Exit
import Data.Char
convertStr convertChar = map $ \c -> case convertChar c of
Just converted -> converted
_ -> c