Archive for November, 2009

From MySQL to Postgres

Slowly, I’m making the transition from MySQL to Postgres.

I’m not a database expert, but I’ve had quite a bit of experience working with them and designing them. For the first eight years or so of my experience working on the Web, my exposure was mostly limited to MySQL. But as I started playing around with Django, I decided to go with its authors’ recommendations and see what all this Postgres hoopla was all about. After a while, I noticed that it was faster and much less resource-hungry on my system.

Which is awesome. I’m on a VPS. I like to know that I’m running as lightweight a setup as possible. I’m a huge fan of efficiency.

So I got curious: could I port all my existing apps over to use Postgres instead? The problem is that MySQL and Postgres don’t exactly speak the same language. It’s similar in a lot of ways, but of course, computers are finicky contraptions that demand exact translations, with the exact characters it expects, in the exact format it wants.

For many of my old personal projects, this wasn’t terribly difficult. It was just a matter of writing a few scripts to export my relatively simple data into a format that Postgres would easily understand.

The first big challenge I came across, though, was in porting my MediaWiki installation over. My first instinct was to do as I had with my own projects: dump the SQL and transform it into Postgres-digestible code.

I googled and coded and googled some more, and after several hours of trying to get this to work, I realized it was a dead end. It then dawned on me that there was no reason to even attempt to do what I was doing. It made more sense to do an export of the data, to XML, and then import it into a fresh installation of the app with a fresh Postgres database.

There were a few gotchas, but it was basically very easy at that point. One hour worth of work vs six.

So the steps were pretty easy:

  1. Use the export script to export the data from the existing MySQL MediaWiki installation:

    php-cgi /maintenance/dumpBackup.php wikidata.xml

  2. Initialize a new database in Postgres.
  3. Set up a fresh installation of MediaWiki on a new path. Follow the setup wizard, using your new Postgres database information.
  4. After installation is complete, delete the Main Page that MediaWiki sets up for you.
  5. Copy the wikidata.xml file to the /maintenance folder in your new MediaWiki installation.
  6. Run the MediaWiki script to import the data:

    php-cgi /maintenance/importDump.php wikidata.xml

And that was it. Very easy.

I have a few more challenges ahead of me that I suspect will require a lot more hands-on work than what it took with MediaWiki. The main one will be a project I’ve intended to do for a while — converting a vBulletin installation to use a different forum platform altogether. There will be a lot of custom code. It should be fun.

I suspect that it will be complicated and may even be impossible to manage the various blogs I’ve created over the years. Half of them were built in Movable Type. Half are in WordPress. I’d like to make my life just a little easier and pick one or the other. Movable Type supports Postgres natively, whereas WordPress sports an unofficial plugin. It might work, but my coder-instincts are telling me not to get my hopes up too much. If the latest versions of Movable Type are comparable enough to WordPress, I might decide to go nuts and move everything over to Movable Type instead.

We’ll see. For now, I have a few more important things to take care of before I embark on any strictly-maintenance-and-upgrades kind of work. More to come.

Dolla Tree

Dolla Tree Sign

i swear
thirteen times a day
some smart-ass jerk asks me why is there no R in your sign
so i stare them in the eyes
and i say

look
if there’s one thing i care about
one thing
it’s providing a good service
good products
to good people
and if there’s one thing i hate
it’s seeing people get ripped off
all spending their money
their hard-earned money
and getting less for it than they used to
it’s a shame
and it makes me angry
so angry

now you know and i know
that there’s an R out in that sign
but are you going to see me spend all kinds of time and money
to repair some dumb sign
that you and i both know what it’s saying?
because i could

but then you see
i’d have to raise my prices
to probably, a dollar five, dollar six

signs are not cheap, amigo

i am not
not
going to become one of those people
pissing money down the disposal
like it’s all plentiful
because it isn’t

not where i grew up anyway

i think they feel pretty bad after that
so they stop asking

i guess that’d be okay
if they ever came back

Photo by Jeff Young

Tech support

I don’t know if I’m getting better at what I do, or if technology is just getting easier, but I’ve noticed lately that it’s taking me far less time to accomplish what I set out to do, when I’m working on the computars.

