Archive | minor aside RSS for this section

Update and Shutdown; sudo, halt, stuff like that.

So I sometimes run the script to shut down my Debian machine (it lives in ~/bin).

[sudo] password for username:

It asks me for my root password then does an update to get the new file version information, then an upgrade and dist-upgrade, then halts the machine. It’s a one-liner:

sudo apt-get update  && sudo apt-get -y upgrade && sudo apt-get -y dist-upgrade && sudo halt

Now, what’s bad about this?

  1. Well, sudo ‘remembers’ that I’ve typed my password for (by default) five (or is it fifteen?) minutes, so if the early steps (update, for example) take a long time, the latter ones won’t work.
  2. Also, if my intent is to let it update and shut down without me, I’ll be walking away from a machine in which root access is available for that five (or is it fifteen?) minutes, so I probably want to lock the screen before I go. Not a big deal if it’s a home machine or you can lock the office, and probably not a big deal anyway unless you deal with sensitive information (or work with untrustworthy people…).
  3. The -y flag tells apt-get to say ‘yes’ to any queries the installer might ask. Could be a problem if I have a non-standard install or specific needs.
  4. I don’t see any information that the installer might give me, and I don’t find out if it worked till I come back and boot up.
  5. Some packages give information screens and ask the user to input a choice or acknowledge some information. They can mean it does not complete the task and so does not shut down.

The apt-get man page says:

-y, --yes, --assume-yes
           Automatic yes to prompts; assume "yes" as answer to all prompts and run
           non-interactively. If an undesirable situation, such as changing a held
           package, trying to install a unauthenticated package or removing an
           essential package occurs then apt-get will abort. Configuration Item:

So that should be borne in mind too.

Still, I use it anyway.



Guidelines Derived from Watching the Australian Cricket Team get Pummelled in Tasmania by South Africa in 2016

Should have put this out earlier; it’s already dated. On the other hand, I think some of it has turned out more or less correct. Some.

Based on listening closely to what has been coming out of the Australian ‘camp’ during their recent run of failures, I have arrived at four rules for selecting and running an Australian cricket team.

Rule 1: Choose players who at least look like they care. It’s not enough to pull a sad face or look angry when something goes wrong. Maybe if they pretend hard enough it will become true!

Rule 2: Forget supposed talent and look at results. Talent is as talent does not as it looks like it ought to be capable of. Australian selectors have a history of being seduced by players who look the part but perform marginally, and not playing those who are ‘unfashionable’ despite being better performing. How did Mark Waugh get to play over 100 tests?

Rule 3: ‘Stick with my natural game’ is code for ‘I don’t want to have to think very hard’ or possibly ‘I don’t really give a shit’. They are professionals who need to adapt to the conditions and match situation. If they cannot do that they are not good enough to be out there. Judge players on how they perform when things are tough, not when they are easy.

Rule 4: Any system with Greg Chappell (currently Cricket Australia’s National Talent Manager, whatever that means) involved fails. (This is not so much based on recent results as on watching the trail of destruction Chappell leaves whenever he is tasked with ‘managing’ anything. The words ‘piss-up’ and ‘brewery’ come to mind.)


Cricket, what’s that, an insect?

Getting lp, lpq and lpstat to work…

I want to be able to use lp and print from command line, not just from gui. My Linux box (Debian, running FLWM as window manager), prints fine from applications with print dialogues, for example LibreOffice or evince, but I want to be able to use lp, a2ps, maybe print from xFig, and these all use the lp command line interface, and that is not set up.

I know I can go ($ is command line prompt)

$ lpadmin -d [printer-name]

but what is ‘printer-name’? I have a couple of printers attached by USB, not network.

It’s actually very simple.

$ lpstat -a

FUJI_XEROX_DocuPrint_CP305_d accepting requests since Wed 02 Nov 2016 13:26:34 AEDT
HL5340D accepting requests since Wed 14 Dec 2016 17:33:54 AEDT
Stylus-TX100 accepting requests since Tue 13 Dec 2016 20:19:20 AEDT

$ lpadmin -d HL5340D


nu and vee, I and l — design of physics books and modern fads for fonts


As someone working in a technical field, I often feel like designers do not really appreciate the subtleties of notation and how to make it clear. In the title of this post, ‘I and l’ is upper case ‘eye’ and lower case ‘el’. Not that you can tell.

For example, because so many symbols are used, formulas can often contain symbols which might be mistaken for each other. The classic example is…ilb1

and here is the same formula using some sans serif fonts, using Microsoft Word…


