Break All the Windows

For reasons that escape me, timed processes on my Windows box(es) just stop for no good reason. I’ve mentioned this before; the latest casualty was mySQL replication (Linux box => Windoze box).

I’ve been using the Windows box mySQL server just for backups, and to get my hand in how to run mySQL on Windows. Useful skill; one of the big pluses of mySQL is that there are native Windows binaries for it.

OK. And replication – which ran fine for over a month – just crapped out.

I couldn’t figure it out. Still can’t.

So I did what every Windows user does: Re-install the damn code.

Actually, I didn’t have the binaries for mySQL, so I got the latest v3 binaries (3.23.58) from a mirror. (I’m running v3.23 on Linux, so just trying to keep conflicts down.)

Installed, did all the set-up – which, since I just did it recently, was a breeze.

But the damn Windows mySQL server kept crashing every time I turned on replication.

After hours of poking and prodding, a Google (thank god for Google and their ilk) search gave me the knowledge that I needed: v3.23.58 on Windoze has, um, replication issues.

There’s a work around – don’t start as service, make it a stand-alone, set account with privileges for this yada yada yada.

That’s bullshit. That’s a huge bug (and I don’t really know if it’s a mySQL or Windows issue).

So I downloaded a v4 binary, installed, turned on replication and … damn! It works.

Sweet.

And aggravating – once I knew of this replication issue, the entire process – from downloading the 12M (or so) binary file, installing, setting up permissions, cutting data over etc – took about 15 minutes.

I spent hours trying to get something that couldn’t work to work.

Who do I bill those hours to???

mySQL/Perl Gripes

Last entry I whined about Perl’s appalling lack of a trim() function.

I forgot to add another Perl pet peeve: No comment blocks.

With most languages, you can place a “/*” before a code block and “*/” after the code block and have all lines – one to (no limit) commented out. (Note: Hopefully, it’s understood that the code comment open/close characters are sans quotation marks…).

Perl, in its infinite wisdom, does not allow this.

Each line must be commented with a pound sign: #

Example:


=======

PHP

=======

/*

// all five lines here are commented out

$myVar = ” Foo Bar “;

$myVar = trim($myVar); // now “Foo Bar”; full trim

$myVar = ltrim($myVar); // now “Foo Bar “; left trim

$myVar = rtrim($myVar); // now ” Foo Bar”; right trim

*/

======

Perl

======

# Note how I have to prepend EACH line with the pound sign,

# even multiple lines of comments, such as these two….

# $myVar = ” Foo Bar “;

# $myVar =~ s/^\s+|\s+$/; # returns “Foo Bar”

OK, no big dealie for these examples, but let’s take a real-world Perl example I was just working on.

I was doing a dataload, and – before I actually fired the SQL – I had several blocks of processing code and was printing out this or that line so I could see all was well.

Once we get to that point, then fire SQL.

I got to that point, but something barfed on the DB side. So I wanted to back out this or that block of processing code and print some additional debug statements.

But – to cut out any code block – I had to either:

  • Remove the code from the file (and paste it elsewhere so it’s not lost)
  • Put a pound sign before each line in the code block – up to 50 lines

Again – with most coding languages, you just wrap the code block in the “begin/end comment” characters. Done.

Ick. I think (not certain…) that Perl 6 is supposed to support multi-line comment tags, but … too late. Lots of pre-v6 code out there that doesn’t have this support. Lots.

MySQL Rant

While I’ve gotten over my initial reaction to mySQL (“It’s not a real database! Hell, Access has better ANSI support!”) and have grown quite fond of this DB, it still keeps biting me in the ass.

Note: I’m currently running v3.23x, simply because that’s what’s supported out on shared hosting sites (that I have to work with). Version 4 fixes – to a degree – the problem I’m going to bitch about right now.

I have square marks on my forehead from banging my head on the keyboard trying to make the following work in mySQL


UPDATE

table_1 (column_name)

SET

table_1.column_name = table_2.another_column_name

WHERE

table_l.id = table_2.id

Trivial, ja?

Nope.

Can’t do multi-table updates in pre v4.0.4 mySQL.

Ouch.

So, I had to write a script that pulled data from second table, stored (array) and then updated the first table.

Yes, this is solved now – in the v4 types, but subselects still are not (v4.1 will address this; won’t be a stable release until about November 2004).

In other words: MySQL is making great strides, but v3.23 – the current standard for most sites today – “offers” significant limitations.

But mySQL is moving in a good direction. Good. Because it does have some nice features.

Please just give me what I expect from any database!

End rants.

Perl Gripes

WATCHING:
Big Fish
Tim Burton

It took me awhile to warm to this movie, but I ended up enjoying it.

Not a great movie, not one I’ll watch again for some time, but with a sweet, funny and thoughtful story line. And great imagination.

Actually, this is a movie that works better as a preview – its got some great, three-second-long shots that would translate well to previews/commercials and so on.

All movies

There’s a lot of iffy areas that Perl catches flack for – loosely typed variables, overuse of hashes, the utter incomprehensibility of some excellent code (such as a great regex to extract data – looks like a punctuation-fest).

