Category Archives: Uncategorized

Factorials

Calculate factorials over a range with Python #!/usr/bin/env python3 import sys import functools start = int(sys.argv[1]) end = int(sys.argv[2]) for n in range(start, end + 1): factorial = 1 if n == 0 else functools.reduce( lambda x, y: x * … Continue reading →

Posted in Uncategorized | Leave a comment

PY

Using Python to graph relativistic apparent speed as a starship approaches c #!/usr/bin/python3 import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots(figsize=(8,6)) major_ticks = np.arange(0, 101, 5) unit_ticks = np.arange(0, 101, 1) minor_ticks = np.arange(0, 101, 0.2) … Continue reading →

Posted in Uncategorized | Leave a comment

Pi

π calculation using a Machin-like arctangent formula #!/usr/bin/python3 from decimal import Decimal, getcontext import sys digits = int(sys.argv[1]) if len(sys.argv) > 1 else 50 getcontext().prec = digits + 5 # a few extra digits to avoid rounding errors def arctan(x): … Continue reading →

Posted in Uncategorized | Leave a comment

SH

Print a hex array with #Bash seq 0 255 | awk ‘{printf “%02X “, $1}’ | xargs -n16 Shuffle and rename the files in a directory of images: $ echo ‘#!/bin/bash’ > files; chmod 744 files; ls -1 | shuf … Continue reading →

Posted in Uncategorized | Leave a comment

Cmdlog

List bash commands by frequency #!/usr/bin/env python3 import os history_file = os.path.expanduser(“~/.bash_history”) counts = {} with open(history_file, “r”, errors=”ignore”) as f: for line in f: line = line.strip() if not line or line.startswith(“#”): continue cmdline = line.split(“|”, 1)[0].strip() parts = … Continue reading →

Posted in Uncategorized | Leave a comment

Alpha

#!/usr/bin/env python3 “”” Argo Alpha-AUXMOD Performance Calculator Models the docked Alpha capsule and Auxiliary Module in orbit. Calculates: – Combined operating and dry mass – Shared AUXMOD propellant budget – Ideal delta-v available for maneuvering and docking – Theoretical peak … Continue reading →

Posted in Uncategorized | Leave a comment

Rtf2txt

#!/usr/bin/env python3 import sys import re import codecs SKIP_DESTINATIONS = { “fonttbl”, “colortbl”, “stylesheet”, “info”, “pict”, “object”, “objdata”, “header”, “headerl”, “headerr”, “footer”, “footerl”, “footerr”, “filetbl”, “listtable”, “listoverridetable”, “generator”, “xmlnstbl”, “datastore”, “themedata”, “colorschememapping”, “latentstyles”, “rsidtbl”, “revtbl”, “annotation”, “atnauthor”, “atnid”, “atnref”, “atntime”, … Continue reading →

Posted in Uncategorized | Leave a comment

Paginate

Python code to generate 26 page headers for a chapter of my magnum opus: #!/usr/bin/env python3 import sys import string letter = sys.argv[1].upper() for second in string.ascii_uppercase: print(f'<span style=”font-size: 1.7em; font-weight: bold;”>{letter}{second}</span>’)

Posted in Uncategorized | 1 Comment

MSDOS

Skyglobe for MSDOS, still the best astronomy software 35 years later… Before we wasted time on Windows solitaire we wasted time on MSDOS solitaire.

Posted in Uncategorized | Leave a comment

Calculus

Posted in Uncategorized | Leave a comment