Book 18: The Kite Runner

Looking back over my reading list for this year, either this book, – The Kite Runner, by Khaled Hosseini, or The Wednesday Wars, is the best book so far this year.

Although terribly sad, as any book about Afghanistan is bound to be, this book was all about redemption, and taking responsibility for our actions. The book is brilliantly written, and I was very surprised to find out that it wasn’t based on actual events. However, the author is in fact from Kabul, and grew up there, and many of the characters are based on actual people he knew.

Apparently the movie is really good, too, and I’m looking forward to seeing that once my Beloved has read the book.

Review: Squid Proxy Server 3.1 Beginner’s Guide, by Kulbir Saini

I just got done reading “Squid Proxy Server 3.1 Beginner’s Guide” by Kulbir Saini, from Packt Publishing.

(Full disclosure: Packt sends me free books on the condition that I review them. However, I’m under no obligation to say nice things, and they keep sending me books even when I say harsh things.)

Quick version: The writing style is ideal for a beginner – clear descriptions of concepts, rich in step-by-step examples and section reviews/summaries to clarify why you just did what you did. Frequent exercises reinforce concepts. Saini writes like a teacher.

Saini’s writing style suggests to me that he’s been teaching this material for quite some time. Every concept has copious examples and suggested exercises to help you remember what you’ve learned. Concepts are clearly defined, clearly explained, and then illustrated before moving on to another concept. Previous concepts are reintroduced and incorporated into the new ones as you go along, so that idea builds upon idea.

This is a book to be read in order, but aso is structured so that someone at an intermediate level can go back and use individual sections as reference.

I love reading technical books that aren’t dry and boring, and which inspire me to be a better writer. Oh, yes, and I learned a lot about Squid, too.

I presume that the content isn’t really quite so specific that it’s only for 3.1, but having not used Squid for an extended time, I can’t say for sure.

The book starts with clear descriptions of the general concepts of proxying, but very quickly gets hands-on and specific to Squid. This is how I like it, because I learn by examples and doing.

So, on the whole, I give this book a firm thumbs up. I’m always a little hesitant doing a review of a book on a technology I don’t know by an author I don’t know, because I make it a firm rule to say the book stinks if it stinks. So it’s always a joy to read a book like this that exceeds my expectations, and turns out to be not just ok, but actually really well written.

Tek11 just a week away

A quick reminder that Tek11 is just a week away, but there’s still time to get your tickets. I’ll be speaking twice – once about all of the things you didn’t know the Apache HTTP Server could do, and once about writing a better FM. And, of course, dozens of far-more-brilliant people will be there too, speaking about many PHP-related topics, and hanging out having fascinating conversations, and working on fascinating projects.

You can hardly afford to miss it. See you there.

Book 17: The Book Thief

A few days ago I finished reading The Book Thief, by Marcus Zusak. I kept wanting to like this book, all the way to the end, but mostly found it annoying. The story is narrated by Death, which really doesn’t work, as he’s not there for most of the story, and so has to make up a variety of reasons why he knows the story. I found the narrator very distracting. The story itself was interesting, but the narration style came close to ruining it most of the way through.

I’ve read several other books about Nazi Germany recently, including The Boy Who Dared, and I’m always struck by the willingness of people to go along with the scapegoating and persecution of their friends and neighbors. I suppose it really shouldn’t surprise me, given how we treat minorities in the USA. It terrifies me to think how little it would take to turn us into those people. We say it could never happen again, but of course it has happened repeatedly since 1945, all over the world.

Anyways, back to the book. I’m glad I read it, but I really can’t give it the glowing review that I’ve seen other places. The jumping around in time is disorienting, and the narrator’s constant interruptions, announcing that he’s the narrator, is very distracting. I prefer for a narrator to be invisible.

Having said that, it’s worth noting that everyone I have mentioned the book to, who has read it, says that they loved it. So perhaps you should go read someone else’s review.

OpenOffice Python (UNO) interface

I spent most of yesterday trying to get the Python UNO interface to OpenOffice to open a document, fill in the TextField blocks in that document, and then export it as PDF. Sort of an automated mail merge, if you will.

The documentation is pretty good, but most of the code examples I was able to find were either in Java or OOBasic, and since I don’t actually speak Python, getting this to work was quite a challenge. There’s a Perl implementation, too, but I couldn’t get that to work at all, and the maintainer was unresponsive. I would love to hear from him, so that I can do this in Perl instead.

So, I thought I’d put the functioning code here, both for my own benefit when I have trouble remembering later, and for the benefit of any other person who might be searching for this information and, like myself, only find examples in other languages.

# Fill in TextFields                                                                            
                                                                                                
import uno                                                                                      
import unohelper                                                                                
import string                                                                                   
                                                                                                
# a UNO struct later needed to create a document                                                
from com.sun.star.beans import PropertyValue                                                    
                                                                                                
localContext = uno.getComponentContext()                                                        
                                                                                                
