Skip to content

Instantly share code, notes, and snippets.

View ObjectBoxPC's full-sized avatar

Philip Chung ObjectBoxPC

View GitHub Profile
@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 October 7, 2023 14:28
Userscript to sort Pittsburgh Regional Transit bus schedules numerically
// ==UserScript==
// @name Sort Pittsburgh Regional Transit bus schedules numerically
// @version 2
// @include 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
Created July 24, 2023 16:23
Quickly generate random numeric PINs
#!/usr/bin/env python3
# Usage: ./makepin.py [number of digits, default 4]
import secrets
import sys
if len(sys.argv) < 2:
digit_count = 4
else:
@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;
@ObjectBoxPC
ObjectBoxPC / phishingurl.txt
Last active March 19, 2022 00:45
Analysis of a URL in an Amazon phishing e-mail
# URL in the phishing e-mail is https://t.co/tmI9IHHvTk?signature=newsletter&trackingid=dpx9Ve0JW3iV15k4k4itEmDGAuJQEpNq
# Times are UTC-7
$ wget -O /dev/null 'https://t.co/tmI9IHHvTk?signature=newsletter&trackingid=dpx9Ve0JW3iV15k4k4itEmDGAuJQEpNq'
--2022-03-18 13:30:42-- https://t.co/tmI9IHHvTk?signature=newsletter&trackingid=dpx9Ve0JW3iV15k4k4itEmDGAuJQEpNq
Resolving t.co (t.co)... 104.244.42.133, 104.244.42.197, 104.244.42.69, ...
Connecting to t.co (t.co)|104.244.42.133|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://linkedin.com/slink?code=gcfcUq57 [following]
--2022-03-18 13:30:42-- https://linkedin.com/slink?code=gcfcUq57
@ObjectBoxPC
ObjectBoxPC / envelope.tex
Created January 30, 2022 10:23
XeLaTeX template document for printing addresses on envelopes
%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.
%Settings
%Envelope dimensions (in inches) (US #10 envelopes are 9 1/2 in. x 4 1/8 in.)
@ObjectBoxPC
ObjectBoxPC / makepassword.sh
Created January 4, 2022 09:00
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 -e 's/=//g' -e 's/+/-/g' -e 's/\//_/g'
echo
@ObjectBoxPC
ObjectBoxPC / shc.py
Last active January 4, 2022 09:03
Dump payload from a SMART Health Card https://smarthealth.cards/
# This code is dedicated to the public domain under
# Creative Commons CC0 1.0 Universal <https://creativecommons.org/publicdomain/zero/1.0/>
import base64
import json
import sys
import zlib
shc = input()
@ObjectBoxPC
ObjectBoxPC / StrConv.hs
Created May 31, 2021 09:50
Programs to transform text strings
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