Where Are The Wise Men?

Mike's Ramblings

Custom Service? Or Counter Rudeness?

| Comments

I had to mail a package at the post office today. That isn't a huge deal -- there is a postal center about two blocks from work. But I've never been there, but only heard about it.

I heard they were rude. Yes, I know, the thought of U.S. Postal Workers as being rude isn't that difficult to imagine. But I have heard extreme things about this place.

But I walked in and there was only one gal working at the counter. I said, "I need to get postage on these?"

"You want express, priority, or first class?" She said it in a tone that said, "Why are you bothering me?"

I said, "Whatever is cheapest."

She gave me a list of prices, whether I wanted insurance on it, etc. Nothing too out of the ordinary. Until she said; "I hope you don't mind me telling you this, but your penmanship is horrible."

Now, I know that I have horrible handwriting. I've had horrible handwriting my whole life. Teachers tried in vain to get it something that resembled English but they always gave up in utter frustration. So, really, it's like telling me I'm male. Yes, I know, but does it really matter?

I was a little dumbfounded and then she started talking about how she dated a guy with bad handwriting, etc. etc. I wished her a good day and left.

But I left my horrible penmanship there.

Powered by [ScribeFire][].

Random Thoughts

| Comments

Here are some random thoughts that I have been thinking about blogging but haven't gotten to it. So you have to put up with one-liners.

* In case you didn't know, Creighton took away Anne Lamott's invitation to speak long after she accepted it. Richard Dooling had a great editorial in the Omaha paper about it and, thankfully he put it on his blog.

* Macfuse's sshfs works much better without the GUI than with. Although maybe I should try MacFusion

* A creative non-violent protest. It makes the subjects of the protest seem like the idiots that they are.

* Anyone use ElementTree with Jython 2.2? Because I can't get it to work. It seems to want Expat, and it doesn't seem to be in Jython. Same with Distutils, which is probably more important.

* Great hint at getting a web color picker for OSX. Especially if you install HexColorPicker

Neat ZShell Trick

| Comments

I've just discovered on of the neatest shell tricks I've seen since [Ctrl-r][]. If you are in [zsh][]and hit Alt-. (or ESC-., if you have a misconfigured terminal like I do) then the last argument from the last command will appear on the command line.

This may seem like no big deal, but it saves me a lot of editing on the command line itself. If you aren't using zsh now, maybe this will convince you to give it a try.

Powered by [ScribeFire][].

LifeLight 2007

| Comments

It's Labor Day again, and so we had another trip to LifeLight. Technically, it's still going on as write this, but due to the heat in Sioux Falls and the long list of things to do at home, the Hostetler's left in the late afternoon. But we still had a good time. These are my highlights. Other people will have different ones.

* I was very excited when I learned that Derek Webb was coming. But, when Gina and I saw the schedule we were extremely disappointed that he was playing at 2pm at the Main Stage and then playing again 90 minutes later at the Coffeehouse. But I wasn't disappointed in his Main Stage performance. He just appeared by himself with his guitar and played his heart out. He is just as outspoken in his talk between songs than he is in his music. At one point, when he was talking about loving and taking care of people in Africa he said, "And most people in American churches don't give a shit what is happening in Africa." There was a shocked silence. Didn't he know that this was a Christian music festival? And he what is happening in Africa."

* Gina and I headed over to the Coffeehouse to see Derek's next set and a seminar was just finishing. It was a captain who finished serving in Iraq. The audience was engaged in the subject but it probably wasn't the ideal audience for the guy who wrote My Enemies Are Men Like Me. When the soldier finished, a band started setting up. The singer of that band announced, "I was just asked to say that Derek Webb will not be performing tonight in the Coffeehouse." Being a conspiracy theorist, I feel that Derek saying "shit" and he sudden non-performance is connected, but maybe not. Everfound seemed very ready to go for an hour and a half notice so it could have been planned. We listened to Everfound for a little while and they were pretty good.

* Leeland was just as good live this year as last year. Probably even better. And they moved up in the world -- instead of playing at 4pm on Saturday (like last year) they played at 8pm this year -- just before the big artist of the day. Good for them! They deserve it.

* Gina really like Phil Joel. I was taking Leah back to sleep when he was singing, but what I heard made was good.

Seems short this year, huh? I guess that it is a little bit. Oh well . . . I had a good time.

More Joys Of Python

| Comments

I haven't had a chance to do anything in Python lately. But yesterday I needed to do some screen scraping and, after looking at the HTML I needed to scrap from, I knew that I needed some good tools.

The HTML is table in a form with several rows in it. In cell in each rows has hidden items representing that data. And, inexplicably, each row also has a couple JavaScript functions embedded in it. I did a File-Save on a page with ~150 rows in that table, which is large for what I am doing. You won't believe the file size if I told you, so I'll just copy-and-paste it in:

$ ls -lh file.htm-rw-r--r-- 1 me mkgroup-l-d 2.9M Aug 31 10:39 file.htm

Yes, one HTML file with one table is a little shy of 3MB. There is no images embedded in this file -- just pure text. This is why I needed to get out the Big Guns for this exercise.

The Big Gun for this is [Beautiful Soup][]. It can parse anything that might resemble HTML and give you what you need. It is not speedy, but it works well. And for the hunk of HTML I need, correctness was more important than speed.

One thing I discovered about Beautiful Soup is that you can query with a regex. Remember what I said that each cell in the table had a hidden form field in it? The ID for each row was in a hidden input named "id0" for the first ID, "id1" for the second, and so on. Similar for the customer column -- "CustName0","CustName1", etc. So, really, this was easy to find:

soup = BeautifulSoup(file(fname))ids = soup.findAll("input", attrs={'name':re.compile("id\d+$")})custs = soup.findAll("input", attrs={'name':re.compile("CustName\d+$")})

What became a horrid parsing problem quickly became a three-liner. Wow.

I needed to spit data out from this HTML into different files. Since I know what kind of a pain file management can be, I decided it would be great to put them in a Zip file. I could have done a system call to zip but instead I used Python's standard [zipfile][]module.

I was storing the data files temporarily in a data directory, but I didn't want to put that into the Zip file. Luckily that, too, was easy using the zipfile module and the non-standard yet wonderful [path.py module][]:

zfile = ZipFile(zip_file,"w")
zfile.write(f,f.splitpath()[1])
zfile.close()

Coding in Python has been a refreshing change of pace, because I can use these wonderful modules to bend the data to my will and all I have to it tell it how. In Java, I have to worry about making sure the right kind of object is being passed and that things are casting right, etc., etc. Although this is a highly complex problem it was easy in Python.

Powered by [ScribeFire][].