Arlo's Blog

Backups, backups, backups

March 7th, 2010 | Add a Comment »

I’ve always been fanatical about backups, based on the mantra that in the computer age, one should never have to do the same work twice. My standard policy is that I keep all project files in a version control system, back up my computer daily, and make an offsite backup monthly. This works great with the development model where I create all the files in a website on my computer, then upload them to the remote server. My computer is, essentially, the master copy and the server files are secondary.

When my favorite hosting company had an incident recently, losing data for two of my clients’ sites, I realized that this model is quite outdated. Modern websites consist of much more than the developer’s files. With a content management system, my clients are adding content and files from different locations that are only collected in one place on the server. And with a social networking site, users are adding content constantly, without which the site would be worthless. Without an automated backup of the site’s database and root directory, replacing content added by the clients is time-consuming, and replacing content added by users is impossible.

My solution is a new system I’ve created for my clients. It allows me to configure automated backups of the database and the root directory, at different intervals if needed, as frequently as once per hour. I and/or my clients can receive email notifications of every backup, and every backup failure. The backup files are saved at a different datacenter than any of the sites, and are available to clients any time at a password-protected web page. Clients can even log in and run a manual backup at any time.

This should bring my backup strategy up to the level of my current website development. I can’t say I’m looking forward to using it, but I do like knowing it’s there!

My first iPhone app

February 11th, 2010 | Add a Comment »

This week I achieved a goal that’s been simmering on the back burner for a while: getting started with iPhone app development. Apple calls each of its new products “revolutionary,” but the iPhone platform (which also includes the iPod touch and the upcoming iPad) actually is, because it creates new ways to interact with the device. Beyond moving a mouse or clicking a button, the iPhone responds to movement, multi-touch and even puffs of air directed at the microphone. Because of the latter, virtual musical instruments are a popular app genre, and since I’m a musician that’s where I put my foot in the door.

My app is designed for aficionados of jug band music, a form of traditional blues and jazz played on homemade instruments. The app includes a washboard, spoons, kazoo and jug. The trick is that they each play like the real instrument: you rub the washboard, tap the spoons against your knee, hum into the kazoo and buzz your lips into the jug. I made a demo video to show how it works.

Programming for this device was pretty brutal, because most of my experience is with the loosely-typed PHP, and the iPhone runs on the strongly-typed Objective C. Simple commands that would have taken me less than a minute in PHP took me hours in Objective C, until I started thinking in terms of data types. The syntax was killing me for a while — figuring out where to place an asterisk, an at-sign or a square bracket — but I’ve experienced that in moving from JavaScript to Perl to PHP over the years. I’m working on a second app now, and the new challenge is memory management, but I’m getting the hang of that, too.

I was especially curious about the infamous App Store approval process, which Apple uses to ensure quality apps and, some suspect, protect its business interests. But I didn’t have any problems here. The code-signing process was cumbersome, but I followed all the tutorials and my app was approved on the first try. If you have an iPhone or iPod touch and can spare $.99, you can buy a copy now. Who knows, you might even get hooked on jug band music!

Google, stupid, etc.

February 2nd, 2010 | Add a Comment »

The article “Is Google Making Us Stupid?” is a year and a half old, but I keep running into it:

http://www.theatlantic.com/doc/200807/google

The premise is that because we now have instant access to a wealth of reference information online, we’re losing our ability to read long passages, concentrate and think. I disagree; here’s why.

Regarding access to reference information, I think that’s a quantitative rather than qualitative difference from the pre-Internet days. When I was reading books in school, I was always encouraged to look up a word in the dictionary if I didn’t know it. I never did it much, but I do it a lot more now that I can access a dictionary online with a few clicks. If that was good advice with a book, how could it be bad advice with a computer? Now I can not only look up vocabulary words, but local wildlife, art history and world politics as I run across them in my daily life. I would conclude that this makes me more intellectually curious — because it rewards my curiosity with new knowledge — not less intelligent.

As for reading long passages, I use the web as much as anyone, and (compared to other people I’ve browsed with) I’m quite good at seeing how the information is organized on a web page and jumping from one link to another. I also do a lot of skimming, as the author describes. But this is when I’m looking for something in particular, like a street address or a bit of programming code or a song lyric. I did the same thing in college when I was researching a paper at the library. Reading for enjoyment is a different skill, and I haven’t lost it. When J.D. Salinger died last week and I decided to revisit The Catcher in the Rye, I read it in two, three-hour sittings.

