The development environment is dead! Long live the development environment!

March 9th, 2011

Everyone who writes code that involves a database has had at least one day like the one I’m having right now.

I’ve reached the point where I’ve installed so many tools that they’ve started fighting with each other.  They can’t agree on whether the root should have a password or not, and most of them demand exclusive access to one service or another.  More than half of them were installed for a one-time use anyway, and the problems that they’re now causing far outweigh their brief usefulness.

So what does one do when faced with an uncooperative development machine?  One becomes the cleansing wind, and uninstalls with impunity.

Between the PHP-based CMS sites for which I write themes, and the web apps for which I occasionally write stylesheets, I’ve figured out that I really only need two tools: Visual Studio (which uses MSSQL) and XAMPP (which uses MySQL).  Different databases, no conflicts!

So a significant chunk of my afternoon is being spent clicking Next, waiting several minutes, and repeating.  Boring and frustrating because I could be working, but ultimately rewarding because things will work.

(Re)Learning Spanish

March 1st, 2011

My resolution this year is to make one small change to my daily habits every month.  Last month, I started drinking the widely-recommended 2.5 liters of water every day.  This month, I’m re-learning Spanish.

I was moderately fluent when I took Spanish in high school, but I didn’t continue speaking it, so I lost it due to disuse.  I can still recall most of the basic grammar and such, but my vocabulary is shot.  I’ve loaded some instructional CDs into my BlackBerry, and am listening to them on my walks to and from work.  Although I’m still working through the less-than-challenging bits (“excuse me sir, where is the bathroom?”), it’s definitely helping me reconnect with those forgotten skills.

My girlfriend is far more fluent than I am, so I get to practice at home.  It’s going to be a good month!

New FrogSlayer site launched

February 24th, 2011

I’ve been stepping up my WordPress development skills, and I’ve put up a new FrogSlayer.com today that’s far better-looking than its predecessor.

FrogSlayer Software Development

I’m working on a few other WordPress themes at the moment, and I’m trying to decide if I like Microsoft WebMatrix.  I’m sure it will come in handy for deploying some CMSes with which I’m less familiar, but it’s actually easier to deploy WordPress without it (using XAMPP instead).  The Visual Studio-esque file editor is nice, but get this — it lags. Seriously.  Both of my laptops have dual-core processors and 4 GB of RAM, and neither one should lag on text entry.

I think I’ll stick with Notepad++, thanks.

Sick week

February 17th, 2011

I have the flu, and it’s my own fault.

We have a rule at FrogSlayer: Don’t come to work if you’re sick. We’re usually pretty good at following it, but we had a client going public last week with a product we were developing.  The pressure was on, and our dev leads were coming down with fevers.

Here’s where we screwed up.  Our client was urging us to rally our troops, so we called the sick ones to check their status.  We told them that we needed them, but told them we’d manage if they couldn’t make it.

They came to work.  The result?  4 strains of influenza chewed their way through the office last week.  This week, no work is getting done.  We’re not happy, our client isn’t happy, and our employees aren’t happy.  Also, we’re not getting paid.

We should never have asked our employees to break the don’t-come-to-work-if-you’re-sick rule, and now we have to figure out if they came in because they’re a bunch of badass heroes, or if they felt like they had to because we asked.  Either way, the outcome was horrific, and we will never repeat this mistake.

Don’t ever ask a sick employee to come to work.  Trust me — you can’t afford it.

Reloading Posts to WordPress

February 7th, 2011

Since witnessing the travesty that was GoDaddy’s Superbowl ads, I’ve never been more pleased to have moved to BlueHost.  That’s not to say that the transition was easy.

One of the WordPress sites that I moved had a large number of posts, and I really didn’t want to have to re-categorize them; but try as I might, I simply couldn’t get the category data to import correctly.  Due to some deployment issues I was working through, I didn’t want to import the entire database from the old deployment — just the bigger pieces of it.  I won’t bore you with the details — suffice it to say, it took me a few tries before I figured out the exact procedure to get this done.

