The Fugue Counterpoint by Hans Fugal

6Jun/121

Code Reading on a Kindle

First, add this to your ~/.enscriptrc file:

Media: kindle 498 612 0 0 498 612

Now, here's a script (I call it kindlecode) to generate a pdf on stdout:

#!/bin/bash
enscript -Mkindle -E -p- "$@" | ps2pdf - -

Usage is something like this:

$ kindlecode *.{c,h} > /Volumes/Kindle/documents/foo.pdf

kindlecode in real life

4Feb/090

Identification in PDFs

If you need to create a PDF with no embedded identification it may not be enough to simply refrain from typing your name. For example:

$ strings foo.pdf | egrep -i '(hans|fugal)'
/PTEX.FileName (./0_Users_fugalh_research_foo_fig1.pdf)
/Author (Hans Fugal)
/PTEX.FileName (./1_Users_fugalh_research_foo_fig2.pdf)
/Author (Hans Fugal)
/PTEX.FileName (./2_Users_fugalh_research_foo_fig3.pdf)
/Author (Hans Fugal)
/PTEX.FileName (./3_Users_fugalh_research_foo_fig4.pdf)
/Author (Hans Fugal)
/PTEX.FileName (./4_Users_fugalh_research_foo_fig5.pdf)
/Author (Hans Fugal)

The /PTEX lines are from pdftex and the /Author lines originated from gnuplot

/Title (fig1.pdf)
/Author (Hans Fugal)
/Creator (gnuplot 4.2 patchlevel 4 )

Removing the offending lines didn't hurt the PDF in this situation. So if you must anonymize a PDF (e.g. to submit a paper for blind review), be sure to check for hidden identification. Of course, most reviewers wouldn't go digging for it, but you will rest easy knowing it's truly anonymous.

25Sep/082

Bread PDF Update

I've updated my bread/sourdough PDF to reflect the recipe and methods I have settled on.

The bread recipe didn't really change, though I adjusted a few minor details in wording, etc. The sourdough pancakes recipe is completely new—the one from Joe Pastry which is so much better than the one I came up with. The biscuit recipe is the old biscuit recipe from the old sourdough cards that my family got with our start. I don't know if that source has a name or author, but I do have scanned images at http://hans.fugal.net/sourdough/. The consensus of all who eat these biscuits is that they must be served at Thanksgiving dinner in Heaven.

biscuits1
biscuits2

11Aug/081

Hipster Redux

I've talked about the Hipster PDA a few times. I finally stabilized on a system that works for me. I've been using it steadily for months with no major changes now, so I thought I'd share with you.

My brief foray into the hipmod was fun, but too restrictive and small in the end. I understand others enjoy it though, so I'm glad I did it.

I find the classic hipster with a few modifications works best. My biggest beef with the original hipster is that it falls apart and it's not very user-friendly. That binder clip had to go. So I got some binding rings (½" I think, but the exact size isn't critical) and use a standard 3-hole punch to punch 2 holes in the index cards, and bind it with 2 rings. This makes a more book-like planner, which nicely folds over on itself.

Now, those rings can be pesky to open and close so I decided not to. I snip a little cut from the edge of the cards I want to be removeable to the holes. They stay in but will come right out and go right in without struggle.

