Skip to content

Instantly share code, notes, and snippets.

tkurtbond / mod-args.scm
Last active Sep 13, 2021
Modify args.scm from the CHICKEN Scheme args egg to not truncate long options and to allow multiple docstrings for multiple lines
View mod-args.scm
;; O is an args:option
(define (usage-line o)
(define (pad-docstring docstring)
(string-append (string-pad "" (+ (args:width) (args:indent)))
docstring "\n"))
(let* ((option-string (commify o))
(docstrings (args:option-docstring o))
(first-docstring (if (string? docstrings) docstrings (car docstrings)))
(rest-docstrings (if (string? docstrings) '() (cdr docstrings)))
(s (string-append
tkurtbond / tkb-smart-unicode-mode.el
Last active Jul 12, 2021
A small minor mode for easily entering Unicode double and single quotes, em and en dashes, and horizontal ellipses.
View tkb-smart-unicode-mode.el
;; look at for xmlunicode.el
;; xmlunicode-character-list.el. xmlunicode.el provides the
;; "smart-unicode-*" functions.
(load-library "unichars")
(load-library "xmlunicode")
(defun tkb-describe-character (before)
"Describe the character after point (before if a prefix was specified)
if it is a unicode character."
(interactive "P")
tkurtbond / .bashrc_logging
Created Jul 9, 2021
bash functions for logging the output of long commands run multiple times
View .bashrc_logging
incf () {
# Construct a filename from PREFIX, "_YYYY-MM-DD", optionally _N (where N
# is 1 or greater) if the filename already exists, and optionally SUFFIX.
# Example: "incf file .tar.gz" results in "file_2021-07-07.tar.gz", or
# "file_2021-07-07_N.tar.gz" if "file_2021-07-07.tar.gz" already exists,
# where N is 1 or greater.
local prefix suffix fileprefix i testname sep1 sep2
View flesh-to-stone-weight.el
(defun flesh-to-stone-weight (human-weight)
"Calculate how much a human of HUMAN-WEIGHT pounds would weigh if they were
converted into granite."
(interactive "nHuman weight in pounds: ")
(let* ((human-density 63.1) ; lb/ft^3
(granite-density 168) ; lb/ft^3
(granite-weight (* (/ human-weight human-density) granite-density)))
(message "A human of %f pounds would weigh %f pounds
if converted to granite."
human-weight granite-weight)))
tkurtbond / height-mass.el
Last active Jun 7, 2021
How much does your giant weigh?
View height-mass.el
(defun height-mass (start-height start-mass end-height build-ratio)
"How much does your giant weigh?
Calculate from START-HEIGHT, START-MASS, and END-HEIGHT multiplied by
BUILD-RATIO the END-MASS. BUILD-RATIO is a factor to express the difference
in build between different creatures. (The factor for a dwarf might be 2.25,
225% heavier than normal.)
Formula: end-mass = start-mass * (end-height / start-height)^3