Skip to content

Instantly share code, notes, and snippets.

View curtmack's full-sized avatar

Curtis Mackie curtmack

View GitHub Profile
@curtmack
curtmack / TitleCase.java
Created January 11, 2024 23:19
Correct title case conversion in Java
import java.util.Map;
import java.util.HashMap;
public class TitleCase {
private TitleCase() {}
// Strictly speaking, this is 100% necessary for correct international behavior.
// There is no way to do this that's built into Java.
private static final Map<Integer, String> SPECIAL_MAP;
@curtmack
curtmack / trans_rights_100.mixal
Last active December 22, 2021 07:07
MIX Says Trans Rights
* TRANS RIGHTS.
* (THE MIX CHARACTER SET IS LIMITED, SO AN EXCLAMATION POINT IS NOT POSSIBLE)
CARDW EQU 17
CARDWBUFS EQU 16
LP EQU 18
LPBUFS EQU 24
TTY EQU 19
@curtmack
curtmack / ecbdemo.sh
Created January 27, 2021 17:48
Shell script to play with ECB encryption.
#!/bin/sh
# Shell script to play with ECB encryption.
# Requires ImageMagick and OpenSSL commandline tools.
# See https://twitter.com/curtmackevo/status/1354471167793520641
while getopts f:o: c
do
case $c
in
@curtmack
curtmack / cl-fizzbuzz.lisp
Created March 2, 2020 23:17
Optimizing FizzBuzz generators for Common Lisp
#+quicklisp
(ql:quickload :alexandria)
(defpackage #:fizzbuzz
(:use #:cl #:alexandria)
(:export #:make-fizzbuzz-counter-from-rules
#:define-fizzbuzz-counter-from-rules
#:print-fizzbuzz
#:print-fizzbuzz*
#:fizzbuzz
@curtmack
curtmack / jira2hours.sh
Last active March 14, 2019 22:15
Sums time in Jira format and prints out the total number of hours.
#!/bin/sh
#########################################################################
# #
# Sums times in Jira format and prints out the total number of hours. #
# Include space to separate each number from its unit. #
# #
# Example usage: #
# #
# $ jira2hours 1 d 2 h 1 w 4 h 30 m #
@curtmack
curtmack / csvawk
Last active November 7, 2018 15:30
Parse CSV file with awk. Uses the Text::CSV CPAN module.
#!/bin/sh
# C0 Unit Separator control code.
# Vanishingly unlikely to be used in data, so it will work for our purposes.
#
# NOTE: If your /bin/sh built-in echo does not support escape sequences,
# try the following instead, assuming you have GNU coreutils echo
# installed at /bin/echo:
# USEP=$(/bin/echo -ne "\x1f")
#
@curtmack
curtmack / fizzbuzz.mixal
Last active March 13, 2019 18:21
FizzBuzz in MIXAL
* FIZZBUZZ IN MIX
SENTINEL EQU 715 * SENTINEL VALUE FOR TERMINATING THE OUTPUT BUFFERS
FIRST EQU 1 * NUMBER TO START AT
LAST EQU 100 * NUMBER TO END AT
PUNCH EQU 17 * UNIT NUMBER FOR THE CARD PUNCH
BUFSIZE EQU 16 * BLOCK SIZE OF THE CARD PUNCH
* THE SENTINEL VALUE 715 CORRESPONDS TO TWO DELTA CHARACTERS
@curtmack
curtmack / bcrypt-gen.py
Created September 28, 2017 22:04
Command-line Python script for generating and testing BCrypt hashes. Requires the 'bcrypt' pip package.
#!/usr/bin/env python3
import bcrypt
import sys
if len(sys.argv) < 4:
print ("Usage: " + sys.argv[0] + " {2a|2b} {workFactor} {password}")
else:
version = sys.argv[1].encode("ascii")
workFactor = int(sys.argv[2])
@curtmack
curtmack / lambda-calculator.lisp
Last active July 9, 2023 09:48
/r/dailyprogrammer Challenge #331 Easy: The Adding Calculator
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Part One: Basic lambda calculus boilerplate ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Define true lambda abstractions.
;;; True lambda abstractions curry.
(defmacro λ ((arg &rest more-args) &body expr)
(labels ((recur (args)
(if (null args)
(cons 'curry expr)
@curtmack
curtmack / nba.hs
Created June 8, 2017 16:05
Broken solution to Daily Programmer Challenge #318. It's basically Bogosort for NBA teams.
import Control.Monad
import Control.Monad.State.Lazy
import Control.Monad.ST
import Data.Array
import Data.Array.ST
import Data.List
import Data.Maybe
import System.IO