Now, this is not to criticise these fonts. They are just not designed for this job. It is the chooser of the font who is being a wee bit silly if these fonts are used in a mathematical document. An even trickier example is…


which I have produced in LaTeX, and the nu and vee are well-differentiated, but that is because the font was designed by someone (Knuth) with the express purpose of laying out mathematics.

If I was able to give advice to anyone out there designing a text with mathematics in it, it would be to look at the two letter/symbol pairs I have shown here, and make sure they can be told apart. If not, the font choice is a poor one and needs to be changed. And what is fashionable at the moment is irrelevant beside the need for clarity and the fight against ambiguity and lack of precision.


Rant over.

My Fortran rotating star and cost of screen output.

Ignore this post.

Got a Fortran program that does some numerical work and I just have it outputting a single character (‘-‘) to the screen each cycle, so I know it’s ticking along. It looks like this, sort of:

-------------------------------> done
Whoa! Exciting.

Whoa! Exciting. This was made using gifsicle.

But I thought that was ugly, so I’ve got something much nicer now. You know how in some text-based programs the fact that it has not completely locked up is shown by having little rotating bar, made just by printing |, /, -, and \ in the same place one after the other? Well, this is one way to do it in Fortran (note, just a snippet, not a working program):

! declare array 'star()'

       character,dimension(1) :: star(4)     

       star(1) = '|'
       star(2) = '/'
       star(3) = '-'
       star(4) = '\'

!other code...

       do iloop=1,nloop
!content of loop...
       end do

So all that this does is write an ‘achar(8)’ character to make the output backspace, use “advance=’no'” to avoid adding a line return, and use ‘mod’ to run through the four characters in the array over and over again.

‘achar(13)’ also works but only if you want to return to the beginning of the line and overwrite everything.

While thinking about this, I wondered: The loop is fairly big (searches some big arrays, does some calculations, works out an energy in a Monte Carlo simulation, that sort of thing) and so since this starry thing is the only screen output, I was wondering — how much does it cost in runtime?

using Gfortran, with -O2 optimisation. With and without the above ‘write’ statement, times are:


 $ time ./Dom2016G_tests < inputsG 

real	2m50.757s
user	1m57.032s
sys	0m1.616s


real	2m49.191s
user	1m56.895s
sys	0m1.587s

So there we have it, a time cost (looking at the ‘user’ time) of less than 0.2s, and only about 0.1%. So I think I’ll keep it. It looks nice.

Oh, and making the animated gif: I made four little bitmaps by screen grabs from LibreOffice, all the same size, and called them a1.gif, a2.gif a3.gif and a4.gif. Then just this command line (I put loopcount in to stop it after a finite number of loops. –loop and it goes forever…):

gifsicle --loopcount=100 -d 30  a?.gif > star.gif









Deep fried. Dusted with sugar. What else matters?

1/4 cup lukewarm water
1/2 teaspoon sugar + 7 grams yeast

Combine the above and let sit for 10 mins until frothy.

2 cups plain flour
1/2 teaspoon salt
1 egg
1 + 1/2 tablespoons sugar
1 cup lukewarm milk
Optional: about 1/4 cup softened fruit, small bits. Sultanas, raisins, cooked apple.
Cinnamon/sugar for dusting

Whisk egg and sugar into yeast mixture.

Put flour and salt in a bowl, make a well. Add half the milk and whisk to smooth. Add yeast mixture and whisk to smooth, add rest of milk and whisk until smooth. It needs to be smooth and pretty runny. Sit bowl in warm place with cling film over top and let it double in bulk.

To cook: Heat oil (enough to deep fry) with hot plate on about 1/3. Dip spoon in hot oil, then spoon a blob into the oil and cook to golden brown. Just a couple of minutes should do.

Yes, yes I did use LaTeX to type up a recipe.

Yes, yes I did use LaTeX to type up a recipe.


A different and much more boring kind of recipe.

Install HP LaserJet on Win 98

Note: This is a pointless note to myself.

I wanted to install my old LaserJet II on a Win 98 box. There’s only one trick to this; go here: and get the file lj120en.exe (or whatever language) and put it on a USB drive, after installing USB software on Win 98, which I outlined here. Or get the file into Win 98 directly if it is networked, or via a floppy or a CD or whatever. The exe file can be unzipped using any zip program, or you can run it and let it unzip itself. Note that if you can find out which file you need from this repository, you may well be able to use the other files there to install any number of devices. This is just one example; but HP do not keep old drivers on their website, so this is a useful site to know about.