Here are a few steps that you can take if you need to import your posts from one WordPress database to another without importing the complete database.

NOTE: Please make backups of all of your files before you follow any of these steps.  As with everything I post here, this is what worked for me — I can’t guarantee you’ll have the same results!

First: Export the tables you need.

I use PHPMyAdmin with XAMPP on my laptop for development.  You’ll need to adapt these directions in you’re using a different database tool.

Fire up XAMPP or log into PHPMyAdmin on your web server.  On the left, select the database from which you want to export your tables, and you should get a list of tables in that database.

Click on the Export tab.  Select these tables in the Export window:

  1. wp_commentdata
  2. wp_comments
  3. wp_postmeta
  4. wp_posts
  5. wp_terms
  6. wp_term_relationships
  7. wp_term_taxonomy

At the bottom, under Save as file, you can save the name template if you want, but it’s not necessary.  Since a lot of web servers will place file size limits on uploads, I recommend compressing with “gzipped” compression.  PHPMyAdmin will decompress the file automatically, and it significantly reduces the size of the file.

Click Go in the lower right corner, and you’ll get a backup file that includes those tables.  If you didn’t change the filename, it will be database_name.sql.gz.

Second: Clear the tables in the target database.

Now that you have what you need, log into the PHPMyAdmin interface on the web server where you’re uploading the data.  Click on the name of your database on the left, and you’ll be presented with a list of the tables on the Structure tab.

In the Action columns, go through the tables listed in the first step one by one, and click on the Empty icon (the trash can).  This will clear the contents of the tables, but leave them intact.

Once that’s done, click on the Import tab.  Under File to import, click on the Choose File button, and browse to the .sql.gz file that you exported earlier.

Click Go at the bottom right.  Once it’s finished, you should get a message telling you that the upload was successful.

That’s it!  Check your WordPress site, and all of the posts should be properly loaded and categorized.

Deploying WordPress the Hard Way

February 3rd, 2011

I had a WordPress deployment ordeal this week.  I developed a site with WebMatrix, and I needed to deploy it to an internal server that did not have the Web Deploy service running on it.

My first thought was to install Web Deploy.  I gave up.  Among my many skills, setting up Web Deploy does not appear.

I’d already added a bunch of links, uploads, and a few custom tweaks that wouldn’t be caught by a simple export/import through the WordPress admin interface, so I had to roll my own method to back up the entire database and get it online.  I pulled heavily from the WordPress Codex, and found a few other snippets online.  Here, in all its horrific glory, is the Hooker Method of moving a WordPress installation from a development box to a server.

NOTE: I’ve done this exactly once, and there was a lot of trial and error along the way.  PLEASE make backups of all of your files before you attempt to follow my steps.  While following these directions should not present any danger to your original work, I do not offer any guarantees that the steps that worked for me will work for you.

1. Back up the database

Assuming you’ve got the whole thing already working on your laptop (or whatever it is that you use), your next step is to run a mysqldump to create a backup of the file.  mysqldump is included with MySQL, but it is not referenced through the MySQL command line client (because it’s a separate executable).  Here’s what you do:

  1. Open a command prompt.
  2. Browse to the directory where the mysqldump.exe file lives (on my standard installation, it’s in C:\Program Files\MySQL\MySQL Server 5.1\bin).
  3. Type at the prompt: mysqldump -u username -p database_name > “path/filename.sql”
    1. username: Your database username
    2. database_name: The name of the database you’re copying
    3. path: The location where you want the file to save.
    4. filename: Whatever you want — it’s the name of the backup file you’re creating.
    5. example: mysqldump -u samhooker -p wordpressDB > “C:\Users\Sam\Desktop\wp-backup.sql”
  4. Hit enter, and you’ll be asked for your password.  Enter it, hit enter again, and you’re done.