However, my biggest gripe – and maybe I’m missing something – is the lack of a built in trim() function.

Why not??

While I understand that you can use a regex like I have above, a trim function is something, to me, that should be part of every language.

Especially in these days of XML and Web-based apps, the spaces can matter.

So you want to trim stuff before it goes into the database.

Ditto when it comes out.

But that’s me.


=======

PHP

=======

$myVar = ” Foo Bar “;

$myVar = trim($myVar); // now “Foo Bar”; full trim

$myVar = ltrim($myVar); // now “Foo Bar “; left trim

$myVar = rtrim($myVar); // now ” Foo Bar”; right trim

=======

T-SQL (MS SQL Server)

=======

— No full trim (makes me nuts, also!);

— nest left and right trims

select ltrim(rtrim(‘ Foo Bar ‘)) as myVar;

— will return “Foo Bar” for myVar

======

Perl

======

$myVar = ” Foo Bar “;

$myVar =~ s/^\s+|\s+$/; # returns “Foo Bar”

There is an int() function in Perl – that returns a string as an integer. You could write a simple regex for this, as well, but there is the more useful – and expected – int function (parseInt() in JavaScript, I believe – in database languages you often have to CAST the string).

So why not a freakin’ trim function?!?

I still like Perl in spite of it.

Linux on the Desktop

News.com ran a story today titled Plugging the Linux holes, which discusses how there are some serious problems with missing apps in Linux that make it difficult for some/many users to switch.

The article touched on the big three app gaps: Tax software (Quicken, Intuit), games and Photoshop.

A good cursory overview of what we’ve all read about before; nothing remarkable, really.

However, one sentence caught my eye:

GIMP (GNU Image Manipulation Program), an open-source graphics program similar to Photoshop, is widely considered to be close to the “good enough” status achieved by OpenOffice and Mozilla.

I just don’t agree with this. There are three issues, to me:

  • Photoshop is a killer app. While GIMP has some tools that Photoshop doesn’t have (or are part of the not-yet-integrated ImageReady), such as batching, it’s not Photoshop. And until that Photoshop functionality is there, it’s going to be a tough sell.
  • People don’t like learning: This is where OpenOffice has done well – while the interface is a little clunkier than MS Office, it’s similar enough. The GIMP, however, is different enough to scare folks off. This is huge, even though it seems trivial. Mozilla is – again – enough like IE with a slightly different look (but very similar functionality – type in address and page displays) – to not scare the average user.
  • I’m not sure about the whole GIMP installation process, but I think PSD support is a plug-in. WTF? What’s a plug-in? Where do I plug it? How do I use it? Translation: Until GIMP supports PSDs [quasi-]natively or the GIMP becomes the de facto standard Photoshop is today, it’s going to get beat up by Photoshop. Really. Not for the average Linux user – who, today, is pretty geeked out – at least. But we (the few, the pimpled, the Geek) are not the real target of the desktop Linux supporters: The non-geeks (in other words, the masses) are desired, as they are the largest group, and they haven’t been convinced yet.

My two cents.

What I’ve Been Up To

I guess this can be split into two sections – what I’ve been up to, and what I haven’t.

Onward…

What I’ve Been Up To:

  • No good.
  • Work on a batch of Perl parsers – screen scraping, processing and using Perl DBI to load MySQL. Learning a bunch. The more I use Perl, the more I admire it. The more I learn Perl, the more I realize I don’t know about the language.
  • Reading about the whole Google IPO thingee. The are a different company. Hope they stay that way.
  • Continuing my love-hate relationship with MySQL. I’m using it more and more – actually, it’s the database I’ve pretty much been using exclusively for development over the past few months – and really haven’t changed my mind about it that much. Sure, it’s fast, cross-platform (*nix and Windoze) and pretty easy to use, but its lack of power still grinds on me. Subselects (coming in 4.1 in November) and stored procs are the big rubbing point to me; I’m still confused on how this beat out Postgres in the OSS database battle. It’s unfortunate, but I understand why MySQL is so widely deployed today: Because it is so widely deployed. The chicken vs. egg battle is over.
  • Lots of PHP – it’s usually the back-end for whatever feeds I get/process with Perl. PHP is just a great Web language. I know a lot of folks are starting to use PHP as a command-line scripting language; I see the reasoning (only one language to learn), I find Perl and/or shell scripts more appropriate for command-line type tasks. That said, I do have a handful of “exec($someCode)” imbedded in my PHP pages. Just easier to do this call vs. the whole page in Perl or what-have-you (I’m currently on PHP 4.1.2, so I have to use the “exec()” function; I think 4.3 and up makes it more transparent to do system calls via PHP).
  • A lot more template-driven work. Right now, I have several tools/processes that run and all pull in the same damn TXT template. Load template, replace etc and spit out finished pages. Set those processes on timers (CRON) and life is sweet. Change template and – by the next day – a whole swath of a site is automagically updated. Very sweet.
  • Getting back into – in a very small way – photography. God I love pics…

