Saturday, May 18, 2013

Computer culture shock

Heard some stories about the clash of computer cultures, from an American tech guy working with an international non-profit. The first story was one about not writing your password down. The new user was disappointed that he couldn't write the password down, and he wanted to use a password in his native language—which you can't type on a US keyboard. When he heard he couldn't do that, he protested: "I know only 4 words in English!" (which he didn't remember how to spell). The American tech guy said, "Let's use those," and typed the login ID. "Now type your password."

The user had never used a keyboard before! He looked at the keyboard. "Where's 'H'"?

He learned how to hunt and peck each letter out. After maybe half an hour of practice, he was able to reliably type his password in before the login timeout. Whew!

Before this interaction, the tech guy hadn't met a lot of people who didn't speak English, and not many who didn't touch-type.

Another interaction was with a user at the other end of a telephone line. "Type “sudo rm /var/run blahblah.pid”," said the tech help guy. "It'll ask for your password."

The response wasn't encouraging: "Aaaa! I broke it! It's broken!"

After several back-and-forth sessions, the reason came out. In a terminal window, when the password is requested, "echoing" is turned off. So you type your password, and you don't see anything. Of course the password isn't shown (this prevents "shoulder surfing") but neither are asterisks shown, and the cursor doesn't advance. So the user thought the computer had died.

Makes sense, but this is not the sort of thing I could have predicted, had I been in the tech guy's place.

Last story: The Unix™ Way says that when a command completes successfully, we don't show anything. So one can imagine a novice at the keyboard, wanting to remove (i.e., "rm") a file named a.out, and typing something like this:

