Archive for April, 2008

OOPs

Generally, when most people learn that I am a geologist by training, they are surprised. Maybe I just give off some sort of geeky aura, or maybe they are surprised that I’m not "using my degree" (actually I am in a way, but that is too convoluted a story to get into here). At any rate, the point is that I am not a programmer by training. I’d say that at least 75%+ of what I know about programming I taught myself through the ole School of Hard Knocks. I’ve had my share of training courses, but the vast majority of my experience has been just sitting down and cranking out code over the last eight years or so. But I digress. Today was a good day. Today I wrote my first object-oriented Python script from scratch . And it works. It’s not much, about a 100-line geoprocessing script; but it works. And I understand it and now realize how much easier this makes programming in Python. Look out.

Move to WebFaction

Finding the right Web host isn’t easy. Google "<web host name> review" for virtually any host out there, and you will find a plethora of both positive and negative feedback. Chances are, you’re going to find more negative feedback than positive just about every time. A month or so ago, when I was looking for a Web host for super-cooper.com, I spent alot, and I mean alot of time researching Web hosts. Apparently I didn’t do that great of a job the first time around. I chose AN Hosting , mostly because they were recommended by WordPress (although rumor has it that the WP folks get a kickback from those recommendations, which would not surprise me at all) and also because the number of negative reviews I found about them was small. Don’t get me wrong, the service was OK, and their plans are well-stocked, but the reliability and the speed just weren’t there. So last week, when I came across Brian’s post where he asked for options on a new host, I realized from the comments that I had to look into WebFaction - almost everyone who commented on his post recommended them. So I decided to switch. What a charm. Sign up was a breeze, and boy is this site faster. WebFaction claims to not "max out" their servers, and so far, I believe them. The list of what they provide is unique, so go check it out . I’m really dyin’ to get my GeoDjango on…

Retro - It’s all about the donuts

Kids are amazing little buggers, especially when they are your amazing little buggers. One of the most amazing things about having kids is that you can actually learn from them. Yeah, imagine that. Something I have learned from our boys is that it really is the little things in life that make it all worth while. Take for example, donuts. Last summer, we flew from our humble little home in northwest Arkansas to Seattle to visit the wife’s sister and boyfriend, and we took the boys. We stayed in this crappy little motel downtown right near the Space Needle (location, location, location). It was cheap, and we figured “Hey, all we’re going to do is sleep there, right. How bad can it be?” When we got there, the little one was asleep in the car so the wife and the big one went in to “check it out”. Upon return, the wife said that “…it’s not that bad”. I later realized that it was one room barely large enough to hold the king size bed all four of us were to sleep in for a week. Oh, and the bathroom only had a shower, no tub to give the boys a bath in (although they found showers to be quite a novelty that week). Now, if I was going to go back to Seattle, I probably would choose another place to stay. Granted, it wasn’t that bad; it was clean, the staff was friendly and helpful, and did I mention the donuts? No? Well, if you asked our boys if they wanted to go to Seattle tomorrow, they would INSIST on staying in that hotel. Why, you ask? Well, the donuts, of course. Every morning the staff would put out this huge spread of donuts, pastries, muffins, and bagels, and once the boys found out about this, they would shoot out of bed every, yes every morning and want to go get donuts. At 6 AM. So we would go to the lobby, my wife or myself barely awake, the boys still in their pajamas, and get donuts. Lots of donuts. Way too many donuts. About an hour later, our room looked like a donut factory where some sort of explosion had taken place. Sprinkles here, frosting there, donut detritus everywhere (hey, that rhymed). Yeah, if we go back to Seattle with the boys, I think we all know where we will be staying.

Mapping point locations with Python and Microsoft Live Search Maps

This article was first published in the February 2008 issue of Python Magazine . It is being reproduced here with the permission of Marco Tabini and Associates .

Requirements

