Categories
Connecting

If only we could see each other’s eyes

During my recent walks in my favorite enchanted forest, I’ve noticed that every day there are fewer lightning bugs, and more well-fed robins. As quickly as nature creates magic, it erases it. Ah, but I’ve fooled that old, contrary lady because her work continues to live in my memory and in my writing.

Well, I should say it lives on in my memory until she gets the last laugh when I’m old and feeble and can’t remember my own name or that robe sleeves aren’t edible, much less one magical moment. Perhaps that’s why the urge to write is so strong in many of us –an act of defiance against the end of both magic and mind.

Categories
Programming Languages

Survival Guide to LAMP: Prepare for prepare

Since PHP 5.0 released a day or so ago, I’ve been seeing how various applications I work with do in the new environment. Porting straight to PHP 5.0 seems to work just fine for the applications tested, including my weblogging tool, WordPress.

Ah, but there’s more to upgrades than just a simple turning off of one PHP version and turning on another. PHP 5.0 includes– in addition to the full support for object implementation and improved XML manipulation–some very slick database toys.

Though PHP is used with MySQL for the most part, look for more work with SQLite, as it’s now bundled with PHP. This lightweight little C-based database engine is ready to go as soon as you need it; for quick database development, it’s hard to resist its simplicity.

However, my heart still belongs to MySQL, and with the new version of MySQL and the new improved MySQL interface extension in PHP 5.0, the love affair continues to grow.

MySQL 4.1 is currently a beta release and should only be downloaded by developers. I found it installed easily and works nicely with existing applications; this includes the existing MySQL interface used by most weblogging tools, such as WordPress, Movable Type, and so on.

However, MySQL 4.1 has one particular new goodie that’s going to make a world of difference in performance with existing applications and that’s support for prepared statements.

Now, Oracle has had this functionality since before PHP was born, but Oracle started out as the 300 pound baby, who has since been finding ways to keep all of its great functionality while trimming down both size and cost. MySQL on the other hand, started out as a cute 6 pounder who couldn’t do much, but is learning quickly.

Prepared statements are a very simple but powerful technology. What happens is you create a statement as a template, with placeholders for values that will change each time the statement is run. You can then run the statement as many times as you want, changing the parameters as needed. We webloggers with our natural born ease around and comfort with templates should find prepared statements to be both friendly and familiar. I just know that this particular technology is what’s going to finally bring those hesitant about working with databases over to the wild data side.

Following is a very quick example of using the prepare statement functionality, tested on one of the WordPress tables ported to the new environment. This code ran successfully using the newly released PHP 5.0, the latest release of MySQL 4.1, in a Windows 2000 environment, under Apache 1.3x.

<?php
$link = mysqli_connect(“localhost”, “user”, “userpass”, “wordpress”);

/* check connection */
if (mysqli_connect_errno()) {
printf(“Connect failed: %sn”, mysqli_connect_error());
exit();
}

// create a prepared statement
if ($stmt = mysqli_prepare($link, “SELECT option_name FROM wp_options WHERE option_id=?”)) {

// bind incoming parameter
mysqli_stmt_bind_param($stmt, “i”, $id);

// bind result variables
mysqli_stmt_bind_result($stmt, $name);

// set input param, execute query and fetch and print value
$id = 77;

mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
printf(“option for id %s is %sn”, $id, $name);

// repeat with new input param
$id = 93;

mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
printf(“option for id %s is %sn”, $id, $name);

// close statement
mysqli_stmt_close($stmt);
}
else
printf(“prep failed: %sn”, mysqli_error());

// close connection
mysqli_close($link);
?>

This code demonstrates the procedural use of the new mysqli PHP interface, since this will probably be more familiar. I’ll demonstrate the use of objects the next time I try out a little of the new PHP 5.0 code.

In the example, a connection to the database is made, using the function mysqli_connect. Once the link is established and we know no error has occurred, the next thing that happens in the code is creating the prepared statement.

Notice the use of the question mark in the statement? This question mark serves as a placeholder for the input parameters that will be bound to the statement later in the code. It’s not different than the use of templates within your weblogging tool – each of them is replaced by ‘real data’ when the page is accessed or generated.

The function mysql_prepare takes the SQL passed to it, parses it, compiles it and then stores in in the database in a binary format that makes passing the data back and forth between the database and the application more efficient – a bonus for this type of statement.