Note:  You can enter a password after the -p, which can be handy if you’re creating a batch file.  I leave it out so it’ll prompt me — it then displays asterisks as I type, which helps protect my password from anyone looking over my shoulder.

In the example listed above, I created a backup of my database named wp-backup.sql on my desktop.

2. Transfer files to your server.

You’ll need to have a complete copy of your WordPress directory (the one with your wp-admin, wp-content and wp-includes folders), as well as the database backup that you made in step 1.  Use FTP or whatever other means you use to get those files uploaded to the proper directory on your web server.

3. Create the database and database user.

This assumes that you already have MySQL installed on your web server, and have login credentials that will allow you to create a database.

  1. Start the MySQL Command Line Client.  You should be able to get there by going to Start –> All Programs –> MySQL –> MySQL Server 5.1 –> MySQL Command Line Client.
  2. You’ll get a command prompt that asks you for a password.  Enter the root password for your MySQL installation.  If you don’t have the root password, you can log in with another user account (that has admin access to the database you’re working with) by taking the following steps:
    1. Open a command prompt.
    2. Browse to the directory where your mysql.exe file lives (mine is C:\Program Files\MySQL\MySQL Server 5.1\bin).
    3. Type mysql.exe -uusername -ppassword and hit Enter.
    4. You should be logged in and have a mysql> prompt.
  3. Type at the prompt: create database database_name;
    1. database_name: the name if the database you backed up in step 1.
  4. Type at the prompt: grant all privileges on database_name.* to ‘database_user‘ @ ‘host‘ identified by ‘password‘;
    1. database_name: The name of the database you just created.
    2. database_user: The database user you created with your original installation
    3. host: the domain on which the database resides, often localhost
    4. password: The database password you created with your original installation
    5. Note: You can easily find all of your previously-entered information in the wp-config.php file in your WordPress directory.
  5. Hit enter, and the database user will be set up.

4. Install WordPress

Browse to your WordPress installation in a web browser, and you’ll get the wp-admin/install.php page.  Fill in the requested information, and it will connect to the database you’ve set up.  You’ll be able to log in now, but the database will be populated with the familiar old “Hello, World!” garbage.  Time to apply the database!

5. Import the database

Now that you have a database and user set up on the server, you’re ready to import the backup you made in step 1.

  1. Open a command prompt and go to the bin directory mentioned in step 1.
  2. Type at the prompt: mysql.exe -uusername -p database_name < “path/filename.sql
    • example: mysql.exe -usamhooker -p wordpressDB < “C:\Users\Sam\Desktop\wp-backup.sql”
  3. Hit Enter.
  4. Enter your password, hit Enter again.

Depending on the particulars of your installation, you may still have a few wrinkles to iron out — namely, you may have to fix the siteURL info.  There are a lot of factors to consider here, so if you’re having issues, I recommend having a look at this Codex article: Changing the Site URL.

Happy deploying!  If I missed any steps, leave a comment and I’ll edit later.

GoDaddy and I broke up.

January 30th, 2011

Sometimes, sarcastic web developers and misogynistic hosting providers simply grow apart.  I hope my readers understand that it’s not their fault.

I’ve been avoiding the drudgery of switching providers for awhile; but since most of my domains are expiring this month, it was time to either slog through it or give GoDaddy a bunch of money.  Had I seen just how ridiculously sexist their commercials were before I’d originally signed up with them, I never would have done so in the first place.

(FYI, their admin interface sucks too.  Not only was it impossible to find anything, they changed it every week.)

I’m much happier with BlueHost, not to mention richer.  $6.95/month for unlimited hosting?  I was paying that for one site with GoDaddy!  Not a paid advertisement, by the way — just a satisfied customer.

I transitioned this site first just to get a feel for it, and it could not have been easier.  Doing the rest of them this week.

Drinking Water

January 25th, 2011

I made a New Year’s resolution this year.  I resolved to get into shape.  The only degree of steadfastness that I’ve achieved in this regard is my unwavering dedication to making this same resolution every year, and then failing to follow through.

