2008/04/26

Scripts for the "Labels" links in my sidebar

There is probably some good pre-fab way to get Blogger to publish links to your blog labels (when you host the content on your own site), but I did not find anything official. Because I have infinite time to waste on web development, I wrote my own scripts instead of using someone else's. I figure I'd share these scripts, so that everyone else can look at them then decide to write their own, too. You can see the finished result in my sidebar on the right, in the Labels section.

There are 3 steps:

  1. Get the labels and make html (bash script)
  2. Make the resulting html embeddable in a webpage (javascript)
  3. Modify my blogger template

It was pretty easy to fetch all the labeled content, using the ls command in the labels/ directory (I am running my webserver on a GNU/Linux system). Then I massaged the output until I had line breaking, label separators, and number-of-posts per label. I put these steps together in my label_lister bash script, because I didn't want to use php (or similar) to access my filesystem. It might be useful to look at the raw output from my labels_lister script. Of course I had to enable cgi scripts in my apache config.

The next step was harder: getting the bash script's output into my blogger-generated index.html file. I chose not to use Server Side Includes to embed the labels html into the blogger-generated index.html file, because I thought I would have to enable SSI for all .html files and that was discouraged by the apache manual.

Instead, I used XMLHttp with javascript. I've done this in greasemonkey scripts in the past, which hides browser implementation details and some other stuff I did not previously realize. Still, the javascript was not too hard. Here is my script: get_labels.js.

Finally, I modified my blogger template. In the blogger template's head, I sourced my javascript:

<script type="text/javascript" src="http://notes.komarix.org/js/get_labels.js"></script>

Then I added one extra CSS class in the template's head:

#sidebar div {
  margin:0 0 1.5em;
  padding:0 0 1.5em;
  border-bottom:1px dotted #ccc;
  }

Finally, I added my Labels section to the sidebar, below the links section, and above previous posts section:

  <MainOrArchivePage>
  <h2 class="sidebar-title">Labels</h2>
  <a href="/">(click here to undo label selection)</a><br /><br />
  <div id='labelsList' class='sidebar-div'>
    <ul>
      <li><a href="/labels/yoga.html">Yoga</a></li>
    </ul>
    <script>getLabelItems(document.getElementById('labelsList'));</script>
  </div>
  </MainOrArchivePage>

And that's it. Possibly more work than it was worth, except that I refreshed my memory on javascript and cgi details, and learned a little bit of new stuff. If I were doing it over, I'd probably start with the bash script and tell apache to do SSI for all .html files. I doubt the server load would be that large, especially for my blog. =-)

Labels:

First Cars

Someone recently asked which of two 200+ horsepower cars was appropriate for a first car, on a mailing list inhabited by car lovers. From my perspective as an "old man" (I'm 34), most of the conversation bordered on ridiculous, with comments like these about adequate cars for commuting and errands (paraphrased):

My daily driver is an IS250 with a whopping 204HP...But honestly I would call it gutless

For a daily driven street driver? ...The [200+HP, sub-3400-pound] C230 and GTi do just fine for street cars.

I finally put on my grumpy old man hat and contributed my two cents. Some people got a kick out of my first-car description, so I'm re-posting it here.

My first car was a 1972 VW Super Beetle that my dad formerly used for commuting. Around 50HP if you adjusted the valves and distributor once per week. It was powder-blue, with a giant rust hole just ahead of the right rear fender -- in rainstorms, the right-rear passenger footwell filled with inches of water (I eventually drilled drainage holes). Due to a quirk in the automatic choke, part of the electrical system would short out when the engine got hot (hard to diagnose...) -- if you shut the engine off in this state, you had to roll-start the car or wait for it to cool down. The gas gauge worked some of the time, which might be worse than not working at all.

I had recurring corrosion problems under the distributor cap. One trip across Snoqualmie pass, the heater seemed especially hot (it melted a plastic bag under my seat) and the car was more gutless than usual. When I reached the summit, I pulled over and checked the spark plug wires at the distributor end. One of the connectors burst into a puff of blue smoke when I pulled it out, and another was covered with blue corrosion. The engine ran surprisingly well (I reached the summit, anyway) in this state, all things considered.

I even rebuilt the carburetor on that car, when my dad and I swapped the engine.

The car I learned in was an old Ford cab-over van. It had the "three-on-a-tree" manual gear selector on the steering column. Sometimes the shift linkage (don't know what it is really called) would stick, and my dad would slide under the van (engine still running) and shake stuff around until the transmission worked again. The van was previously owned by a friend that ran a Volvo dealership. The paint crew at that dealership played a prank on him, and painted a Volvo stripe along the body and removed most Ford logos. They also installed a Volvo radio. We kept it this way, which resulted in humorous confusion for many people.

My dad would take us out to back roads, hence I learned to drive a stick on gravel. He was very brave. After recovering from sliding around a corner and fishtailing between deep ditches, he only said "I think you might have taken that last corner a little faster than you should have."

Labels:

2008/04/07

How I started journaling

Midway through last September, I started journaling. I am still writing frequently in my journals, a surprising success given several aborted attempts in the last 34 years. I can identify several reasons I am still writing. I am giving myself permission to write poorly, as if nobody would ever read what I write -- including myself. Grammar, spelling, punctuation, and sentences are all optional. I think of the journal as a terrific listener, and really this is just a reflection of something more important: I am finally willing to listen to myself without judgment, giving myself permission to speak freely. However, none of that is my motivation for this blog post.

My first journal invited me to write on its pages. The cover, the line spacing, the art on the edge of each page -- all encouraged me to hold and admire this originally-empty book. My first entry arose from this visceral attraction. This blog post is motivated by a desire to share that entry.

I chose this book because its art invited me to write on its pages. Tonight I see the sun on the cover, and remember the Phoenix, willing to end its life in fire and ashes, so it may be reborn and rise to a new life. Tonight is a good night for me to give up the life I've had. Once I've let that life go, I'll be ready, and willing, to receive the morning's new life. Again.

2008/04/06

How to fix your Panasonic TZ3 camera

My Panasonic TZ3 camera recently malfunctioned. When I turned the camera on, the lens extended and retracted three times, then LCD showed only the message "Please Turn Camera Off Then On Again". The instruction booklet said this indicated a problem with lens extension. I tried turning the camera on and off at least thirty times over two weeks, and each time the lens, lcd, and controls seemed to work fine -- except that the camera wanted to be turned off and on again. Playback mode worked perfectly. It was frustrating to believe that the camera was fine and the error was wrong.

Eventually I wondered if there was some sort of "reset the lens sensor, everything is okay" function. In under a minute, I found it, or something close enough for my needs. I held down the shutter release, then turned the power on. The mode selector was in the "manual" position, though I have no idea whether this was important. After extending the lens, the camera focused as if it were taking a regular photo. When I released the shutter button, the lens remained extended, and the camera appears to be working fine. Note that pressing and holding the shutter release after turning the power on did not help -- I only succeeded once I held it down before powering on.

"Fix" is probably not the right word, for two reasons: I don't know how exactly I fixed anything, and I don't really know what was wrong in the first place. With luck, I'll never need to answer those questions.