Next in the code, it’s a matter of binding input and output parameters. For this example, there’s one of each. The input parameter is an integer so in the mysqli_stmt_bind_param function call, a value of ‘i’ is passed as the second parameter to define the data type of “integer”. The first parameter is the prepared statement, and the third is the actual variable that will be bound to the input parameter.

(By ‘binding’ what I mean is that changes to the variable are reflected in placeholder position in the prepared statement, each time it is executed.)

Next, the output parameter is defined, using the function mysqli_stmt_bind_result.

To test the statement, I assigned a value of 77 to the input parameter, executed the statement using mysqli_stmt_execute, fetched the result with mysql_stmt_fetch, and printed both values out. The result is:

option for id 77 is weblogs_xml_url

To demonstrate the reusability of the prepared statement, I assigned a new value to $id, this time a value of 93. Again, the statement is executed, and the resulting value fetched and printed out along with the input parameter. The resulting line from this second run of the prepared statement is:

option for id 93 is blog_charset

The prepared statement will continue to reside at the database until the application goes out of scope (beyond the current operating environment), or until the statement is closed, whichever comes first.

How can something like prepared statements help out in a weblogging environment? For the weblogging application I use, it’s not unusual for us to have to access the posts or comments table more than once in order to process new comments or display or edit posts. In particular, because of my custom spam protection and moderation, I access both tables at least twice when a new comment is posted; with something like the prepared statement, I could improve the program readability, as well as efficiency. I may not get hundreds of comments a day, but as I said in the past – I’m a coding miser. The less work the application does, the happier I am. I and everyone who shares my machine.

However, before we all run out an upgrade to PHP 5.0 and MySQL 4.1, note that I could not complete the migration of WordPress to this new environment because one MySQLi function, mysqli_fetch_object, caused Apache 1.3x to throw a memory exception. That’s ’semi-crash’ for those of you who haven’t seen programs step all over each other’s toes in memory.

This is beta, new, in development code. Just the start of new things. But such great things. And I haven’t even covered all the new goodies coming out in MySQL 5.0.

Categories
Political

Political Games

Recovered from the Wayback Machine.

With the American election getting ever closer, the political games will continue to increase. If we’ve managed to stumble about in naiveté for the last three years, now is the time to wake up, and smell the cynicism.

There have been a number of folk who have tried to generate discord in the “Anyone but Bush” solid front by questioning whether Kerry would be a good President. They say, what are the positive things about Kerry that would make him a good leader? After all, can’t elect a man just because he’s not George Bush, can we?

The hope is that they’ll pull the more liberal or seemingly liberal of us about and get us thinking that, why of course we shouldn’t vote for someone just because they’re not someone else. They pro-Bush camp is joined by Ralph Nader and his supporters in this effort to drain off just enough of the votes from Kerry to put Bush back into the White House, while giving Nader the ego boost he seems to desperately need.

What the parties involved forget is that for many elections, people vote for the best of a lot we don’t generally care for, making a determination that we’d rather have someone who is inactively good, than actively bad.

I am voting for Kerry and Edwards because, first of all, they are not Bush and Cheney. Even if Kerry spent the next four years, comatose at his desk and didn’t do a damn thing, he would be a better President than George W. Bush in the White House for four more years without the constraints of worrying about a future re-election. An unconstrained Bush is the stuff of nightmares. (Puerile humorous pun unintended.)

If Kerry just sat in his chair, contemplating his navel, he wouldn’t be attempting to work around the decisive support for ANWR (Alaska National Wildlife Reserve) by opening up the rest of the Arctic for devastating damage via oil drilling infrastructure (thanks Julie.)

If Kerry spent the time playing Solitaire, at least he wouldn’t be invading other countries on shallow pretexts, and then find a handy scape goat when things don’t go according to a badly thought out plan. Or inviting in big time financial supporters to change the course of the environmental and energy policies in this country, until such time as the supporter gets busted.

If Kerry and Edwards spend all their time traveling the country, appearing in nightclubs as a singing act called “The Breckettes”, hopefully they would fire that incompetent Ridge first, with his deliberate manufacturing of fear through vague and unspecified threats; not to mention thoughts of bloodless coups. Then some kid who happens to be the wrong skin color can go back to finishing his photo assignments without being arrested.