$ rm a.out
$ _
and saying, "Huh? Why didn't it work?" Well, actually it did work, which is why it didn't say anything. But he doesn't know that; perhaps he expected it to say "Delete succeeded." or something. Maybe he types it again, with this result:
$ rm a.out
$ rm a.out
rm: cannot remove `a.out': No such file or directory
$ _
At this point our novice may be quite confused: the first one failed, but the second one... failed because... the file isn't there any more... then why didn't the first one give me that same messa... Oh! The first one succeeded, but it didn't say anything; the second one failed, with that message, because it succeeded the first time! Oh! OK!

And the light comes on. He remembers reading somewhere about how commands don't say anything when they succeed, only when they fail. It didn't sink in when he read it, but now the "no news is good news" thing has started to become part of his computer consciousness, his culture.

And a few years from now, he'll tell someone, "Okay, now type rm a.out" and he won't mention the part about how no news is good news. When the other person says, "It didn't work!" he'll probably say, "It didn't? What was the error message?"

Monday, April 08, 2013

Dovecot doesn't restart after software update & power fail

Impatient? click here
Yesterday afternoon, the patio door slid open and the lovely Carol appeared. "Before I restart the computer, should I close everything?" she asked.

That's right, it was a software update operation. I suggested that she quit NeoOffice, Firefox and Mail[.app]; it turned out that there was one other question to answer, but I gave it no further thought. For a while.

About 1:30 a.m., the power came back on. It hadn't been off for long, because the microwave oven's clock had the correct time when we got up later this morning. Other electronic clocks, though, were blinking. And the computers were off.

Actually mine, some lease-return IBM/Lenovo desktop from the previous decade, was already on. I guess that's what happens on power-fail-recovery. The Mac Mini, though, was silent. I fumbled around for the button and it came up.

I returned from walking the dog, to discover that thunderbird (on my Linux pee-cee) wasn't able to connect to the server—that is, dovecot on the mac mini (our setup is described further here).

I'm embarrassed to tell you that my first thought was to blame the software upgrade. "Shoulda checked to see if I needed a new rev of dovecot too," I muttered to myself. But then I came to my senses. Nope, everything was fine last night, after the upgrade (and supper).

I mused upon this while chewing my cereal. This might take some time to run down, I thought, and I tried to imagine how annoying it would be for the lovely Carol to have to do without email access.

"Bah—it musta been the power-failure!" I thought. Looked for /var/run/dovecot.pid -- no such file. Hurmpf, I said, and next typed grep dovecot /var/log/system.log, which revealed that dovecot was supposedly already running. The pid file (which was in /opt/local/var/run/dovecot.pid or something like this) claimed dovecot was running as PID 30. Of course "ps p30" told me the awful truth -- that was cron running there.

So it was a stale pid file. Becoming root, I "rm"ed the file, and in fairly short order some nice system process had re-spawned dovecot, and all was well.

Sunday, March 31, 2013

A more catholic science?

First Things is a Catholic magazine—that's Catholic with a capital C.

But many of us forget that small-c "catholic" means "universal" or "inclusive," which is why protestants like me still proclaim, "We believe… in the holy catholic church." I was reminded of this today, Resurrection Day, while reading this article from the April issue:

Most often the story is told like this: There is some feature of the world that science is at a loss to explain. Christians rush to claim that this feature can only be explained by God. Science later produces probable non-theistic hypotheses, and the Christians must beat a hasty retreat.
God and the Gaps by Ross McCullough
A lot of religions have done this, right? The sun rises because Apollo drives his chariot across the sky starting at dawn.

McCullough correctly points out that just because the Apollonian explanation is offered, that doesn't shut down all discussion; the chariot explanation is just one hypothesis, after all.

But what I wanted to mention today is that the empty tomb, or rather The Empty Tomb, is a phenomenon that materialists are so far unable to explain. That first Easter morning was filled with despair and resignation. When the body of Jesus was not in the tomb where it was laid, this resignation became wild hope and utter confusion. Panic and utter confusion also came to the guards (Matthew 28:4, 28:11-15).

How did this happen? Modern science, with its anti-religious materialistic prejudice, refuses to consider the possibility that God intervened in his world in this case. McCullough again:

Why exclude a class of possible answers? Why be atheistic as a matter of method? Why not, instead, choose a more catholic science, admitting a broader array of hypotheses, excluding conclusions based not on predetermined criteria but on what best fits the data?
Why not indeed? Today, Christians all over the world proclaim our answer: Jesus Christ is risen!

He is risen indeed!

Tuesday, March 26, 2013

Interrupted?

"Life," someone said, "is what happens to you when you're busy making other plans." Oh, it was Lennon.

But what I really wanted to tell you about was this fabulous word from Newbigin, from The Light Has Come:

Jesus had no program of his own. He planned no career for himself… He simply responded in loving obedience to the will of his Father as it was presented to him in all the accidents, contingencies, and interruptions of daily life, among all the personal and public ambitions and fears and jealousies of that little province of the Roman empire. (200)
I happened upon this in Responding to our Call, volume 4 of the Companions in Christ series [buy].

The point, of course, is that if we want to follow Jesus, we are also to imitate him in this aspect of his life. Newbigin continues:

So the disciple… will not be concerned to create a character or career for himself. He will leave that to the wise husbandry of the Gardener, who alone knows what pruning, what watering and feeding, what sunshine or rain, warmth or cold is needed to produce the fruit he desires. (ibid.)
Which reminds me of a "Jews for Jesus" song: And press your life into His hands, That He might drink the wine. [link]

When I tell my story, I mean how I came to follow Jesus, I sometimes say I was driving down the road of life, and Jesus was there at a crossroads, indicating that he'd like to go the way of life with me. The problem was, he wanted to drive.

As it turns out, yielding the steering wheel (and the accelerator and brake) was not something I could do once and then forget about. Daily my plans must be surrendered: "I choose above all else to live this day with you" means that walking with God, responding to interruptions in a way pleasing to him—these things are a higher priority than my plans and dreams.

And so "thy kingdom come, thy will be done on earth (and in my life) as it is in heaven." Amen.

Sunday, March 24, 2013

What's new

A friend mentioned that my blog has been dark lately, and he wondered how I was doing. James, this one's for you.

First, the news: my father's two remaining brothers died recently -- Harry, approaching 95, on 2/21; when Gilbert (97 next month) heard the news, he took a turn for the worse and succumbed 3/7, exactly two weeks later. My dad is the youngest to survive to adulthood; he has just one sister left.

The illness and death afforded opportunities to have conversations about things we don't often discuss. Though I felt somehow inadequate several times in these past days, I'm glad I spent the time with my family.

Being with my father, and remembering my uncles in recent years, made me think about what I hope for in my future decades. I do not hope to be taking 30-mile bike rides at age 90, and I imagine much more of my memory will have left me by then; I do not expect to have a lot of brilliant insights. But I do hope I'm more loving, joyful, peaceful, patient, kind, generous, gentle and so on. I hope I can be a man of blessing.

Some good things have been happening through fellowship. Carol and I are in a small group that more or less uses the sermon study guides. Recently we talked about Colossians 3 and the concept of doing everything in the name of the Lord Jesus Christ. What a challenge! Carol hurts my feelings so I ignore her for a while -- in the name of the Lord Jesus Christ? I don't think so.

In a men's small group I'm in, we were talking about 2 Corinthians 12:9f. What is our weak spot? the book asked. We had to think about this, but the concept of doing everything (every detail of our lives) in the name of the Lord Jesus -- that made it quite clear that we have a number of weak spots. Or blots.

Last week we shared dinner with a couple who were so happy that they found our church. Like many of us, they had attended churches where questions were not welcomed, so the thoughtful, respectful, open approach that we take to our faith at MPPC was, and is, very refreshing to them, and it's brought greater engagement in learning, spiritual transformation, discipleship.

We are very grateful for our Sunday morning fellowship group, "Side by Side," which has been in some ways like an extended family to us. It's a community where we encourage each other—stimulate each other to love and good deeds, as the author of Hebrews tells us.

As we approach Good Friday, and Easter Sunday, I remember some past Easters, and one Easter morning in particular, now over 30 years ago, when I marveled at the idea that someone could love me enough to die in my place, to pay the penalty for my sins (or to pay a ransom to set me free), so that I might have eternal life. It seemed a wonderful thought, but it was unbelievable to me.

But a voice from the empty tomb thundered to me over a nearly 2000-year period, "Believe it!"

And so on Easter Sunday morning I will join with my brothers and sisters worldwide in proclaiming, "He is risen indeed!"

Saturday, February 09, 2013

How to convert(1) foo.pdf to bar.png with high resolution

Short version:use convert -density 300x300

I'm an occasional (→non-expert) user of the ImageMagick's marvelous convert program. Today I wanted to convert a nice PDF file to a high-resolution (300dpi, say) PNG file for some editing.

But I was having trouble with it; saying
convert foo.pdf bar.png
resulted in a 72dpi image. What to do? I wondered. Perhaps the help would be useful?

collin@p3:~> convert --help|grep -i resol
  -units type          the units of image resolution
  -resample geometry   change the resolution of an image
collin@p3:~> convert --help|grep -i size
  -page geometry       size and location of an image canvas (setting)
  -pointsize value     font point size
  -size geometry       width and height of image
  -adaptive-resize geometry
                       adaptively resize image using 'mesh' interpolation
  -extent geometry     set the image size
  -geometry geometry   preferred size or location of the image
  -repage geometry     size and location of an image canvas
  -resize geometry     resize the image
collin@p3:~> convert --help|grep -i dots
collin@p3:~> convert --help|grep -i dpi
collin@p3:~> 
None of those looked promising. I didn't want to change the resolution of the image, or resize the image; I just wanted the pre-existing information to be used! Well, when all else fails, Read The Fine Manual.
convert(1)                                                          convert(1)



NAME
       convert  -  convert  between  image formats as well as resize an image,
       blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much
       more.

SYNOPSIS
       convert [input-options] input-file [output-options] output-file

OVERVIEW
       The  convert  program is a member of the ImageMagick(1) suite of tools.
       Use it to convert between image formats as well  as  resize  an  image,
       blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much
       more.

       For more information about the convert command, point your  browser  to
       file:///usr/share/doc/packages/ImageMagick/www/convert.html          or
       http://www.imagemagick.org/script/convert.php.

Ah-HA! The manual is actually online. So I went to the link and looked for "resolution" -- it pointed me at resample, which I knew I didn't want, but I clicked on it anyway, which got me to http://www.imagemagick.org/script/command-line-options.php#resample, where I did a search for "dpi" (dots per inch). That led me to this entry:
-density width
-density widthxheight
Set the horizontal and vertical resolution of an image for rendering to devices.
This option specifies the image resolution to store while encoding a raster image or the canvas resolution while rendering (reading) vector formats such as Postscript, PDF, WMF, and SVG into a raster image. Image resolution provides the unit of measure to apply when rendering to an output device or raster image. The default unit of measure is in dots per inch (DPI). The -units option may be used to select dots per centimeter instead.

The default resolution is 72 dots per inch, which is equivalent to one point per pixel (Macintosh and Postscript standard).
I see that the image is interpreted as 72x72 dpi during conversion; if I resample after that, the higher-resolution info is already gone. But this "density" thing says we'll read the original image at the specified resolution, and then convert to the output format desired. Following are three commands; in the image on the right are the results.
collin@p3:/tmp> convert foo.pdf bar.png
collin@p3:/tmp> convert foo.pdf -resample 300x300 bar3-resampled.png 
collin@p3:/tmp> convert -density 300x300 foo.pdf bar3.png
The first command is the naive command to convert foo.pdf to bar.png; the top image is a screenshot, magnified, of bar.png. You can see that the image is pretty ugly.

The second command is the result of resampling the interpreted-as-72dpi image. The information was lost when foo.pdf was read (i.e., it was read at 72dpi); we then tried to expand the image to 300dpi. The edges are smoothed, so it doesn't look quite as ugly as the first image—if you don't look too close that is. But still, a lot of information was lost.

The last command retains more information from the original, and in the bottom image you can see how much nicer it looks.

openSUSE 11.3: printer won’t print some PDFs

So I have a PDF file (it's from the social security administration's BSO, but really, it could have been from anywhere). I opened it with okular and told it to print pages 1-3, then pages 5-6. I waited briefly, then started wondering what was wrong.

I ran yast2 and tried to see what was up... the test page printed successfully (my PDF print jobs were still in the queue) so I knew the printer was fine.

I'm embarrassed to tell you that I next rebooted the computer. My excuse is that this machine does have some hardware issues, but that's lame. Of course the print jobs didn't print, and lpq still showed them there...

collin@p3:/mnt/home/collin> lpq
hp is ready
Rank    Owner   Job     File(s)                         Total Size
1st     collin  246     SGV147.pdf                      852992 bytes
2nd     collin  247     SGV147.pdf                      800768 bytes
collin@p3:/mnt/home/collin> 
I wondered if something was fishy about the printer itself. After failing to remember the command "lpc", some web searching reminded me of it, but it didn't have much to say, either.
collin@p3:/mnt/home/collin> lpc status
Absolute path to 'lpc' is '/usr/sbin/lpc', so running it may require superuser privileges (eg. root).
collin@p3:/mnt/home/collin> /usr/sbin/lpc status
hp:
 printer is on device 'socket' speed -1
 queuing is enabled
 printing is enabled
 2 entries
 daemon present
simplex:
 queuing is enabled
 printing is enabled
 no entries
 daemon present
collin@p3:/mnt/home/collin>
Finally (D’oh!) it occurred to me to look at the log file. Which logfile? There's no "cups" or "lp" in /var/log/messages but there is /var/log/cups, whence
collin@p3:/var/log/cups> less error_log
…
E [09/Feb/2013:08:59:17 -0800] [Job 246] Job stopped due to filter errors; please consult the error_log file for details.
D [09/Feb/2013:08:59:17 -0800] [Job 246] The following messages were recorded from 08:59:17 to 08:59:17
…
D [09/Feb/2013:08:59:17 -0800] [Job 246] HWMargins = [ 9.000 9.000 9.000 9.000 ]
D [09/Feb/2013:08:59:17 -0800] [Job 246] Error: /undefinedresult in --stringwidth--
D [09/Feb/2013:08:59:17 -0800] [Job 246] Operand stack:
D [09/Feb/2013:08:59:17 -0800] [Job 246] ()   0   ()
D [09/Feb/2013:08:59:17 -0800] [Job 246] Execution stack:
D [09/Feb/2013:08:59:17 -0800] [Job 246] %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1878   1   3   %oparray_pop   1877   1   3   %oparray_pop   1861   1   3   %oparray_pop   1755   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--
D [09/Feb/2013:08:59:17 -0800] [Job 246] Dictionary stack:
D [09/Feb/2013:08:59:17 -0800] [Job 246] --dict:1172/3371(ro)(G)--   --dict:0/20(G)--   --dict:77/200(L)--   --dict:66/75(L)--   --dict:18/25(L)--   --dict:0/15(L)--   --dict:0/15(L)--   --dict:8/15(L)--
D [09/Feb/2013:08:59:17 -0800] [Job 246] Current allocation mode is local
D [09/Feb/2013:08:59:17 -0800] [Job 246] Last OS error: 2
D [09/Feb/2013:08:59:17 -0800] [Job 246] GPL Ghostscript 8.70: Unrecoverable error, exit code 1
D [09/Feb/2013:08:59:17 -0800] [Job 246] cups_close(0x80ad2dc)
D [09/Feb/2013:08:59:17 -0800] [Job 246] prnt/hpcups/HPCupsFilter.cpp 505: cupsRasterOpen failed, fd = 0
D [09/Feb/2013:08:59:17 -0800] [Job 246] Print file sent, waiting for printer to finish...
D [09/Feb/2013:08:59:17 -0800] [Job 246] Ready to print.
D [09/Feb/2013:08:59:17 -0800] [Job 246] End of messages
D [09/Feb/2013:08:59:17 -0800] [Job 246] printer-state=3(idle)
D [09/Feb/2013:08:59:17 -0800] [Job 246] printer-state-message="Ready to print."
D [09/Feb/2013:08:59:17 -0800] [Job 246] printer-state-reasons=none
Why "Job 246"? Because that was the first print job shown in the "lpq" output above. In case you can't see the messages I marked in boldface above, they were:
  • [Job 246] Job stopped due to filter errors; please consult the error_log file for details.
  • [Job 246] GPL Ghostscript 8.70: Unrecoverable error, exit code 1
That "Execution stack:" message was actually my first clue that it was ghostscript.

So the problem lay with ghostscript, which didn't grok whatever okular was telling it. The upshot was, I printed the file using the mac's Preview program, which knew what to send to the printer (an hp officejet pro L7650, but I don't think it matters).

What if you don't have a consumer operating system and utilities? It turns out that pdf2ps works and produces ghostscript-able postscript, albeit with some ugly-looking messages:

collin@p3:/mnt/home/collin> pdf2ps SVG147.pdf tmp/x.ps

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** Warning: Invalid 0.0 font scale given for Tf ****

   **** This file had errors that were repaired or ignored.
   **** The file was produced by: 
   **** >>>> iText 2.1.5 (by lowagie.com) <<<<
   **** Please notify the author of the software that produced this
   **** file that it does not conform to Adobe's published PDF
   **** specification.

collin@p3:/mnt/home/collin>
The resulting file (tmp/x.ps in this case) does print; I think it became a sort of bitmapped file.
collin@p3:/mnt/home/collin> ls -o SVG147.pdf tmp/x.ps
-rw-r--r-- 1 collin  309812 2013-02-09 08:54 SVG147.pdf
-rw-r--r-- 1 collin 2014259 2013-02-09 09:46 tmp/x.ps
collin@p3:/mnt/home/collin>