Why get into shape? My job doesn’t depend on it, and my girlfriend thinks I’m hot stuff whether I can run a 5k or not.  Beyond the prospects of looking better, living longer or becoming capable of surviving the impending zombie apocalypse, being in shape simply makes me feel better.

Why do I fail? That one is easy.  Every year, I either come up with a vigorous training regimen that’s far easier to dismiss under the banner of “I don’t have the time,” or I don’t come up with a plan at all.

My best attempt happened a couple of years ago, when I was working the night shift.  When I got off work at 7am, I would hop on my bike and ride 15-20 miles.  Afterwards, I’d eat a healthy “breakfast,” watch TV for an hour or two until my body relaxed, and go to bed.  I was the strongest I’d ever been, I felt great, and motivation was never a problem.

It all came crashing down when I moved to a daytime shift.  I blame the fact that I was then available for social interaction.  I still rode, but not regularly.  I lost the regimen.

Enter Tim Ferriss. I picked up The 4-Hour Body by Tim Ferriss on my Kindle.  I’d previously read his other book, The 4-Hour Workweek — I wouldn’t say that I’m a firm disciple of every method he preaches, because some of them are simply outrageous.  The thing is, that’s what I like about him.  He’s big on self-experimentation, and a lot of his work reads like stereo instructions written in Latin in crayon.

He receives a lot of bad press from people who try to follow his books with biblical fervor, and then feel betrayed when they don’t get the results they want.  He’s the first to say that most of his work is based on self-experimentation, and he doesn’t spend a lot of time verifying his results.  He does some verification, but he’s more interested in applying what he learns to his own life.  Isn’t that an admirable characteristic in a life-improvement guru?

If you take any advice from Tim, keep in mind that your mileage may vary.  He’s actually the first to tell you that.

So what am I going to do? Unlike Tim, I don’t get to spend my days reading nutrition manuals and talking to world-class athletic trainers.  I need to take a piece of his advice and start small.  According to Tim (and I’m paraphrasing), the most effective exercise is the one that you actually do. Even if it’s not the most efficient strength-building exercise, if it’s easy enough that you’ll do it consistently, it’s a good idea.  One push-up per day is better than zero exercise, right?

I’m not starting with exercise.  I’m going to drink water.

According to a few websites I read, 2-3 liters of water per day is what I should be drinking.  I’m not even close.  I haven’t been getting on my elliptical in the morning because I don’t feel good enough to work out when I wake up.  Obviously, I need to take a few baby steps to build some momentum.

My theory is that properly hydrating myself will improve my general health to the point that I will feel good enough to start doing actual exercise.  Starting today, I will drink 2.5 liters of water every day for one month.  That’s it — next month, I’ll get on the elliptical if I feel up to it.

I’ll chart my progress and make no more than one easy change in my daily habits every month.  Wish me luck!

Solving Self-Motivation Problems

January 24th, 2011

It happens to all of us from time to time.  Even in the face of a rapidly approaching deadline, we find ourselves staring at our desks, reading web comics, or shopping for new books to order online and never find time to read.  Entire days can be lost to unshakable ennui.

At FrogSlayer, we have a burnout policy: if you’re burned out, take a day off.  Come back tomorrow when you’re refreshed, and put in a proper day’s work.

We also have a Don’t Be A Hero policy, which discourages working more than 40 hours a week (and forbids working over 50 hours a week).  A well-rested software developer can accomplish more in one hour than an overworked one can with an extra 10 — and his work will be better.

Unfortunately, a lot of companies have not embraced more progressive policies.  If you can’t get away for a day to reset your brain, the solution is a sprint – a brief period of time, during which a specific goal is accomplished.  Here are three steps that you can use to get yourself back on track:

Step 1: Pick a 10- to 30-minute task.

Start by picking a simple task from your to-do list.  Preferably one which will take you at least 10 minutes, but no more than 30.  It’s important to stay within this range.  If your work isn’t time-sensitive (writers, for example), resolve simply to work on your task for 20 minutes.

