💾 Archived View for gemini.ctrl-c.club › ~lettuce › offline-programs.gmi captured on 2024-06-16 at 12:35:41. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-10)

-=-=-=-=-=-=-

Offline programs (via aliases/functions)

2024-03-24

Responding to the challenge set out by Solderpunk this month to develop and share some piece of offline software that is offline-first I thought about what things I open a web browser to find out the answer to that could instead be easily found out through a short program, conversion, or lookup table.

Announcing OFFLFIRSOCH 2024

Thesaurus

I do a lot of writing and am frequently using a thesaurus to find better words, particularly when doing writing for school or grant applications. First I looked for thesaurus software in the Void package repository and found mythes. But I couldn't find a good CLI way to interact with it. Then I downloaded the mythes repository and attempted to build its examples but I couldn't make a successful build. I tried a few iterations but ultimately gave up. Next, despite my dislike of the Python packaging environment, I set up a python virtual environment (ugh) and installed cli-thesaurus, then built a fish function wrapper (instead of a Bash alias) since I use fish shell.

function thesaurus --description "find synonyms of words"
  ~/Software/venv/bin/python ~/Software/venv/bin/thesaurus $argv
end

So now I just need to type: thesaurus word-to-look-up

Is that how you're supposed to make a simple CLI shortcut? I'm not sure, but that's what I did.

Inches to Centimeters

The next one seemed to be so simple that I thought I'd use fish shell's math command.

I often need to convert between inches and centimeters because Americans are insane and everywhere else uses centimeters and I work on bicycles which could have parts indicated one way or the other and I need to check they will work together.

The multiplication symbol needs to be escaped since it is the glob character in the shell. Here's the form it should take to convert an argumnt from inches to centimeters with the standard conversion rate of 2.54 centimeters per inch.

math $argv \* 2.54

And the conversion from centimeters to inches.

math $argv \* 1/2.54

So I made two fish functions:

#inches.fish

function inches --description "convert inches to centimeters"
  echo $argv inches is (math $argv \* 2.54) centimeters
end

Example:

$ inches 20

20 inches is 50.8 centimeters

And next for converting centimeters to inches

function centimeters --description "convert centimeters to inches"
  echo $argv centimeters is (math $argv \* 1/2.54) inches
end

It might be nice to do this instead with gforth so I coul write instead 53 centimeters instead of centimeters 53, but I haven't yet wrapped my head around how floating point numbers work in forth yet!

Oldies but goodies

These are similar offline shell wrapper programs that I use already.

Diceroll

function diceroll --description "Roll 1d6"
  shuf -i 1-6 -n 1
end

If I had need to roll other dice occasionally I could alter it make use of an argument, maybe something like diceroll 20.

calm

function calm --description "calm ocean sounds white noise"
  play -n synth brownnoise synth pinknoise mix synth 0 0 10 10 40 trapezium amod 0.1 30
  end

I believe I read this oneliner somewhere but I don't remember where.

dither

There are websites to run dithering on an image. Here's a basic one I run. Requires imagemagick.

function dither --description 'dither, reduce size and grayscale file'
convert $argv -resize 800x600 -colorspace gray -ordered-dither 8x8 (string split -r -m1 . $argv)[1].gif
echo 'converted to dither: ' (string split -r -m1 . $argv)[1].gif
end

music shuffler

I love the noise band Wolf Eyes and have acquired a few dozen of their albums. I often put it on in the background but want it to play randomly.

function wolfeyes
mplayer -quiet -shuffle -playlist ~/Music/wolf-eyes/playlist.txt 
end

Game

I love the amount of games you can get when you download and install the bsdgames package. But I often forgot which ones it comes with, so I made this simple list to remind me.

function bsdgames --description 'list installed bsdgames'
	echo "Installed bsdgames:  adventure, arithmetic, atc, backgammon, battlestar, bcd, boggle, caesar, canfield, countmail, cribbage, dab, go-fish, gomoku, hack, hangman, hunt, mille, monop, morse, number, pig, phantasia, pom, ppt, primes, quiz, random, rain, robots, rot13, sail, snake, tetris-bsd, trek, wargames, worm, worms, wump, wtf "
end

Back to index

---

You can leave a comment by emailing lettuce at the ctrl-c.club domain. Put the name of the post you're responding to and your comment and nickname to list.