resolver = localContext.ServiceManager.createInstanceWithContext(                               
                "com.sun.star.bridge.UnoUrlResolver", localContext )                            
                                                                                                
smgr = resolver.resolve( "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" )  
remoteContext = smgr.getPropertyValue( "DefaultContext" )                                       
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",remoteContext)           
                                                                                                
# Open the document                                                                             
hidden = PropertyValue( "Hidden" , 0 , True, 0 ),                                               
                                                                                                
doc = desktop.loadComponentFromURL("file:///home/rbowen/test_doc.odt" ,"_blank", 0, (hidden))
                                                                                                
# Find variable fields, and put values into them                                                
oTFs = doc.getTextFields()                                                                      
enum = oTFs.createEnumeration()                                                                 
while enum.hasMoreElements():                                                                   
    tf = enum.nextElement()                                                                     
    if tf.VariableName == 'firstname':                                                          
        tf.Content = 'Rich'                                                                     
    if tf.VariableName == 'lastname':                                                           
        tf.Content = 'Bowen'                                                                    
                                                                                                
# Save the document                                                                             
# doc.store()                                                                                   
                                                                                                
# Save as PDF                                                                                   
pdf = PropertyValue()                                                                           
pdf.Name = 'FilterName'                                                                         
pdf.Value = 'writer_pdf_Export'                                                                 
doc.storeToURL( "file:///home/rbowen/test_doc.pdf", (pdf,));

Note also that in order for this to work, you’ll need to have already started up OpenOffice in server mode:

/opt/openoffice.org3/program/soffice -invisible "-accept=socket,host=localhost,port=8100,tcpNoDelay=1;urp;" &

Quick note: iconv and Building PHP on OSX

When attempting to build PHP 5.3.6 on OSX (Snow Leopard) I got warnings about iconv, which I had installed via ports.

Undefined symbols:
  "_iconv_close", referenced from:
      __php_iconv_strlen in iconv.o
      _php_iconv_string in iconv.o
      _php_iconv_string in iconv.o
      __php_iconv_strpos in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      __php_iconv_mime_decode in iconv.o
      _zif_iconv_substr in iconv.o
      _zif_iconv_substr in iconv.o
      _php_iconv_stream_filter_dtor in iconv.o
      _zif_iconv_mime_encode in iconv.o
      _zif_iconv_mime_encode in iconv.o
 ... etc

To get around this, I had to:

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-iconv=shared,/opt/local

Teddy bear questions

I used the phrase “teddy bear question” today, and apparently it’s not common lingo, as I thought.

Sometimes the act of asking a question provides the answer. If you ask this question in public, you make yourself look like a moron, but if you’re able to ask a self-answering question without the public humiliation, then you get the best of both worlds.

So, I used to keep a teddy bear on my desk, and I would ask it any question before I asked that question on IRC. This often produced the same result, but without the feeling like an idiot bit.

Thus, in our house we call these self-answering questions “teddy bear questions.”

Book 16: The Remains of the Day

I just finished reading The Remains of the Day, by Kazuo Ishiguro. I saw the movie years ago, and this is one of those rare cases where the movie almost lives up to the promise of the book. This is mostly because Sir Anthony is such a brilliant actor.

The story of a butler trying to maintain the dignity of his position among the great events of the pre-war years is heart-breaking and ennobling. Highly recommended. Worth reading again. I LOVED this book.

Book 15: Brave New World

Just finished reading Brave New World, by Aldous Huxley. This is another on my long list of “I should have read that a long time ago”. It’s easy to see that many of the other sci fi books I have read in recent years have borrowed heavily from this book. The ideas of eugenics and pleasure-controlled society are disturbing. I suppose, like 1984, one sees the things from the book happening in today’s society, which is, of course, what these books are about – a warning about what we could become.

Book 14: Snow Crash

Book 14 was Snow Crash, by Neal Stephenson. It’s been on my list for several years. As a whole, the story was great, and the descriptions both of cyberspace (“The Metaverse”) and programming were some of the best I’ve seen in sci fi. He explains programming in ways that any layperson would be able to comprehend it. Well, any layperson who reads sci fi, anyways. 🙂

I found the lengthy conversations with the computer – lectures, really – to be tedious and somewhat preachy. It would, of course, give away much of the story to tell what I found most irritating about these lectures, so I won’t. However, I find the general sci fi bias against faith to be unnecessary and something of a cheap shot.

While I don’t think that hacking/programming/being online will ever be quite what is described here, the interaction between Reality and The Metaverse is fascinating and well played out. His description of Google Earth, 20 years before it was invented, was awesome. I imagine that, at the time, it must have seemed absolutely magical, but now it’s sort of The Way We Do Things.

As always in well-written sci fi, I’m fascinated by what predictions are still magical, and which ones are just every-day occurrences now.

I’m now reading The Tempest, and might get back to Cider House Rules at some point.

The Margin Is Too Narrow