(By the way, I didn’t mention this earlier, but half of my photographs that will be appearing in the August issue of Missouri Life were of bridges. I figure this should help sales–all those brown skinned terrorists in this country, you know.)

No, if Kerry spent most of his time finger-painting on the walls of the Oval Office using ketchup, he at least wouldn’t be harrassing gays in order gain a few extra votes from those who like nothing better than to interfere in the lives of others. In the name of God, of course. Don at Hands in the Dirt had it right:

This was about election political posturing at the expense of a minority segment of the population.

And since Kerry is under threat from being denied religious comfort for being a leader to the people rather than a good Catholic, perhaps the righteous religious in this country will have to go back to practicing their religion, all that golden rule stuff, rather than trying to force the rest of us into their beliefs.

(Oh, and for those critical of Edwards and Kerry for not being present for this vote, be aware that the members of Congress almost always know how a vote will go before it happens. A favorite election year gambit is to use this knowledge ahead of time to make those who are running for office seem negligent when they aren’t available for a vote. Members of a party will actually change their vote on a measure to make the vote seem much closer than it would really be, just to generate bad publicity for a candidate. Yeah, I know: devious. And both parties are guilty of it. So take the cries of, “But they didn’t vote” with a grain of salty sand.)

No, I reckon a dead Kerry is worth more than a live Bush in office. After all, we thought a dead man was worth more than Ashcroft when he ran for Congress in Missouri.

But having said this, I think a live Kerry will do a lot of good. I think he’ll put back many, if not all, of the environmental protections we’ve lost over the last three years. I also think he’ll reduce the office of Homeland Security to it’s proper role, and roll back many of the paranoid acts that have been foolishly passed. Contrary to unfounded implications, I expect that he’ll be a strong leader in case of conflict, if needed; but I also don’t think he’ll go looking for a fight.

He knows that healthcare is an issue, needing more effective legislation than that foolish Medicare drug reform that just so happens to benefit yet more Bush supporters. He also knows that we’ve botched our handling of the military needs for the Mideast and will hopefully stop punishing the same military by yanking them about with little regard and even less pay.

He’ll make tough choices – like eliminating some of those tax cuts. Mario Cuomo did a brilliant TV interview this weekend saying that only the top 2% of the country really benefits from the tax cuts. The problem, he said, is that the top 20% of income earners think they’re in the top 2% income bracket. So about 18% of the people think they’ll benefit from tax cuts, when in reality the benefit is negligible.

Most of all, I think both Kerry and Edwards will listen to others, and be prepared to change their minds when new facts arise. Some people call this flip-flopping; I call this learning from experience, and being willing to admit you made a mistake.

Categories
Media

If only I weren’t lost in translation

Though I couldn’t take pictures of the storm when I was looking at it from the parking lot last Monday, I did try to take some photos of it when I got home. However, when I started to take the pictures, my camera began emitting this high pitched whistle, just like the sound things make in the movies before they explode in a loud and dangerous manner.

Rather than tossing the camera through the air and diving into a ditch, I whipped off the battery cover and removed the battery. Not as dramatic, but not as hard on the camera. What caused the noise, I don’t know, but I hesitate to put that one battery back in.

The editor of Missouri Life is sending me a copy of the magazine featuring my photos and also arranging payment to me – payment! money! – and this forms the start for my new camera fund. I am going to buy a Nikon D70 because a) I like Nikon optics and quality; and b) I have several lens that will work with the D70. In the meantime, words will do until I have my new camera or feel brave enough to put the battery back into my old one.

However, it may be a time before I have the new camera because I have become very frugal of late, cutting our fripperies right and left in esthetic abandon. I am indulging in just one splurge–a monthly subscription to Netflix. Thanks to it, I’ve managed to finally see Big Fish, Lost in Translation, Seabiscuit and several other less than memorable films. That and my library, my computer and the Internet, a small drive in the car and a long hike, and above all, my whistling camera, and I am content.

I thought that Seabiscuit was charming, but a little predictable. I really liked Big Fish – I loved the tall tales and the actors and the narrative and the end, and thought it was a very good film. But Lost in Translation, now that was a fine movie. Since I am probably the last person to have seen it, nothing I can say about the movie should be spoiler, but be forewarned.