What I’ve Been Missing:

  • I did a solid week or two of Java – trying to get my hand back into that game – but have currently put it on the back burner. I’m more of a Web development guy, and Java – while there are JSPs, servlets and so on – is more for heavy lifting on the backend. While I’ve done – in very small bites – most of what Java has to offer, I still have to find a project that I can code a full app/backend with so I can better learn the language. Like Perl, I’m impressed with how well thought out Java seems to be (with notable exceptions: AWT, some primitive types and so on…). But Java really is not a good tool for getting work done – it’s for getting work done that will last and scale. In many cases, the Web is moving too fast for that.
  • I’m stuck on what book to read next. It’s coin toss between a doorstopper of a non-fiction book and a older fiction work. My guess? My next read will be neither…
  • SQL Server – as mentioned, I’ve been focusing on MySQL lately (actually, the only Windows work I do is to used my Win2000 box for various tools [editors, GUIs] that point at my Linux box(es] ). The only SQL Server work I’ve done in the last couple of months have been either maintenance or very incremental updates. Nothing new or major.
  • Ditto preceding point, but ignoring ColdFusion and instead working on PHP/Perl. The whole Windoze vs. Linux statement holds here, as well.
  • Not as much CSS as I’ve done in the past. Partly that’s because I’m getting a little better at it, so a CSS event that would have taken a day a year ago takes 10 minutes today. I still need to get better at it, but I do have a broad part of the basics down pretty well. I’ll give myself that.

Brushwacked!

You know all those shots/videos of former President Reagan and current President Bush clearing brush on their respective ranches? You know, they’re clearing brush just to relax, take their minds off of work and so on.

OK.

I’m out in the backyard doing the same right now. Not exactly brush, but tree limbs, trimming/removing bushes and so on.

It’s not fun.

It’s not relaxing.

I don’t want to do it anymore!

On the other hand, Bush or Reagan probably wouldn’t understand the therapeutic powers of crafting a really fast Perl parser…

GMail

GmailWell, I just signed up for Google’s GMail. It’s currently in beta, but – as a Blogger user – I get first crack at it.

So far very sweet. There is still the privacy issue (which, as I’ve noted, I find blown out of proportion by the media and privacy advocates), but this is already looking like a winner.

The big buzz about Gmail is the size of the account – 1 Gig! – but, to me, that’s just window dressing. The search, threading and key bindings are all much more impressive than a large bin.

I think this is Google’s first attempt to become what they are trying to be: They are not a search company, they are an application company.

You read it here first…

The Windows to Hell

Or – better yet – the hell with MS Windows.

Well, I’m just being cranky.

For some reason, scheduled tasks die on Windows for some unknown reason. I’ll have scheduled tasks – such as virus downloads – automated and it’ll work fine for months and then … just stop working.

I delete the task, reset it and … all is well again.

That is, until it dies again.

It seems to have something to do with the addition of other scheduled tasks; I have noticed that.

But I really can’t figure out what happens, exactly. And the event log is a joke. Events fail and are not logged as such. What’s with that?

And don’t get me started on the Add Scheduled Task wizard. While it is a nice way to easily add tasks one at a time, it’s…one at at time.

And it’s hard to get a list – a good view – of what happens when. Sure, there is a list of tasks, but have to open properties of each individually to get the full picture.

Give me a CRONTAB anyday. Fast, comprehensible – but a little daunting at first. Agreed. For administrative tasks, why shouldn’t an OS give the option for a less “wizardy” tool. Again, these are task and administrator is doing, not the kids or your mom.

End rant. Let’s hope things run well tonight.

[Ir]regular Expressions

PerlYou know, one of the reasons I like Perl so much is that there seems to be no end to what one can do with it. As soon as you muse to yourself “Hmm…wish I could do [whatever],” you stumble across that [whatever] and suddenly it’s a daily part of your Perl arsenal.

In addition, one of the reasons I sometimes hate Perl so much is that there seems to be no end to what one can do with it – which means, in many ways, I constantly feel stoooopid when I work with it.

Regular expression are an example – while not at all unique to Perl, Larry Wall’s language enables you to used them for a plethora of tasks, reducing lines of code to often only one clump of code (clump is a good word; tight Perl often looks like a cat has walked across your keyboard).

Yet the more you want to do with RegEx, the more you have to teach yourself.

In other words, first you have to feel stupid, and then (usually) a breakthrough gives you the payoff.

It can be frustrating, but … that’s also the fun. Yeah, color me geek…

Hit Me With Your Clueless Stick!

A news.com story about an open-source routing product – one its creators hope can eventually do for routing what Linux did for operating systems.

So far, Cisco doesn’t see the open-source code as a threat.

‘There have always been pieces of open-source routing code on the market,’ said Jayshree Ullal, senior vice president at Cisco. ‘It is an important community that helps continue the development and innovation of the technology. But the software coming out of this community should not be confused with business-class software.’

Researchers envision the Linux of routing

OK, maybe this project won’t set the world on its ear, but how many times have we heard this type of pronouncement?

  • Ballmer and Gates dissin’ Linux
  • Microsoft dissin’ MySQL
  • MS dissin’ the ‘Net
  • Oracle dismissing the SQL Server threat
  • Sun ignoring Linux

Do I really have to continue?

It’s just that everytime I read such a pronouncement, a bell just goes off in my head: Ding! This might be something!