How to make porridge

This is how one prepares a tasty porridge. Take 150 mL of oats and 225mL of skimmed-milk—add them together in a cooking pot. Apply low to medium heat and wait for the mixture to  come to a boil. Now add a little more than half a tablespoon of clotted cream and stir until the cream has completely dissolved and the porridge has achieved a nice thick smooth consistency. Finally, transfer the porridge to a bowl for serving. Sprinkle the steaming concoction generously with unrefined cane sugar. And it is most advisable to add a generous tablespoon of single malt Scotch whisky, preferably from a region of the highlands of Scotland were the kilts are still worn without undergarments.

Using lp and lpr commands in FreeBSD to print from the console using CUPS

If you are using FreeBSD and have installed and configured CUPS to send print jobs to your printer, then there is a fair chance that you have at some point attempted starting a print job from your console window. For example, by executing a command like “lp myfancynovel.pdf”. And then you would be quite puzzled to discover that although the ‘lp’ command itself seems to be working fine, and that even though printing test pages—via the localhost:631 CUPS configuration webpage in your browser, for example—also works fine, you still get the following puzzling output: “lpr: lp: unknown printer”. Oh dear, that’s not good.

Well, the thing is that you probably have two printing systems on your FreeBSD installation: LPD and CUPS. I believe LPD is installed as standard on a fresh FreeBSD install. But anyone whose printer is so damned modern, that it does not even require a separate building to be housed in, will want to install and use CUPS instead. And in a rational, sane universe, this would not be a source of evil. However, the developers of CUPS appear to have implemented the same names for their command line tools as LPD…

“WHAT!?”—I hear you say? But yes, I fear you indeed read that correctly. It would seem there is some evil bearded pseudo-autistic caveman working on CUPS—some say he had a bad acid trip in the seventies, or perhaps he’d had one too many sugarcubes in his 50 daily CUPS of coffee—who apparently decided at some point that it would be a good idea to use the same names that the LPD system uses. At least, this is my theory. For what kind of lunatic would think to use EXACTLY the same names for the command line programs used by a competing system, and in doing so risk sabotaging his own? It makes no sense to me.

But how did this psychotic loony achieve this? Well, he obviously knew that the LPD commands are located in /usr/bin. Thus a cunning plan sublimated in his warped mind. “Well then, I’ll just put mine in /usr/local/bin!—he must have thought, with the air of resolute authority one usually sees exclusively in megalomaniac dictators of profoundly marginal banana republics. But since the /usr/bin path usually comes before the /usr/local/bin path in the $PATH variable, the shell will naturally always find and execute the LPD version first if LPD is installed on the system. But LPD is of course not running, so all the commands invariably fail.

Thankfully, there are many ways to remedy this issue. Just uninstall LPD, for example. Or alternatively, you could add an alias in your .shrc file (if you use /bin/sh), like so: alias lp = “/usr/local/bin/lp”. Yet another way would be to edit your $PATH variable so that /usr/local/bin is read before /usr/bin. I guess the moral of this story is that when there’s a will, there’s a way. And also that CUPS is stupid when it comes to naming their CLI programs.

 

How to create a simple pdf file in FreeBSD using groff and ps2pdf

Download (PDF, 4KB)

Below is the source text for creating this example pdf:


 

.TL
How to create a simple pdf file in FreeBSD using groff and ps2pdf
.AU
M.Laurens Voogt
.DA
.NH 1
What you’ll need
.PP
Of course you will need a working installation of FreeBSD. I am using FreeBSD 10.1 at the time of this writing. I recently installed it on an old Asus EeePC 1000H that I was no longer using for anything. I do not use the Xorg X-server on this device, but instead do all my work in text based programs. I use CenterIM for chatting with friends, Mutt for reading and answering my emails, Vim for text editing and tmux for terminal multiplexing.
.PP
Besides the operating system, you will also need to install groff. This may be achieved either by installing a precompiled package ($>pkg install groff) or by compiling it yourself from ports (in “/usr/ports/textproc/groff” execute the command “make -C install clean” as root user). Once groff is installed, all you need to do is read some bigass manual on groff and its macros. Do not be discouraged or deterred by this\[-]even I didn’t read more than the basics, and look how nice this document turned out.
.NH 1
Writting groff code and compiling it into a pdf
.NH 2
Writing it
.PP
There are several so-called macros available (groff is after all just a wrapper for gtroff). In my example I will use groff_ms (look it up on googlebing or
whatever). To begin writing a simple file, you might startup the Vim editor (or whatever other editor floats your boat). Call the file whatever you like, but
something like “test.ms” is what I would choose. Begin writing your novel and save when finished (remember to look up the man page for groff_ms to see how you may control the layout of your document).
.NH 2
Compiling it
.PP
Next step is to compile your document. Top tip: try executing “grog test.ms”. This will return the command that you can use with groff. In my case it advised
me to use “groff -ms test.ms”. This, however, does not produce a pdf. It outputs a postscript file instead, so you will need to convert it. And that is done with “ps2pdf”. So the full command would be: “$>groff -ms test.ms | ps2pdf – test.pdf”
.PP
Now, if all went well, you should have a reasonably nice looking pdf that was a lot easier to create than if you had used LaTeX. Great for composing a nice letter for someone, or writing down your favorite recipes. As you can see, the resulting pdf file does not yet look as `fancy’ as the ones I create with LaTeX. But it is nice have such a simple alternative, and not everything I write has to look like it was written to be submitted to a scientific journal ;-).