Author Archives: Linuxgal

Unknown's avatar

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu

Csv2sc

Convert comma-separated value (CSV) files to SC format with #Python #!/usr/bin/env python3 import sys,string d=’,’ a=”ABCDEFGHIJKLMNOPQRSTUVWXYZ” r=0 o=[“:”] for l in open(sys.argv[1]): c=0 for p in l.rstrip().split(d): if not p:continue try: o+=[“let %s%d = %d”%(a[c],r,int(p))] except: o+=[“leftstring %s%d = %s”%(a[c],r,p … Continue reading →

Posted in Uncategorized | Leave a comment

Whereis

List all binaries in /usr/bin which do 𝑛𝑜𝑡 have a man page find /usr/bin -exec basename {} \; | xargs whereis -m | grep -v \/

Posted in Uncategorized | Leave a comment

Cartesian

#!/usr/bin/env python3 import sys from astropy import units as u from astropy.coordinates import SkyCoord as S c=S(” “.join(sys.argv[1:7]), unit=(u.hourangle,u.deg), distance=float(sys.argv[7])) print(c.cartesian)

Posted in Uncategorized | Leave a comment

Weierstrass

There’s something wonderfully unsettling about a function that has no tangent anywhere, no matter how far you zoom in. #!/usr/bin/env python3 import numpy as n,matplotlib.pyplot as p a=.5;b=11;n_terms=50 x=n.linspace(-2,2,20000) f=sum(a**k*n.cos(b**k*n.pi*x) for k in range(n_terms)) p.plot(x,f,’b’,lw=.1) p.title(‘Weierstrass Function’) p.grid() p.show()

Posted in Uncategorized | Leave a comment

Vidir

Vidir (part of Debian’s moreutils) lets me edit the names of files in a directory in vim as though the directory was just a file, which it really is.

Posted in Uncategorized | Leave a comment

Colrm

Remove columns 1 through 9, and from column 48 to the end of the line: cat starplot6.txt | colrm 1 9 | colrm 48

Posted in Uncategorized | Leave a comment

Hexes

Hexes seq 0 255 | awk ‘{printf “%02x “, $1}’ | xargs -n16

Posted in Uncategorized | Leave a comment

Morse

Morse Code with sed #!/bin/sed -rf s/.*/\U&/ s/$/\nA.-B-…C-.-.D-..E.F..-.G–.H….I..J.—K-.-L.-..M–N-.O—P.–.Q–.-R.-.S…T-U..-V…-W.–X-..-Y-.–Z–../ :a s/([A-Z])([^\n]*\n.*\1([-.]+))/\3 \2/ ta s/\n.*//

Posted in Uncategorized | Leave a comment

Fourier

Additive synthesis with Python #!/usr/bin/env python3 import numpy as n,matplotlib.pyplot as p x=n.linspace(0,2*n.pi,1000) def s(x,t): k=n.arange(1,2*t,2) return 4/n.pi*(n.sin(k[:,None]*x)/k[:,None]).sum(0) N=12 colors=p.cm.rainbow(n.linspace(0,1,N)) for i,t in enumerate(range(1,N+1)): p.plot(x,s(x,t),color=colors[i],label=f'{2*t-1} harmonics’) p.title(‘Fourier Series Approximation of a Square Wave’) p.grid() p.legend() p.show()

Posted in Uncategorized | Leave a comment

Prep

Remove ASCII art boxes from text #!/usr/bin/env python3 import sys import re def prep(lines): cleaned = [] for raw in lines: line = raw.rstrip(“\n”) if re.fullmatch(r”\+[-+]+\s*”, line): continue if line.startswith(“|”): line = line[1:] if line.endswith(“|”): line = line[:-1] line = … Continue reading →

Posted in Uncategorized | Leave a comment