GDS Software's Free Software Tools

These tools are provided for use under the GNU General Public License (GPL). Click here to get a copy of the GPL.  These software tools are provided without any warranty -- you agree to use them at your own risk.  GDS Software and Don Peterson are not responsible for any losses you suffer because of this software.

Click here for some notes on some of the software tools that I like and use.

For C/C++ code on Windows, the MinGW compiler can build the C/C++ files below.  Linux folks should already have a compiler installed.  Other choices:  Borland and Microsoft make their command line compilers freely available.

As you can see from the listed programs, I use python a lot more than C or C++.  This is mainly because I can generate a given program in python faster than I can in C or C++.  I will usually only use C or C++ when python is too slow.  With today's hardware, that's pretty rare.  Also, virtually all the programs I write in python are platform independent.  It takes a fair bit of experience on multiple platforms to write platform-independent C/C++ code.

Python scripts

These are python scripts I've found useful in my own work. If you don't have python available on your machine, I'd recommend you consider getting it, as it's a useful tool and it's freely available for most platforms. Go to the Python  website for more information on python.  NOTE:  these scripts are old, having been written for the 1.5.2 version of python in the late 1990's.  Some of the functionality here has been obsoleted by things put into python's standard library or made part of the language (such as sets).
eng_grid.py
This is a python script that will generate most any linear isotropic graph paper by creating a PostScript file that draws the page. You can use ghostscript (see the script's comments) to convert the file to a PDF or an image bitmap.   Someday I'll also make it construct log axes too.
readability.zip
This python script will calculate various readability indexes for text files, such as the Gunning Fog Index, the Flesch-Kinkaid Grade Level, etc.  I use this tool to help ensure my writing is about at the 8th grade level, which is about the level of Reader's Digest.  
html_tokens.py

This script will produce a list of readable words from an HTML file, all in lower case, one per line.  You could then run the list of words through a spell checker.  I wrote this script in the hope that people on the web would spell check their web pages before publishing them.  :^)

iapws95.zip

This zipfile contains C++ and python code that implements the IAPWS95 equations for the thermodynamic properties of water.  You might also want to take a look at John Pye's freesteam project.  I wrote this code in November of 2004 in anticipation of getting some contract work doing a redesign of a steam turbine impeller, but the work never materialized.  Thus, the code hasn't been carefully validated in a real-world application.  If someone does use the code carefully, I'd appreciate any fixes and more unit test code to incorporate back into the package.  You might also search John's site, as he mentioned in an email in November 2005 that he thought there was an error in one of the second derivative equations (I lost his email, but I think it was one of the deltadelta ones, probably for phi)..

naics.zip

Contains a python script that can perform NAICS and SIC lookups.  These are codes produced by the US Federal government and are used to identify different types of businesses.  SIC stands for Standard Industrial Classification and NAICS stands for North American Industry Classification System.  SIC is obsolete and was replaced by NAICS in 1998.  These codes are useful with business search tools that are probably available at your library.  For example, the Reference USA tool can take an NAICS code and show you all businesses near your location that engage in that type of business.  Similarly, both SIC and NAICS codes are used by the US Census website for various searches useful for marketing research.

bd.c

This program performs a comparison between binary files.  Corresponding bytes that are different print out in a hex dump style.  You can also use the -m option to print an ASCII picture of where the differences are in the file, indexed by percentage through the file.  Will compare files of different sizes, but only up to the smaller file's size.  I used this tool to help compare firmware builds despite date stamp and CRC differences.  Debug symbol files for this firmware were typically 137 MB -- it could take 15 minutes to load them into the debugger over the 10 Mb/s Ethernet on a busy day.  Ah, the good old days...  :^)

tlc.py