People have said the movie was about these two strangers who find each other, and not about them being in Japan, but I have to disagree: Japan forms a third character, the straight man the other actors play against.

The premise behind the movie is two people alienated from their surroundings who happen to find each other. Not only are they alienated in the environment in which they find themselves in Japan – a country with a different culture and language– we learn over time they are also alienated from those who love them: the young woman can’t connect with her husband and his hollywood lifestyle; the aging actor looks at spilled color samples, trying to understand which is burgundy among all the pinks.

If the movie had taken place on a beach in Oregon or some such thing, all we would have seen was two dissatisfied people who can’t seem to find contentment with their very good lives. Instead, by putting this movie in Japan, the lack of connection both experience originates first from an external source; an impression lasting long enough, and being familiar enough, for the audience to get to know and even like both of the main characters. Rather than two spoiled people who refuse to be content with their lives, we meet two people who are lost, lonely even in the midst of friends and family and admirers, and the bright neon lights.

I’ve heard people condemn the movie for stereotyping, but the impressions I received of people in Japan from this movie are that they are gracious, charming, friendly, patient, and have wonderful senses of humor. I wouldn’t mind it if people stereotyped Americans that way.

No, rather than crude stereotyping, what we’re given is a look at Bob and Charlotte’s perceptions of their surroundings. What we see through their eyes is what they expected to see, and what astonished them to see. The ordinary is invisible.

There were so many scenes I loved in Lost In Translation. I loved the scene with the prostitute and the nylons, and thought I would choke I was laughing so hard. I also enjoyed the hospital scene with the two ladies laughing politely behind their hands in the background at Bob’s non-conversation with the older Japanese person; or when Charlotte was exploring and Bob was riding in the Taxi through the streets – and the quiet elegance found within these visually exploding scenes.

In the end, when Bob runs up to Charlotte and they hold each other and he whispers something in her ear, and we don’t know what it is–what a perfect ending. What a marvelous ending. I would save all my pennies to go to Japan if only I could have a moment, one single moment of that ending.

I was thinking about this movie last week when I sat in the dark looking out the window at the storm, too late in an evening or too early in a morning. I found myself wondering: if I were feeling lost and alienated, what words would I want to hear whispered in my ear?

I also thought that I would rather be lost in translation than lost in Hoboken, New Jersey. And if I were lost in Hoboken, New Jersey, I wondered if I could find a way to blame it on the Japanese.

Categories
Diversity

No room at the top

I have been remiss in the past in all my criticisms of Six Apart’s business practices and Movable Type coding gotchas. One thing I did not comment on favorably was the fact that Mena Trott was CEO of the company. In our environment where it’s rare to hear a woman’s name in a list of speakers, or see a woman’s face among a photograph of leaders in any field, Mena stood out as an example to all women that this environment is not completely and totally controlled by men.

Well, that was, until today when Mena wrote a very gracious note about a gentleman by the name of Barak Berkowitz who has taken over as CEO of Six Apart. I’m not sure of what Mena’s position is at this point; I believe she may be continuing on as President.

Six Apart is no longer Ben and Mena Trott, not with all the VC involvement and international growth. It is a very successful company now, and nothing wrong with success in weblogging. I guess an added benefit is that whatever criticism any of us now have of the company or products, I don’t think people will say we’re kicking the baby squirrels because of it.

But it was difficult reading about Mena stepping down as CEO because I have to wonder how much of our criticism of the recent license fees had to do with it. I work hard to see that women are promoted in weblogging, only to be critical of a company headed by one of the few women who has managed to find a position among all those cookie cutter men. Yet, paradoxically, I don’t believe that criticism should be held back just because the recipient is one of the few women that has actually made a difference.

In all my discussions about women in weblogging and technology, I’ve not asked that women get preferential treatment, or to be judged other than on our own merits. If anything I’ve asked that women get the equivalent acknowledgement and recognition, and yes, even criticism, that men get. Still, I wonder–by being critical of these rare women, do we make it easier to get pulled from, or should I say pushed from, positions that are hard for us to get to in the first place?

I hope this is a good move for Mena Trott. I wish her success in whatever role she has in the company. I am happy for her, but sad for us: there’s now one less woman at the top.