Perhaps a lack of concentration is the author’s real problem, but I don’t think that comes from using the web. Like a book, that goes at our pace and doesn’t interrupt our train of thought. That’s not the case with other technologies like television, telephones and instant messaging. I tend to use those as little as possible when I’m working, but if they were talking, beeping and flashing at me all day, I’d probably feel like the author does.

I guess my motto would be, tune out, turn off, log on!

Oops, forgot the attachment

January 14th, 2010 | Add a Comment »

I’m a pretty detail-oriented guy, but the number of times I’ve sent an email message without the attachment I referred to is unnerving. A while ago I had the idea that if my email program could scan for the word “attachment,” and an attachment wasn’t present, it could show an alert before letting me send the message to confirm whether I meant to include one. I decided to try and write an AppleScript plug-in for Entourage, my email program at the time, and put it on my low-priority to do list.

Before I had time to do that, I switched from Entourage to Thunderbird, and was delighted to find that such a plug-in already exists. I tried it and it worked exactly as I had imagined:

http://sourceforge.net/apps/mediawiki/attachreminder

Then I switched from Thunderbird to Apple Mail, and found a plug-in for that, too:

http://eaganj.free.fr/code/mail-plugin

I haven’t used them, but it looks like similar plug-ins are available for Gmail and Outlook:

http://www.techsuperb.com/email/forgotten-attachment-detectors-for-gmail-and-outlook/1536.html

I’m afraid that still leaves Entourage without a similar feature, but it won’t be me who builds it — I’m happy with my new mail setup.

Web vocabulary

December 29th, 2009 | Add a Comment »

One interesting aspect of working with the Internet is watching the technology evolve faster than the vocabulary used to describe it. We’ve all seen new terms like “blog” and “podcast” become instantly popular, but what about technology that hasn’t even been named yet? I’m not creative enough to come up with the names, but I’ll start a list of the concepts that need naming:

  • When you perform a Google search, and the answer is visible on the search results page, so you don’t even have to click one of the results.
  • Variation: When you perform a Google search using your browser toolbar, and the answer is visible in the search shortcuts that appear while you type.
  • Blogs that consist solely of funny pictures related to a theme (e.g., icanhascheezburger.com, cuteoverload.com and failblog.org). As my wife can tell you, there are hundreds of these!

Can you suggest a catchy name? And what other new Internet terms should I add to this list?

OOP in 09

December 17th, 2009 | Add a Comment »

As a web developer I’m constantly looking for ways to improve my techniques, and one big change I made this year worked out better than expected. For the two large sites I built from the ground up this year (and a third, smaller site), I used Object Oriented Programming (OOP) for the first time.

I’d tried wrapping my mind around OOP many times over the years, and it always seemed like something useful for game programming, not web development. But it finally clicked when I found this user comment in the PHP manual, and I decided to give it a try at my next opportunity.

On the first project, I spent an extra 20 or 30 hours up front just thinking about how I wanted to use this technique. I ended up with a Base class that handles routine things like escaping quotes in database values and dealing with the discrepancy between saving a new record and updating an existing record. More importantly, I had to figure out what code would live in the Base class, what code would live in the other classes (like Order, Customer, etc.) and what code would live in the page scripts (like store_checkout.php). Eventually I found the right balance, and the second project went more quickly than it would have without OOP — a pretty fast return on investment. Since then, I’ve found updates and enhancements to be, maybe not quicker, but more reassuring because I know that all the related code is in one class.

My favorite thing about this approach is that it allows a greater degree of abstraction in my code. I always use Contemplate to separate design, content and functionality from each other. But OOP makes it easy to further separate functionality into data processing and data storage. It’s been easy to put SQL code only in the classes, and as a result, I only have to change a few files if my database structure changes. In fact, I quickly extended my Base class to store data either in a database or in a session — which is useful for something like a multi-page registration form that doesn’t create any records until the last page — and this distinction is completely abstracted from my page scripts, which only care that the data is being saved. If a new technology ever comes along to replace SQL databases in web development, and these sites are still around, it will be relatively easy to convert them.

I still have a couple adjustments to make in my programming style (for example, expanding my naming conventions to accommodate the variables I use for object instances) and I may be overusing static methods (which, beyond being organized into classes, are no different than traditional functions). But I’m sure that I’ll continue using this technique into the coming year and beyond.