Python 2.4+
pyExcelerator module (http://sourceforge.net/projects/pyexcelerator/ )
Anthony Tuininga’s ceODBC module (http://sourceforge.net/html/ceODBC.html )
John Machin’s xlrd module (http://www.lexicon.net/sjmachin/xlrd.htm )
Michael Foord’s cgiutils module (http://www.voidspace.org.uk/python/cgiutils.html )

Lets face it, using Python, we can pull data from virtually anywhere in the corporate enterprise - databases, text files, or other documents. But how can we easily visualize data that has place associated with it? Well, we turn to Python and the API of a popular web-mapping application, that’s how.

Read more »

Codeviewer plugin test

Back a few years ago, I used a code syntax highlighter called Code Viewer that was created by Aaron Schaefer at Elastic Dog. That has since been taken over by Håkan Carlström. I spent too many hours this weekend getting this plugin setup to parse Python source code. It uses GeSHi to highlight the code syntax, and I had to hack up the GeSHi CSS and my own CSS to get the Python source code to look like I wanted, but it’s about there. I highly recommend this plugin if you are looking to highlight source code of virtually any modern language. The coolest part of it is that it links to a source code file and you just point to that file, you don’t have to include the code in the post. Below is a sampling of the output, with my own CSS styling applied.

  1. def grabNewImages( self ):
  2. """ Recurses thru directories and looks for images to upload. I only want to upload my ‘5-star’ images, so we scan the IPTC tags for ‘r5′, my way of tagging my pics I really like (usually get prints of r5s) """
  3. images = []
  4. for dirpath, dirnames, filenames in os.walk(IMAGE_DIR):
  5. for f in filenames :
  6. # Grab IPTC keywords
  7. info = IPTCInfo(os.path.join(dirpath, f))
  8. # Is it a 5-star photo?
  9. if ‘r5′ in info.keywords:
  10. print ‘File to upload:’,os.path.join(dirpath, f)
  11. ext = f.lower().split(‘.’)[-1]
  12. if ( ext == ‘jpg’ or ext == ‘gif’ or ext == ‘png’ ):
  13. images.append( os.path.normpath( dirpath + ‘/’ + f ) )
  14. images.sort()
  15. return images

Windows on my Mac with VMWare Fusion

Windows on my MacI’ve been running Windows XP Pro on my MacBook Pro for a few weeks now, and I have to say, I’m quite pleased. I have XP installed as a BootCamp partition, and at first, I booted into XP to do any GIS work. Lately, however, I’ve been working strictly in the VM, and ArcGIS works like a champ, a little bit slower, sure; but still quite reliable and stable. For the VM, I have allocated 1GB of RAM (I’m maxed out at 2GB, I have a first generation MBP) and both processors. I installed a Ubuntu Gutsy VM the other night, and that is one sweet little package. I’ll definitely be playing around with that some more soon.

Apple support rocks; wait, maybe not; OK they do

My battery on my almost 2-year old Macbook Pro finally crapped out, as pretty much all Apple batteries do I’m finding out. So I did some research and found out there was a battery recall for Macbook Pro batteries, but mine didn’t qualify according to the serial number, oh well. I then went for the advice of my local Apple retailer, who informed me that I might be able to talk Apple into giving me a new battery, based on some of the poor statistics I had gleaned from the System Analyzer about the battery - basically it was a bad battery. Sunday night I called Apple support (for the first time ever), answered a few simple questions to the automated voice recognition thing, and within about 3 minutes, was on the phone with an actual human being in the United States. Holy crap - Apple support rocks. I plead my case, she tells me that it sounds like I have a bad battery, but then tells me that my battery, based on the serial number, does not qualify for the battery replacement program. Sorry, a battery is considered a consumable item after one year. I say no way, its charge capacity is too low, it has only had one-half of its lifetime charge cycles, and you admit it’s bad. I want a new one (maybe they don’t rock after all). I hold (while she presumably goes and talks to an engineer about the matter) and then I’m told that they will replace it. They do rock! Monday I try to get a replacement from my local retailer, but they are out of stock, so I call Apple back, wait for ZERO minutes, only to get the same tech that helped me the day before - cool! She says they will have a battery out for me in no more than 2 business days; this was at noon yesterday. I come home for lunch today and find the battery waiting for me - about 24 hours after the order was put in. Not bad, eh? Apple support rocks.