Latest example:

I upgraded my server to the next full version up — sort of the equivalent of going from Vista to Windows 7.  But in the process of upgrading, postgresql — my database of choice — got bumped up a version as well, and in the process, the default character encoding was reset to SQL_ASCII.  Not UTF-8.  WTF, right?

So after a little googling, I found the remedies I needed: how to set the default locale in Ubuntu so that it uses UTF-8, and how to essentially wipe out postgresql’s default template and replace it with the one you want.

This pleases me because I got it done in about a third of the time it might have taken me two years ago.  That, my friends, is progress.

Jetsam

I’m running through about a terabyte of data from old computers and finding some interesting stuff.

For example, here’s a real gem.  I don’t know how this ended up as a Word doc on my machine (e-mail attachments from grandmothers probably).  Since the original author was apparently so excited that he had! to! write! everything! in! bold!, I’ve helpfully highlighted the amazing news below.  Enjoy.

Mars is going to be a second moon of earth for a day

Close-up of the Red Planet

NO ONE ALIVE TODAY WILL EVER SEE THIS AGAIN.

The Red Planet (MARS) is about to be spectacular! This month and next, Earth is catching up with Mars in an encounter that will culminate in the closest approach between the two planets in recorded history.

The next time Mars may come this close is in 2287. Due to the way Jupiter’s gravity tugs on Mars and perturbs its orbit, astronomers can only be certain that Mars has not come this close to Earth in the last 5,000 years, but it may be as long as 60,000 years before it happens again.

The encounter will culminate on August 27th when Mars comes to within 34,649,589 miles of Earth and will be (next to the moon) the brightest object in the night sky. It will attain a magnitude of -2.9 and will appear 25.11 arc seconds wide. By August 27, Mars will look as large as the full moon to the naked eye. Mars will be easy to spot.

At the beginning of August it will rise in the east at 10p.m. and reach its azimuth at about 3 a.m. by the end of August when the two planets are closest, Mars will rise at nightfall and reach its highest point in the sky at 12:30a.m. That’s pretty convenient to see something that no human being has seen in recorded history. So, mark your calendar at the beginning of August to see Mars grow progressively brighter and brighter throughout the month.

Share this with your family, friends, children and grandchildren!!!!!!!!!!!!

As Snopes helpfully points out, someone left out a key clause here — that Mars is only going to look that big with the aid of 75x power optics. Like a small telescope. Or binoculars. But not the naked eye.  Fools.

Clutter

Clutter impairs your ability to think.

It’s like cholesterol, clogging things up.

Relax.

“I was playing good and giving my team its best chance to win,” McCoy said, “but at the same time it was not fun. I was beating myself up. I kept digging myself deeper and deeper in a hole that I couldn’t get out of.” [...]

The people around McCoy say they didn’t notice a whole lot different about him. But McCoy felt it. He brooded. He didn’t reach out to his young receivers. He could feel his usually open personality closing up.  [...]

[But then] “The week after Oklahoma, I let myself go,” McCoy said. “Forget about everything. I walked up to Coach [Mack] Brown and Coach Davis and said, ‘As far as I’m concerned, we’re 0-0. This is going to be my first game. I’m starting over completely.’

Ivan Maisel, Colt McCoy overcomes worst critic to lift Texas Longhorns.

Slicehost

I accidentally shut off SSH access to my web server tonight, leaving me without a way to log in and work on my projects.  It’s as if I locked my keys in my car.

Unbeknownst to me, Slicehost‘s control panel let me fix all this.  I looked in my slice’s control panel and found a web-based terminal — basically a back door into my server.  I logged in, opened SSH back up, and I was done.  I got what I needed within 3 minutes of looking for an answer — without needing to call support.

A great service provides what its customer needs, even if he doesn’t know he needs it.

Sabbatical

I have more ideas than time right now.  It’s fantastic to have the time to develop them.

Stuff is getting done.  Life is good.

Enjoyment

Every now and then, when I’m in the middle of coding in a project that I care about, I get a feeling of delight as things happen just the way I want them to.

I feel powerful.

Signs of life

Clementine oranges?!  I’m alive!

Return top