Script to rename all files in a directory to lower or upper case.  Can also rename directories (it doesn't do this by default), as well as act recursively.  Useful on Windows for us UNIX weenies.

pgrep.py

Python script that provides some of the functionality of the GNU grep program.  It allows use of python's regular expression syntax, which is similar to perl's (GNU grep also has an option to use perl regular expressions).  This python script will run perhaps 10 to 20 times slower than the compiled GNU grep program, but it is portable.

otp.py

This script generates one time pads.  It is a later version than what's given in the zipfile of python scripts above.  It uses the os.urandom() function to provide cryptographically secure one time pads.  A one time pad is a sequence of (hopefully) unpredictable random bytes.  If you and a friend both have copies of the one time pad, you can XOR messages to each other using it and your messages will be cryptographically secure.  In practice, public key cryptography using something like GPG is much more convenient.

mixture.py

A script to aid in mixture calculations.  Adapted from a C program here.  Here's an example of its use.  We have 1 volume unit of a 50% mixture and add 1 volume unit of water.  We'll wind up with 2 volume units of a 25% mixture:

Specify concentrations of both solutions.  If one solution is a
dilutant (e.g., pure water), enter its concentration as 0%.

Concentration of solution A in %? [0] -> 50
Concentration of solution B in %? [0] -> 0
Enter what you know; press return if not known.  You must enter
two data items to obtain a solution.

Amount of solution A? [0] -> 1
Amount of solution B? [0] -> 1

Amount of solution A        = 1
Amount of solution B        = 1
Amount of mixture           = 2
Concentration of solution A = 50%
Concentration of solution B = 0%
Concentration of mixture    = 25%

xref.zip 

This is a C++ console program (along with a 32 bit Windows executable) that will cross reference the tokens in a set of files. It is more comprehensive than the xref.py script in the python scripts collection, can cross reference multiple files, and is faster.  It also can perform spell checking.  It has a -k option which makes it useful for programmers, as it will split composite tokens in their source code and spell check the individual tokens.  Many programmers feel as I do that symbol names should be made of composite words and correctly spelled.  

Here is some typical output from the program:

Default
xref.cpp: [2] 566, 1514
Define
xref.cpp: [1] 1505
Dictionary
xref.cpp: [5] 254, 257, 364, 387, 401
DictionaryContainer
xref.cpp: [5] 219, 224, 603, 1444, 1488
DictionaryContainerIterator
xref.cpp: [3] 220, 226, 605
Do
xref.cpp: [4] 479, 499, 556, 560
The tokens are on the left, followed by a line indicating the file the token was in, the count in square brackets, and the line numbers following.

I wrote both this and the python version for support on software projects with lots of files (say, 10,000 to 100,000).  Glimpse is a better tool in many cases, but it wasn't available on Windows NT systems in the 1990's when I wrote these tools.  Usually, what you want is to find the definition of a programming symbol; ctags is a good tool for this.  When I'm on a UNIX box, I'll run ctags on /usr/include every night via a cron job so I have an up-to-date tags file.

space.py

An updated version of a similar program in the python scripts collection.  It allows you to see where the space is being consumed in a directory tree and where the biggest files are.  Here's a truncated output example:

For directory '.':     [total space = 378.0 MB]
   %     MB   Directory
------ -----  --------------------------------------------------
   7.7    29  .\doc
   6.5    24  .
   6.1    23  .\Projects\Ropes_and_Knots\pictures
   3.8    14  .\business\accounting\receipts\gdssw_scanned_paperwork
   2.3     8  .\pylib
   ...
            [751 directories not shown]

20 biggest files in MB:
    9.76  ./don.knt.knbak
    9.76  ./don.knt
    7.49  ./business/accounting/receipts/gdssw_scanned_paperwork/x.png
    6.78  ./business/accounting/receipts/gdssw_scanned_paperwork/y.png
    5.80  ./Projects/Ropes_and_Knots/RCS/knots.odt
    5.77  ./shop/shopdoc/army_machine_tools.zip
    ...

  Total MB of these files = 94.3

thd.py

Prints out various dimensions associated with threads.  Calculates the values based on the  ASME B1.1-1989 standard document.  If you machine threads on a lathe, you may find this program handy.  Here's the output for a 1/4-20 UNC class 2 thread:

                                       inches        mm
                                       ------        ---
Nominal diameter                       0.2500       6.35
Threads per inch or mm                20.0          0.79
Thread class                           2
Pitch                                  0.0500       1.27
Allowance                              0.0011       0.03
Tensile area, in^2 or mm^2             0.031821    20.53

External thread
    Major diameter
        Max                            0.2489       6.32
        Min                            0.2407       6.11
        Tolerance                      0.0081       0.21
    Pitch diameter
        Max                            0.2164       5.50
        Min                            0.2127       5.40
        Tolerance                      0.0037       0.09

Internal thread
    Minor diameter
        Max                            0.2074       5.27
        Min                            0.1959       4.98
        Tolerance                      0.0115       0.29
    Pitch diameter
        Max                            0.2224       5.65
        Min                            0.2175       5.53
        Tolerance                      0.0048       0.12

Measurements over wires
    Min wire size                      0.022        0.55
    Max wire size (95%)                0.049        1.24
    Best wire size                     0.028868     0.73
        Meas. over best wires, max     0.2598       6.60
        Meas. over best wires, min     0.2561       6.50
    On-hand wire size                  0.029        0.74
        Meas. over wires, max          0.2602       6.61
        Meas. over wires, min          0.2565       6.51

Tap drills
    50% thread                         0.2175       5.53    7/32
    55% thread                         0.2143       5.44    #3
    60% thread                         0.2110       5.36    #3
    65% thread                         0.2078       5.28    #4
    70% thread                         0.2045       5.20    #6
    75% thread                         0.2013       5.11    #7

Sharp V thread (H = sqrt(3)*pitch/2, C = cos(29 deg))
    Thread depth H (Sharp vee)         0.0433       1.10
    Double depth 2*H                   0.087        2.20
    Compound feed 2*H/C                0.099        2.52
    Double compound feed 4*H/C         0.198        5.03

Unified thread
    Flat on form tool                  0.011        0.27
    Thread depth h = 5*H/8             0.0271       0.69
    Double depth 2*h                   0.054        1.37
    Compound feed 2*h/C                0.062        1.57
    Double compound feed 4*h/C         0.124        3.14

ddiff.zip

Contains ddiff.py and ddiffcp.py.  The ddiff.py script compares two directories and lists the differences between them.  You can compare based on time, file size, or content.  The companion script, ddiffcp.py, will perform the needed copying operations to help synchronize the content of two directories.  I wrote this tool to deal with a home computer and work computer that had gotten out of sync and there were files on both computers that weren't on the other computer and I'd want to save both types.  The ddiffcp.py script will overwrite read-only files, so make sure you understand how things work before using it for real.  Here's ddiff.py's help message:

Usage:  ddiff [options] [comparison_operators] srcdir destir
Recursively compares files in two directory trees.
The comparison_operators are:
    ois          File is only in srcdir tree
    oid          File is only in destdir tree
    com          File is common to both trees
    !com         File is in one tree but not the other
    tsn          srcdir tree file newer
    tso          srcdir tree file older
    t=           Identical time stamps
    t!=          Different time stamps
    ==           Files are identical
    !=           Files are different
    z=           Same sizes
    z!=          Don't have same sizes
    zslt         src size less than dest
    zsgt         src size greater than dest
Options:
    -c      Output in "copy" format
    -d      DOS format:  output has backslashes
    -h      Print man page to stdout
    -q      Escape the double quotes in -c mode
    -Q      Same as -q, but the quotes are escaped.

root.py

Implements a general-pupose root-finding method in python that was published in Embedded Systems Programming, May, 2002, pg 7-14.  I translated the C code in the article into python, which, because of python's design, is usually easy to do.  I also added the same algorithm that uses python's Decimal numbers for calculation.  If you're not familiar with python's Decimal class, it's a number class that uses python's arbitrarily long integers to implement floating point arithmetic.  If you do numerical work, you'll be familiar with roundoff error -- the Decimal class can help you get a grip on round off.  You also can perform floating point arithmetic with any number of digits you wish and have full control over rounding and exceptional events.  It's a well-designed tool by people who  understood what they were doing.  A disadvantage is that iterative calculations (e.g., root finding, numerical integration, etc.) with Decimal numbers can be quite slow.  I wrote some routines for a shop utility script that involved two and three nested loops.  These calculations were a hundred to a thousand times slower than the equivalent C code.  In fact, they were slow enough that I had to abandon the idea of using the Decimal class for the program.  If this kind of thing interests you, be aware that there are python bindings for the GNU Multiple Precision library.

Here's example output that shows the calculation of the eighth root of two:

Calculated root = 1.090507732665258  (Normal floating point)
Correct value   = 1.090507732665258
Num iterations  = 9

Calculated root = 1.090507732665257659207010655760707978993  (Decimal)
Correct value   = 1.090507732665258
Num iterations  = 14

It took 14 iterations to calculate the value to 40 decimal places.  I checked that this was the correct answer by using long integer arithmetic.

novas.py

This is a translation into python of some C code from the US Naval Observatory.  It contains routines that are nearly identical to those used for calculations of the Astronomical Almanac.  Combined with accurate ephemeris data, it should be capable of accurate astrometric calculations.  The python code generates the same results for the test vectors used by the C code.  Here are some notes I made on it.

fish.zip

In 2002, my wife and daughter went to the winter Olympics in Utah, so I was home by myself for the weekend.  I had come across the "Einstein fish puzzle" on the web and worked on it that weekend.  I've never seen an attribution to anything published by Einstein on this puzzle, so it leads me to think that a clever person attached Einstein's name to the puzzle for "marketing" purposes.  It's a logic puzzle and you have to reason out a solution.  Most folks will make a matrix, get a solution, and think they're finished.  I was curious if there was more than one solution.  I manually did some systematic searching and did find other solutions, but then realized that I could use a program to exhaustively examine all the possible solutions.  Here are some notes on the program and solution.  It's interesting to search the web using "Einstein fish puzzle" and see how many people have written about it.  Mainly, what's of interest to programmers here is probably the comb_perm.py script that can be used for brute-force searches using combinations and permutations.

tags.py

If you use ctags because you use an editor that can make use of a tags file, this script might be useful, as it supports obsolete/oddball programming languages.  It currently produces tags for xBase program files and BASIC.  It uses python regular expressions to find functions.  I examined some dBase program files I had on hand to generate the regular expressions for xBase, but if you find I've left something out, please let me know.

app.cpp

This is a handy application if you like to work at a cygwin command line.  Given one or more files, it will cause them to be opened with their registered application.  For example, if I have a Word document named design.doc in my current directory, I'd normally have to open Explorer, navigate to the directory, then double click on it to open the file.  With the app program, all I have to do is type app design.doc.  If you're using a regular DOS window, note that you can use the start command instead.

vimrc

I like to use vim as my editor.  Here's my .vimrc file.  If you're a vim user, poke around in it and there might be something of use.  I recommend you regularly peruse the vim website, as there are wizards there who have produced neat stuff.  Editors like vim and emacs are wonderful tools because they have so many capabilities and contributed add-ons.  Even if you're comfortable with your editor, make it a point to learn something new about it each week with an eye towards improving your efficiency.  Other good programming editors I've used are CodeWright, SlickEdit, and UltraEdit.

goto.zip

If you spend a lot of time in a console window with a UNIX sh-type shell, you'll probably want this file.  It contains a shell function and a python script that let you navigate around to various directories.  I've had a few folks tell me they couldn't live without it once they started using it.  I still kick myself about this tool, as I had been using UNIX for about 10 years before it occurred to me to write this tool to save time.  

hc.exe

This is an RPN calculator (run at a 32 bit Windows command prompt) loosely based on HP's calculators (especially my beloved HP-42S).. Type 'hc -h' to get a man page to stdout. Type ? and ?? in the program to get brief help.

The hc stands for hex calculator, which is what it was in the mid- 90's when I wrote it. But then I wanted it to have floating point calculations too, so I added a bunch of new stuff in a C++ rewrite in the late 90's. I've been using it everyday since. There are a couple of obscure commands that are broken, but most things seem to work fine.  Some day I want to rewrite it in python and add physical units, complex numbers, rational numbers, and interval arithmetic.  Take a look at frink in the meantime -- Alan wrote it in Java and it has wonderful support of units.

This tool is free, but I'm not planning on providing the source code.

unx.py

Produces a list of files that are candidates for turning their execute bit permission off.  On Windows XP, when you use cygwin, external programs can create or modify files and leave their execute bit set.  Later, when you do an ls, you see a sea of green (or whatever color you have executables set to).  This script turns off the execute bit on all files that are not .exe's or some kind of script.  It can also act recursively.

ShopTrig.pdf

In the shop, the need to solve triangles pops up frequently.  To solve any triangle, you really only need a few pieces of knowledge:  the definitions of the sine, cosine, and tangent of a right triangle's angle, the cosine law, the sine law, and the fact that the angles of a triangle sum to 180 degrees.  This white paper gives these laws, then shows a few examples of their use.  It also gives Euler's Formula, a very useful thing to know.  In case you were wondering, the Pythagorean Theorem is a special case of the cosine law.

irr.py

If you deal with data files from a spectroradiometer, this script could be handy.  I use it mainly to calculate irradiance over a wavelength band from a spectral irradiance data file.  It is written to work with StellarNet spectroradiometer files, but it can easily be modified to work with other data files.  The weighting option -w weights the data with the weighting function given by the 2006 TLVs and BEIs by the American Conference of Government Industrial Hygienists.

Usage:  irr.py op parameters
Operates on StellarNet spectrum files.

int[egrate] [-w] lambda1 lambda2 file1 [file2...]
  Prints the integrated irradiance for a StellarNet irradiance file
  integrated over the indicated wavelengths.  If the -w option is
  given, the effective irradiance over the UV band is printed.

dif[ference] file1 file2 output_file
  Calculates the difference between two spectra and writes it to the
  output file.

OO_math.pdf

This is a short two-page document that introduces the equation-writing capabilities of Open Office 2.0.  While it's not industrial strength like TeX or LaTeX, it is quite capable and free.  If you occasionally need to stick equations in your documents, this could be a good tool.

math_cheatsheet.odt
math_cheatsheet.pdf

I put this cheatsheet together to remind me of how to do things in Open Office's equation writer.  I print it out on  a single sheet of paper and keep it next to my computer.  Please note this list is not intended to be complete -- it contains a list of the things I am likely to use.

VoltageDivider.zip

This is a C++ program that lets you design a voltage divider from the resistors you have on hand.  The zip file contains the divider.cpp file along with a Windows executable.  A PDF file also shows a simple and ingenious resistor storage system my wife came up with that lets me find a resistor in a matter of seconds.

gauge.cpp

A C++ program to print out combinations of inch gauge blocks that yield a desired composite length.  I have a second-hand set of gauge blocks I purchased inexpensively on ebay.  They are missing about 20 blocks.  It is difficult to figure out the blocks to use for general sizes, so I wrote a program to examine all of the combinations.  This problem is technically known as the subset sum problem and is known to be a difficult problem to solve -- there is no known algorithm that can solve the problem in time proportional to a polynomial of the problem size.  The brute force algorithm used here is exponential; however, it happens to solve the practical problems I'm interested in associated with the gauge block set I use.  It will also find one or all of the gauge block stacks for 36 and 81 block standard sets for a variety of desired dimensions.

While the purchase of a new gauge block set is probably beyond the financial means of most home shops, don't rule out the purchase of a used set.   I use my beat-up gauge block set quite a bit more than I thought I would.  For example, I'm designing a simple radius turning attachment for my lathe that will sit on top of the compound slide.  I needed the distance from the top of the slide to the spindle axis of the lathe.  It was easy to do with gauge blocks and I'm confident of the results:  I just chucked an edge finder in a collet chuck and used the gauge blocks to measure the height.  I could even account for the 0.0012" of runout of the edge finder and collet.

pycephes.zip

This is a pure-python translation of Stephen Moshier's cephes special functions.  It contains special functions used in technical work, such as elliptic functions, gamma and beta functions, hypergeometric functions and probability functions.  Bessel functions are missing.  This package is handy when you occasionally need such things, but if you are doing serious numerical work with python, you'll probably want to use scipy instead, which contains the cephes functions written in C.