Step 2: Take a 10-minute break.

Go outside for 10 minutes.  The break room will work in a pinch, but getting some direct sunlight is miraculously refreshing.  10 minutes of sunlight stimulates production of serotonin which can improve your mood, as well as release endorphins which are essential for combatting depression.

Don’t look at a screen, including the one on your phone.  Just breathe, and enjoy the calm before the storm.

Step 3: Attack your task.

Go to the bathroom, grab a drink or snack, and head back to your desk.  Ignore all distractions, and work until the task is done or until your time limit is reached.  You should find yourself free of the ennui and ready to face the rest of your day.

As mentioned previously, the 10- to 30-minute time period for this task is essential.  Anything less than 10 minutes is not enough time to establish the working rhythm, and anything more than 30 minutes pushes the feeling of accomplishment  too far away to keep you motivated.

Good luck, and don’t underestimate the benefits of caffeine in a pinch!

Evolution of Web Standards

October 11th, 2010

Web standards, in a nutshell, are the reason that your computer and my computer display content from the World Wide Web in the same way.  When the concept of web pages was first unleashed, we had something of a Tower of Babel situation on our hands.  All of the key pioneers of web technology were striding boldly forward, creating new solutions for displaying web content without regard for what their peers were doing.  Developers were writing code that produced amazing results when viewed in Netscape Navigator, but was utter gibberish in Internet Explorer.

Eventually, developers got tired of having to develop two or three versions of every page they wrote, and turned their efforts to writing code in such a way that it would work in any browser.  This made for some ugly and convoluted code.  Then Sir Tim Berners-Lee founded the World Wide Web Consortium (W3C) in October 1994, and they set to work on writing a standard for HTML.  Over time, the W3C was able to exert enough influence over people in the business of building web browsers, and they started to fall in step with the HTML standard.  This was a great thing for guys like me in the website business, because it meant each page only had to be made once, using one set of rules.

Internet Explorer’s user market share recently dropped below 50% for the first time in over a decade — probably because more savvy users have recognized that Microsoft simply isn’t as interested in innovation on the Web as its competitors.  Since the W3C sets the standards, they also have a great deal of control over our rate of innovation.  That comes with a responsibility  to drag browser producers, kicking and screaming if necessary, into compliance with modern technologies (or fall by the wayside).

The problem now is that pendulums swing both ways.

Most of us in the web development business are bursting with enthusiasm for the new HTML5 standard.  It’s already in use by most of the major browsers, but a lot of developers are loathe to use it because it’s not fully supported.  (I’m not using it here on samhooker.net because it would mean re-designing my site, and I’m content with the way it is, for now.)

Another (more woeful) reason that HTML5 is not being more widely used at present is the W3C’s assertion that it needs a lot more work before it’s ready.  So much work, in fact, that it’s not going to be ready until 2022, according to their timeline.

I’d like to share a screenshot I took from CanIUse.com, a really handy tool that tells us which features are supported by which browsers.  This screenshot shows a summary of browser compatibility with HTML5 and CSS3.

You can see that the current versions of FireFox, Safari, Chrome and Opera are between 73% and 90% compatible with HTML5 and CSS3.  Internet Explorer, on the other hand, is at a pathetic 16%.  Even with the release of IE9 next year, current projections do not show Internet Explorer offering the same levels of feature support that other major browser offer now.

As the browser with the highest market share, I am sure that Microsoft’s slow progress is a major contributing factor to the W3C’s 2022 estimate.  But given the strides that web technology has made in the 17 years since the birth of the web, doesn’t 10 years until the next big step seem overly cautious?  I feel that a more aggressive approach to developing the official HTML5 standard is crucial to our rate of innovation.  Whether the W3C’s inertia is due to waiting for Microsoft to catch up, or to the organization itself becoming top-heavy with obsessive bureaucracy, it’s time to shake things up.

Internet Explorer’s market share