I also like to print some forms (as you've seen). These I just print on regular paper and trim to size with a guillotine then hole punch (no snips, that works best on cardstock).

I made front and back covers out of a cereal box and duct tape, and even a pen holder out of duct tape. I'll post a picture soon so you can see.

My planner consists of a few reference pages I printed out (including a circle of fifths, a few airport kneeboards, performance data for my favorite planes, and morse code… anything you can find a PDF for.), my weekly calendar/todo list pages, and a bunch of index cards that I use for notes, moments of inspiration, or whatever else they come in handy for. Oh, and a paperclip to mark the current week. I only have to reprint/refill the weekly pages about once every 3 months or so.

For printing things, I wrote a script that automates some of what I mentioned in previous posts.

26Jan/080

hipmod

When I was in grade school, I used to bring my homework from and to school folded up in my back pocket. Life was simpler then. I always knew exactly what I had on my plate at any moment by checking my back pocket.

Fast-forward to the era of planners, PDAs, and productivity software. I've gone through all the phases. None of them fit, but I took something away from each. These days I know what I want, and none of the traditional solutions come close.

I want something analog, very simple, compact, and easy to put together. When I came across the Hipster PDA I thought I had found it, but I soon found that even the hipster wasn't easy enough. I didn't like even the smallest binder clips or paperclips because they had to be removed to actually use it. Rings didn't suit my fancy either. Loose index cards are of course a disaster. The supply of index cards got almost as unwieldy as the hipster itself. To top it all off, blank index cards alone wasn't quite enough structure. So it fell into disuse.

Then I found the D*I*Y Planner, most notably their Hipster PDA edition. This added some structure and beauty, so I gave it a try. I soon decided that printing onto index cards is completely infeasible without special equipment. So that was out, alas.

The other day, I came across PocketMod. Here was something not entirely unlike the homework in my back pocket. It had some structure, it was easy and simple and cheap. It was perfect, except… I don't want to visit a website and run a flash app every time I want to print one. What if the website disappears? And what if I want to add custom pages? (There's a Windows app for that but I don't use Windows.) Also, the printouts generated by the flash app aren't quite right—the fold points aren't on the center and so the end result is a little sloppy-looking. I wish the US used A4 paper, but that's beyond my control at the moment (though I might consider ordering some online…). So the pocketmod flash applet had to be replaced.

So I decided to combine the D*I*Y Hipster and some scripting magic, and the result is hipmod. Thanks to the magic of Multivalent (I was going to use pdftk but it's segfaulting on my laptop for some reason) I can now create hipmods including whatever PDF of interest I find lying around. See the README for more information. Here's a screenshot:

2-week hipmod

29Mar/070

pdftk

Imagine my suprise when a PDF created by Quartz (from the application Pages), turned out to be corrupt. It worked ok with Quartz apps, but not with more strict PDF apps like acrobat and various special-purpose PDF tools. ps2pdf give a nice summary of what's wrong:

$ ps2pdf mv.pdf
   **** Warning:  File has an invalid xref entry:  28.  Rebuilding xref table.

   **** This file had errors that were repaired or ignored.
   **** The file was produced by:
   **** >>>> Mac OS X 10.4.9 Quartz PDFContext <<<<
   **** Please notify the author of the software that produced this
   **** file that it does not conform to Adobe's published PDF
   **** specification.

I found a neat program called pdftk - the PDF
toolkit. It is able to repair such PDFs. From its manpage:

Repair a PDF's corrupted XREF table and stream lengths, if possible:
pdftk broken.pdf output fixed.pdf

Et voilá! Worked like a charm. pdftk has a bunch of other neat tricks up its sleeve, like concatenating PDFs, etc., and it's Free software and cross-platform. Worth a look.

Tagged as: , No Comments
22Feb/070

The Ugly Chronicles of Postcript and PDF

Levi and I tried to figure out the age-old question of how to get not-ugly PDFs out of troublesome PS files. This question used to be primarily "how do I get legible PDFs out of LaTeX?" That question has been answered and answered well, and in most setups of LaTeX it just works these days (in my experience). Here is a good page on that subject.

The question now has become, how do I get legible PDFs out of PostScript files for which I do not have the .dvi or source files? The web is fairly silent on this point.

First, let's talk about the problem. The problem is bitmapped fonts. The beautiful Computer Modern fonts are (were) not vectorized fonts, but bitmapped fonts. That means, in a nutshell, they only look right at certain resolutions. When ps2pdf or its kin converts such a PostScript file to PDF, it generates a PDF file with Type 3 fonts. I believe Type 3 fonts can be either vector or raster, but we're interested in the raster case.

Many many programs do a fantastically terrible job of rendering Type 3 fonts. This includes Adobe Acrobat (rumor has it newer versions are improved), OS X Preview, gv, and a whole slew of others. So what you get is a PDF that is fairly illegible on-screen but that prints fine. Some nice screenshots here.

This inability to cope with Type 3 fonts seems to be a matter of utter incompetence. If you know anything about image processing, you know that it would be hard not to do a better job of downsampling. There do seem to be programs capable of displaying PDFs with Type 3 fonts in at least an acceptable manner. On linux, xpdf and whatever GNOME's PDF viewer is called manage well enough. gv does not handle a PDF with Type 3 fonts well, however it handles the original PostScript file very well. On OS X, Preview fails miserably. You should be able to get xpdf from MacPorts, which is a valid option. Another option is to enhance the generated PDF to the point of moderate legibility:

ps2pdf -dPDFSETTINGS=/screen -dGrayDownsampleType=2 foo.ps

That says downsample to screen resolution not printer resolution, and use
bicubic resampling instead of the fast and worthless default. Levi reports MacGhostView ($20 shareware) works well too, but I can't get it to extract out of the sitx file for some reason. I tried PStill ($70) and got an absolutely pitiful output (and the UI sucks too). Probably the best option is to use gv in X11 to view the original PostScript file, if you don't mind the interface (I actually am kind of fond of gv's interface). However my initial attempt at this with MacPorts doesn't seem to work - I get no fonts at all.

Hopefully this helps somebody. If you know anyone that is responsible for the abysmal state of things, whack him upside the head for me. If you ever generate a PostScript or PDF file from LaTeX with bitmapped fonts instead of vector fonts, whack yourself upside the head for me.

17Dec/060

PDFView

I'm more than pleased to point my fellow OS X users in the direction of PDFView. It fixes all the annoying issues with Preview, i.e. stupid initial sizing, lack of auto-update, and the annoying 'onscreen display' for Beamer presentations. Thanks to bsag for the tip.