Cheerful Curmudgeon

A complete lack of ideas and the power to express them.

  • Jul
    22

    Running #2

    Filed under: Health;

    I ran again this morning. All is good with no aches or pains. (And if you believe that, I have this bridge to sell you….) Seriously, I am a little sore and can definitely feel parts of me which do not “normally” make themselves felt but nothing extreme.

    I am alternating between jogging for one minute and walking for one minute. I will build up slowly, as advised by everyone I talk to any everything that I read. Next week will involve a LOT of walking, since I am headed to AirVenture, but I plan to take my running shoes and keep on track with my new hobby, too.

    As for technology, JogStats on the Palm Pre is my friend.

    Lesson for the day: downhill is easier!

    No Comments
  • Jul
    20

    Now I’m a Runner

    Filed under: Health;

    I’ve been walking almost daily for over a year and recently got to thinking about running, which I have never done. As a kid, I was always too chunky. As an adult, I have neither been in good enough shape nor have I had the motivation to get in shape. For the first time, I am close enough to give it a try.  I think, more than anything else, I am intrigued by the thought of being able to do something that I could never do before.

    On advice of a friend (and several books and web sites), I realized that I needed good shoes and headed over to Fleet Street Sports, the local athletic cobbler. (I suppose that “cobbler” is not quite right, since they do not actually make any shoes, but this is probably the only chance that I will have to use “cobbler” in a sentence.) Jason fitted me out with a pair of ASICS GT-2150 shoes, a pair of inserts with modest arch support, and some truly weird socks. I took the socks because my friend said that I should and I had read the same thing in a few other places. I figured they could not possibly be worth the big bucks but was willing to suspend disbelief for one run and give them a try.

    The verdict: The shoes are possibly the most comfortable things I have ever worn on my feet. And my socks and feet were dry after a “test run/walk” of 35 minutes, which was quite the contrast from the rest of me which was clad in drenched cotton.

    Thoroughly convinced of the value of “technical” clothing, I visited the local athletic haberdashery for new duds. My son laughed out loud when I told him that I had bought Spandex clothes!

    As for the run, I managed 2.2 miles. Not bad for my first go at running and my second workout of the day.

    No Comments
  • Jul
    16

    I have been walking regularly for over a year and have lost almost 30 pounds. Now I want to start running and the calcified structure within my skull nudged me and suggested that a little research might be in order before I hit the pavement. I checked the library and discovered that the authority record for grey beards in my age bracket is Running for the aged.

    "Running for the Aged" subject heading

    "Running for the Aged" Library of Congress subject authority record

    Aged?!?! Me? Hope springs eternal, though. At the Library of Congress, hope takes the form of the “see: Running for older people” line. I was sure that if I checked that record, it would unequivocally exclude me.

    "Running for older people" subject heading

    "Running for older people" Library of Congress subject authority record

    Sadly, it unequivocally includes me. But on the bright side, I now have it on two of the best authorities in the world, the US Congress and the US Congress’ library, that I am officially aged. Wisdom must certainly arrive soon.

    No Comments
  • Jul
    14

    I have learned to change lead into gold, and back again, for real! Well, sort of. Thus far, it only works within the virtual world of programming languages like Python. Here is the recipe. (If you are not into geek-speak, skip to the bottom where I natter on about reading ebooks on an iPad.)

    class Lead(object):
        def prestoChango(self):
            self.__class__ = Gold
    
    class Gold(object):
        def prestoChango(self):
            self.__class__ = Lead
    
    pb = Lead()
    print pb             # prints Lead
    pb.prestoChango()
    print pb             # prints Gold
    pb.prestoChango()
    print pb             # prints Lead
    

    Voila! First it’s lead. Then it’s gold. Then it’s lead again.

    I understand why you might want to do something like this but, at least within the projects that I work on, it would obfuscate the program too much for my liking.

    I learned this from reading the Python Coookbook ebook on my iPad, which has been thoroughly enjoyable. I like the iBooks app more than I expected to. I can highlight portions of the book, without actually trashing the pages. I can scribble notes next to my highlights. I can easily browse a list of the sections that I highlighted/noted. Perhaps even more useful, I can select a word or phrase from the text of the book and instantly search either Google or Wikipedia for it.

    No Comments
  • Jul
    11

    St. Charles County, MO, will try to ban bicyclists from using some state highways, as reported in the Suburban Journals, Bill would ban bicycles from some highways in St. Charles County. How wrong can you get? In the year 2010, amidst all the hue and cry about poor health, obesity, and greenhouse gases from automobiles, Councilman Joe Brazil, R-District 2 is seriously  proposing that,

    The bicyclists need to stay on the trails that were made for bikes and off the roads in southwest St. Charles County.

    Why, Joe?

    I get more complaints about this single issue than any other issue. The speed limit is 55 mph. You come around a corner and there are two bikes in your lane. You can’t pass them, and it becomes a hazard.

    This sounds like an opportunity for education on sharing the road and respecting all persons’ rights to use the roads within the limits of the law. 55 mph is the speed limit; there are no minimum speeds on the proposed county roads. It is perfectly legal to drive a car or ride a motorcycle at 15-20 mph; so why ban bicycles? If you are in a car behind two bikes, or any kind of slow vehicle, I would hope that a polite toot of the horn or flash of the headlights would encourage the slower vehicle to move over and let you by.

    We live in the 21st century, Joe. Segregation is “out.” Coexistence and cooperation are “in.” There is plenty of room for all of us here in St. Charles County. Won’t you join us?

    If you live in St. Charles County, I encourage you to contact your council representative.

    2 Comments
  • Jul
    7

    You may not be aware of some of the insanity which current copyright laws create in many countries, not just the United States. Here are two songs which you may think are free and clear but which are, in fact, copyrighted and subject to royalty payments:

    Happy Birthday to You

    The Chicago-based music publisher Clayton F. Summy Company, working with Jessica Hill, published and copyrighted “Happy Birthday” in 1935. Under the laws in effect at the time, the Hills’ copyright would have expired after one 28-year term and a renewal of similar length, falling into public domain by 1991. However, the Copyright Act of 1976 extended the term of copyright protection to 75 years from date of publication, and the Copyright Term Extension Act of 1998 added another 20 years, so under current law the copyright protection of “Happy Birthday” will remain intact until at least 2030. (from Snopes.com)

    Kookaburra Sits In The Old Gum Tree

    In February the [Australian] Federal Court ruled the iconic Aussie band [Men at Work] plagiarised part of [it's 1980s hit Down Under], which was penned in 1979 but only achieved worldwide success after a flute riff was introduced to the track two years later. Larrikin Music said the band stole the riff from the children’s song Kookaburra Sits In The Old Gum Tree which was written by Melbourne teacher Marion Sinclair for a Girl Guides jamboree in 1934…. Larrikin owns the rights to the song and had been seeking up to 60 per cent of Down Under’s profits as compensation. (from the Australian Broadcasting Company)

    Y’all be careful out there. Just because it has been 75 years or more since that little ditty was written, doesn’t mean you can’t be ordered to pay royalties if you sing it or even just riff a few bars on your instrument.

    No Comments
  • Jul
    5

    If you are a US citizen then you are almost certainly the descendant of people to immigrated to the United States. As you consider your position on immigration reform, please look at the issue from at least two perspectives: How do immigrants affect you and your loved ones today, and, just as important, how would your ideal solution have affected your immigrant ancestors?

    Immigration has always been contentious for us. My great-grandparents, and great-great-grandparents, came to the US from eastern Europe. I do not know their individual experiences but, as a group, eastern European immigrants were not well received in these United States. The immigrants were seen as dirty, poorly mannered, uneducated, and generally offensive to polite society. There was great debate about whether these kinds of people should be allowed to come to the US; how much it would cost the US citizens to house them, feed the, educate the, and transport them to cities away from the eastern seaboard. It does not matter what period of our history you examine; you will find that immigration was a contentious topic. Yet despite all that contention, most of us are here because of our forefathers’ compassion.

    Hold that compassion dear. Use your heart and your mind to choose a “solution” to the immigration “problem” which serves you, your neighbors, your community, and future Americans.

    P.S. Though you may consider me poorly mannered and generally offensive to polite society, I do bathe regularly and I am well educated. Two out of four ain’t bad. ;-)

    No Comments
  • Jul
    4

    Nelson Mandela gave a copy of Theodore Roosevelt’s “The Man in the Arena” speach to François Pienaar, captain of the South African rugby team, before the start of the 1995 Rugby World Cup. I find this quote much more inspiring and apropos than the poem Invictus.

    It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming; but who does actually strive to do the deeds; who knows great enthusiasms, the great devotions; who spends himself in a worthy cause; who at the best knows in the end the triumph of high achievement, and who at the worst, if he fails, at least fails while daring greatly, so that his place shall never be with those cold and timid souls who neither know victory nor defeat.

    I first learned this as a child: If at first you don’t succeed, try try again.

    No Comments
  • Jul
    2

    The Python programming language has become my first choice for most tasks over the last year or so. The more I use it, the more I find to like about it. I just stumbled across generators in a way that made them make sense to me and it is so cool that I want to share it with you. A generator can make a program immensely more readable by separating the task of producing (or generating) data from the task of processing the data.

    This will make more sense with an example: print an alphabetized list of all the usernames for a Linux system. On a computer running Linux, the file /etc/passwd contains information about all of the users. Here is the file for my laptop:

    root:x:0:0:root:/root:/bin/bash
    daemon:x:1:1:daemon:/usr/sbin:/bin/sh
    bin:x:2:2:bin:/bin:/bin/sh
    sys:x:3:3:sys:/dev:/bin/sh
    sync:x:4:65534:sync:/bin:/bin/sync
    games:x:5:60:games:/usr/games:/bin/sh
    man:x:6:12:man:/var/cache/man:/bin/sh
    lp:x:7:7:lp:/var/spool/lpd:/bin/sh
    mail:x:8:8:mail:/var/mail:/bin/sh
    news:x:9:9:news:/var/spool/news:/bin/sh
    uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
    proxy:x:13:13:proxy:/bin:/bin/sh
    www-data:x:33:33:www-data:/var/www:/bin/sh
    backup:x:34:34:backup:/var/backups:/bin/sh
    list:x:38:38:Mailing List Manager:/var/list:/bin/sh
    irc:x:39:39:ircd:/var/run/ircd:/bin/sh
    gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
    nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
    libuuid:x:100:101::/var/lib/libuuid:/bin/sh
    syslog:x:101:102::/home/syslog:/bin/false
    klog:x:102:103::/home/klog:/bin/false
    hplip:x:103:7:HPLIP system user,,,:/var/run/hplip:/bin/false
    avahi-autoipd:x:104:110:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/bin/false
    gdm:x:105:111:Gnome Display Manager:/var/lib/gdm:/bin/false
    saned:x:106:113::/home/saned:/bin/false
    pulse:x:107:114:PulseAudio daemon,,,:/var/run/pulse:/bin/false
    messagebus:x:108:117::/var/run/dbus:/bin/false
    polkituser:x:109:118:PolicyKit,,,:/var/run/PolicyKit:/bin/false
    avahi:x:110:119:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false
    haldaemon:x:111:120:Hardware abstraction layer,,,:/var/run/hald:/bin/false
    art:x:1000:1000:Art Zemon,,,:/home/art:/bin/bash
    postfix:x:112:124::/var/spool/postfix:/bin/false
    candy:x:1001:1002:Candy Zemon,,,:/home/candy:/bin/bash
    sshd:x:113:65534::/var/run/sshd:/usr/sbin/nologin
    mediatomb:x:114:126:MediaTomb Server,,,:/var/lib/mediatomb:/usr/sbin/nologin
    couchdb:x:115:116:CouchDB Administrator,,,:/var/lib/couchdb:/bin/bash
    speech-dispatcher:x:116:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/sh
    kernoops:x:117:65534:Kernel Oops Tracking Daemon,,,:/:/bin/false
    usbmux:x:118:46:usbmux daemon,,,:/home/usbmux:/bin/false
    festival:x:119:29::/home/festival:/bin/false
    rtkit:x:120:128:RealtimeKit,,,:/proc:/bin/false

    Since the username is the first “word” on each line, up to the first colon, most of that file is drek and can be ignored. So given that file of stuff, the program breaks down into these tasks:

    1. Open the file /etc/passwd.
    2. Read every line from the file and get the username, the first word, off of each line.
    3. Construct a list of all the usernames.
    4. Sort the list.
    5. Print the results.

    My first attempt at such a program would have been something like this:

    namelist = []
    passwd = open('/etc/passwd')
    for line in passwd:
        username, drek = line.split(':', 1)
        namelist.append(username)
    passwd.close()
    namelist.sort()
    for name in namelist:
        print name

    This little Python program does what I just described, producing this output:

    art
    avahi
    avahi-autoipd
    backup
    bin
    candy
    couchdb
    daemon
    festival
    games
    gdm
    gnats
    haldaemon
    hplip
    irc
    kernoops
    klog
    libuuid
    list
    lp
    mail
    man
    mediatomb
    messagebus
    news
    nobody
    polkituser
    postfix
    proxy
    pulse
    root
    rtkit
    saned
    speech-dispatcher
    sshd
    sync
    sys
    syslog
    usbmux
    uucp
    www-data

    The ugliness is that the for-loop does two things which are unrelated to each other: It finds the usernames within the /etc/passwd file and it constructs a list of the usernames. Why does a piece of a program which finds usernames care what happens to the usernames after they have been found? Why does a piece of a program which constructs a list of usernames need to care where the names came from? This is an artificially contrived example, so each of these pieces is very simple, but it is generally A Good Thing if each piece of a program does exactly one task. This makes everything easier: design, coding, testing, and debugging.

    By using a generator, we can pry these two tasks apart and the program becomes easier to understand:

    def usernames():
        passwd = open('/etc/passwd')
        for line in passwd:
            username, drek = line.split(':', 1)
            yield username
        passwd.close()
    
    namelist = []
    for name in usernames():
        namelist.append(name)
    namelist.sort()
    for name in namelist:
        print name

    The generator at the top does just one thing: it produces usernames, one at a time. Python takes care of all the complexities. We can simply use the generator wherever we need a list of usernames. On first use, the /etc/passwd file is opened. Then each line is read, the username split off the beginning of the line, and the username yielded up to whatever other part of the program needs it. When the file has been completely processed, it is closed.

    The second part of the program has become an easy-to-read loop: for name in usernames() This loop processes each name. We can understand that without being distracted by the details of processing the /etc/passwd file. Sweet.

    [Update: I particularly enjoy programming because there is always something new to be learned. I have updated the following example, shortening it by one line while simultaneously making it easier to understand.]

    Of course, Python offers more shortcuts and we can make the program more concise. Try this flavor:

    def usernames():
        passwd = open('/etc/passwd')
        for line in passwd:
            username, drek = line.split(':', 1)
            yield username
        passwd.close()
    
    print '\n'.join(sorted(usernames()))

    Reading from the inside to the outside: usernames() produces the list of usernames. sorted(...) produces an alphabetized list of usernames. '\n'.join(...) takes the alphabetized list of names and joins them together into a string, one name per line, which is ready to be printed.

    I hope that this has not been too deep a peek into the machinations of a programmer’s mind. :)

    No Comments
  • Jun
    27
    This has got to be the coldest, most insensitive obituary ever written:
    !STL 06/424 3SQ AD CLSD WEF 1006300501

    In English, this NOTAM (federal NOTice to AirMen) says that the St. Charles Municipal Airport will close at 12:01am CDT, Wednesday, June 30, 2010. After 67 years of service, the owner will shut it down forever.

    I returned to flying, after a 13 year hiatus, at this airport. Countless pilots have learned to fly at St. Charles Muni. Innumerable stories have been told. Lessons learned. Camaraderie savored. Airplanes loved.

    You can read more about it in the St. Louis Post-Dispatch.

    No Comments

Categories

Archives

Useful Software

Get Firefox! The browser you can trust.

Get Thunderbird

Use OpenDNS

Sampling My LibraryThing

Translate