Then just use Settings -> Printers -> Add Printer and click through the various dialogues and tell it to find the files wherever you have copied them to (‘Browse’ button). Then make sure your printer is connected and turned on and has paper in it, and go and see if the test pages works. It did for me.

Why? I have an old PC non-networked and an equally old printer with plenty of toner but no connection to a USB-only modern machine, and I just want to use the old hardware to print out some rough drafts.


Print that.


Nautilus keeps trying to open files using uninstalled application(s)

Just a reminder to self: On my Debian box, I uninstalled (‘removed’) Calligra, but Gnome (well, Nautilus) keeps trying to load it when I double-click on some documents.

cd .local/share/applications/

grep calligra *

rm calligra.desktop

Done. The grep just checked for which .desktop files had it in, then I removed the one that did.


Know won kneads two no.

Wagga Wagga Wagga Wagga Wagga Wagga Wagga Wagga

So, all you sciency people out there who look at materials, whether you’re a solid state chemist or a condensed matter physicist or a materials engineer or whether you work with organic materials or metals or ceramics or… well, let’s face it, everything you can touch, sit on or turn into a useful gadget is made of stuff and stuff means materials and materials means the annual Wagga Condensed Matter and Materials Meeting…

Go to this magisterial website:

Or go direct to this one:

And take a look. It’s cheap! Just a few hundred dollars for accommodation, meals and the meeting. It’s cheap, but it’s not nasty, though it might be bloody hot. Here are the important dates:

Key Dates

Abstract Submission Open Monday 12th September 2016
Abstract Submission Close Friday  11th November 2016
Notification of Acceptance Friday  23rd December 2016
Conference Begins Tuesday 31st January 2017


Here’s the conference flyer as a png file, stolen directly from the conference website:

Wagga Wagga Condensed Matter and Materials Meeting announcement.

Wagga Wagga Condensed Matter and Materials Meeting announcement.



A little script to scan and OCR a bunch of pages

So this little script just uses scanimage, tesseract and vim to scan and process pages from my typewriter. It tries to produce sensible paragraphs, and outputs the results of multiple pages to a text file which can be read in and formatted using a word processor, such as LibreOffice.

It is an interactive script because I do not have a scanner fitted with a sheet feeder. To make it non-interactive, modify the scanimage line after reading the scanimage man page, and remove the line read Response. Nothing fancy, no error checking, no clean-up afterwards, no niceties. But it works pretty well, so far. If you want to use it, install any packages you need to to get scanimage, tesseract and vim to work, and cut and paste the below into a file in your path, and make the file executable.

# /bin/bash
# v. 1.0
# Script to scan, ocr, process and concatenate pages, e.g. from a
# typewriter.
# D.J.Goossens, 14 July 2016.
# Start at 1001 so we can be (pretty!) sure all filenames have 4 digit
# numbers
# Create the output file.
echo This is v. 1.0
echo Make sure you give it the output filename as a command line argument.
echo Ctrl-D escapes from the scanning, Ctrl-C quits elsewhere.
echo The resulting images and text files are not deleted.
echo They are of the form outXXXX.pnm and outXXXX.pnm.txt and
echo may be quite big.
echo Hit Ctrl-C to exit now or Enter to continue.
read Response
echo 'Text file from v. 1.0' > $1
echo Processed `date` to $1 >> $1
echo 'Note: When it says "document 1001", treat it as document (page) 1'
scanimage --batch --batch-prompt --batch-start 1001 -p --mode=Gray --resolution=600
# Outputs are of the form out????.pnm. Loop over them
for f in out????.pnm;
tesseract $f $f
# The above produces out????.pnm.txt, which we can process,
# where first we replace double occurrences of newline with a placeholder
# string, then replace single occurrences with a space, then replace the
# placeholder with a return character (it is a trick of regular
# expressions that we search for \n (newline) but write \r (return) when
# we mess with the file).
vim -c "%s/\n\n/pLaCeHoLdErStRiNg/g" -c "wq" $f.txt
vim -c "%s/\n/ /g" -c "wq" $f.txt
vim -c "%s/pLaCeHoLdErStRiNg/\r/g" -c "wq" $f.txt
cat $f.txt >> $1
echo Try typing libreoffice $1 to see what you have got.
echo Setting paragraph formatting to indented and one and a
echo half space is a good start.

Your mileage may vary. Buyer beware. You get what you pay for. No guarantees implied or given. No warranty as far as possible. (Add here any other escape clauses you can think of.)