Some funny computer programs for download
These are some of my programs, mostly shell scripts.
Disclaimer: These programs are in the public domain. They may be freely
copied, distributed and changed. However, no guarantee is given that they
are useful for any purpose or that they will run on any particular machine
without damaging hard- and software. Enjoy at your own risk!
- ASCII-file to TeX Converter
- Extract UU-encoded files from Mail & News
- Position of the Sun (low precision)
- Delay and Date Calculation with Shell Scripts
- Calculate relative humidity from temperature and dewpoint
- Calculate dewpoint from temperature and relative humidity
- Show nesting level of braces in a TeX file
- Computing sequences of the Collatz Conjecture
ASCII-file to TeX Converter
Program name: totex
This is a bash Shell-Script running under Linux and eventually some other flavours of Un*x (untested). It makes use of the sed stream editor which should be part of user's system.
totex tries to figure out how to format a plain ascii-file in a
way to make it look nice when subsequently processed with TeX. It is
intended to process a wide variety of texts the user could download from the
internet. The problem is to find titles, alineas and paragraphs. The script
probably needs some editing to reflect personal preferences. Don't forget to
set the downloaded file to executable:
chmod a+x totex
Usage: totex [-t] filename
where the option [-t] will call TeX after conversion.
Download totex
and report any stories of success or failure to:
![]()
Extract UU-encoded files from Mail & News
Program name: uuesplit
Another Shell-Script for bash/Linux. When you have saved a couple of UU-encoded files to a news or mail folder, then this file must be split before uudecode can be run. This script will do exctly this, using a brute force approach (not very fast on *big* files).
Usage: uuesplit filename-of-folder
Download uuesplit and report any
stories of success or failure to:
![]()
Calculate Position of the Sun
Program name: sunpos
And this is a tiny snippet from the code:
The program calculates the apparent position of the sun for a given local position of the observer. Besides azimuth and elevation, data for right ascension, declination and ecliptic longitude are given as well. Nutation data display can be enabled.
The scope of this program is to provide an easy determination of the relative solar position for photographers, pilots, environmentalists and others. Accuracy is within 2 – 3 seconds of time. For a determination of sunrise / sunset the effects of atmospheric refraction must be taken into account. If high accuracy is desired then more advanced methods of computation should be used.
This program is written in "C" and must be compiled on the users machine. It was tested under Linux/gcc and contains very few machine specific code. The code contains a 'Makefile' appended as a comment. This Makefile can be extracted after downloading and be saved as a separate file using your editor.
Usage: sunpos
Download sunpos.c and report any
stories of success or failure to:
![]()
Delay and Date Calculation with Shell Scripts
Program Names: jd, dow, dt, delay, easter
This is a package of 5 shell scripts to handle delay and date calculation easily from the command line. They should run on any Linux/UN*X system with a "bash" or original "Bourne Shell".
These programs do:
- jd Convert any date given on the command line or on standard input to the corresponding Julian Day number. This is a continuous count of days starting at the beginning of the year -4712. The script will not work for negative Julian Day numbers.
- dow Calculate the day of the week from any given input (date or Julian Day number) and print to standard output.
- dt This is the conversion of the Julian Day number back to a date. Output is in the order "day month year" (those in the new world will have to hack the script slightly to change this order).
- delay is an application making use of jd, dow and dt. When given two different dates like 'delay 15 3 -44 4 10 1957' the script will reveal that there are 731055 days between Cesar's death and the launch of Sputnik 1. Alternatively an input like 'delay 4 10 1957 1000' will show that 1000 days after the launch of Sputnik 1 was Thursday 30 6 1960.
- easter calculates the day of easter within the Gregorian Calendar (i.e. after the year 1582).
All five shell scripts can be downloaded by clicking the following links, but don't forget to set the downloaded file to executable with a shell command like "chmod a+x jd".
Download jd,
dow,
dt,
delay and
easter
and report any stories of success or failure to:
![]()
Calculate relative humidity
Program name: relhumidity
This is an example how to use the bc calculator in a shell script. The program calculates relative humidity from temperature and dewpoint.
View the code relhumidity.html or download
relhumidity and report any
stories of success or failure to:
![]()
Calculate dewpoint
Program name: dewpoint
This is an example how to use the bc calculator in a shell script. The program calculates dewpoint from temperature and relative humidity.
View the code dewpoint.html or download dewpoint and report any stories of
success or failure to:
![]()
Show nesting level of braces in a TeX file
Program name: nesting
Show the contents of the input file on STDOUT, each line preceded by a number indicating the nesting level of braces '{}' valid at the end of the respective line.
TeX syntax is used. Braces in comments are not taken into account.
Download the source package with a right click on nesting-1.1.tar.gz.
Calculating sequences of the Collatz Conjecture
Program name: collatz.c
Lothar Collatz suggested in 1937 that the following
repeated operation on any arbitrary positive integer N:
— if the number is even, divide it by two (N = N/2)
— if the number is odd, triple it and add one (N = N*3 + 1)
will eventually transform N to 1. Starting from 1 is an infinite loop 1 - 4 - 2 - 1.
David Barina verified that all numbers N below 270
converge to 1
(see his list).
The Collatz conjecture is one of the most famous unsolved problems in mathematics. However, it's fun to play with it. You can search for regularities and irregularities or for values of N with a high number of steps required to reach 1. Some other vales of N have a high maximum trajectory point (= highest value of N reached during the sequence). Eric Rosendaal published a list of records.
| Examples: | ||
| N=27 | STEPS=111 | MAX=9232 |
| N=9016346070511 | STEPS=886 | MAX=252229527183443335194424192 |
| N=14022512981985 | STEPS=1569 | MAX=79988992024030705960 |
The program is written in "C" and must be compiled on the users machine. It links to the GNU Multiple Precision Arithmetic Library (GMP) and is capable of dealing with quite large values of N. A sample logfile for N=2 to N=1000000000000 is included.
Download collatz-1.0.6.tar.gz,
compile, have fun, and let me know of any faster or better versions you
created from it.
Note: The image above shows the
Collatz fractal.