Category Archives: Uncategorized

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

Boxn

Python script to detect the width of your text and put a box around it #!/usr/bin/env python3 import sys lines = [line.rstrip(“\n”) for line in sys.stdin] if not lines: sys.exit() width = len(lines[0]) for n, line in enumerate(lines, 1): if … Continue reading →

Posted in Uncategorized | Leave a 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

Matrix

while :;do echo $LINES $COLUMNS $((RANDOM%COLUMNS)) $(printf ‘%b’ “\\u$(printf ‘%04x’ $((RANDOM%500)))”);sleep .05;done|gawk ‘{a[$3]=0;for(x in a){o=a[x];a[x]++;printf “\033[%s;%sH\033[2;32m%s”,o,x,$4;printf “\033[%s;%sH\033[1;37m%s\033[0;0H”,a[x],x,$4;if(a[x]>=$1)a[x]=0}}’

Posted in Uncategorized | Leave a comment

Calculus

Posted in Uncategorized | Leave a comment

Imagemagick

Imagemagick showcolor() { display -size 300×300 xc:”#${1}”; } showcolor fba9c3 &

Posted in Uncategorized | Leave a comment

Magic

Generate magic squares for any odd side length: #!/usr/bin/env python3 import sys def magic_constant(n): return n * (n * n + 1) // 2 def magic_square(n): square = [[0] * n for _ in range(n)] num = 1 i, j … Continue reading →

Posted in Uncategorized | Leave a comment

Lastfri

Print a list of last Fridays every month for the given year #!/usr/bin/python3 import sys from calendar import monthrange from datetime import date, timedelta def last_fridays(year): for month in range(1, 13): last_day = date(year, month, monthrange(year, month)[1]) yield last_day – … Continue reading →

Posted in Uncategorized | Leave a comment

Perfect

Perfect #include <stdio.h> int main(void) { for (unsigned int p = 2; p <= 23; p++) { unsigned long long m = (1ULL << p) – 1; int prime = 1; for (unsigned long long i = 2; i * … Continue reading →

Posted in Uncategorized | Leave a comment

Antiprime

Print a list of antiprimes (highly composite numbers) with bc #! /usr/bin/bc define factors(n) { auto c, i for(i=1;i<=n;i++) { if(n%i==0) c+=1 } return c } max = 0 n = 1 for(c=19; c > 0;) { f = factors(n) … Continue reading →

Posted in Uncategorized | Leave a comment