Reason enough (for me) to install Windows (and Google Chrome)

Sure, I own a real NES. Two, in fact. I also own a GBA Micro, Nintendo DS, and a Wii, with emulated versions of all of my favorite NES classics. And then, of course, there’s emulation.

But as a web developer, I just have to geek out on this: the very idea of a working NES emulator running entirely in JavaScript… wow. I’ve known about JSNES for a few months, but I hadn’t had the time and/or inclination to fire it up in Google Chrome (still Windows-only), the only browser so far that has a JavaScript interpreter efficient enough to run it at a decent frame rate.

The last time I tried running it was on the iPhone. Yes… it did run… at about 1.5 FPS. And, of course, there’s no way to access the controls. But in Chrome… it’s actually playable. A smidge slower than the real thing (which would be at 60 FPS), but as you can see, I got it up to 46 FPS. Not bad. Especially considering that I was running Windows 7 with Parallels Desktop on the Mac. Nice!

JSNES

Omphaloskepsis of the day: what have I been listening to?

There’s no surer way of driving away visitors than to spend too much time contemplating one’s navel. And yet, here I go…

I realized a few minutes ago that I had left iTunes turned on most of the day, even though I wasn’t around, playing through four “Rhino Hi-Five” greatest hits EPs, including three I had just purchased today: Gordon Lightfoot, Christopher Cross, Seals and Crofts, and the one I already owned, The Cars. (One of these things is not like the others.) Yes, that’s a triple dose of yacht rock. And I missed it.

Anyway, that realization led to another: that all of these excess plays that I hadn’t actually been listening to have ticked up both the songs’ play count in iTunes and their “scrobbled” totals on my Last.fm profile. Oops. But contemplating that, I became interested in checking out a little bit more of the data Last.fm has been compiling about my listening habits. In the beginning I only signed up with Last.fm to handle automatic scrobbling, so my playlist could show up in real-time on this site. Cool, but the details you can dig up on the Last.fm site itself go way beyond that.

The statistic I found the most interesting was the total number of plays of a given artist over various periods of time. And so, with that thrilling introduction, here are screenshots of my personal listening charts for the past 12 months, the past 3 months, and the past week.

Last 12 Months

Scrobbles - 12 months
What did I say about navel gazing? I’ve listened to my own music more than I’ve listened to artists #2 through #8 put together. Granted, that’s in large part because when I’m working on new music I tend to listen to the rough mixes over and over and over again, making adjustments, making new mixdowns, lather, rinse, repeat. But still… I listen to myself a lot. The rest of the list… yeah… those are the bands I thought I’d listened to the most, although I’m a bit surprised Genesis is so high up there.

Last 3 Months

Scrobbles - 3 months

And The Beatles take the lead! Not entirely surprising, given the intense interest generated by the new boxed set. I’ve listened to Beatles tracks 757 times in the past 3 months, but had only listened to them 17 times in the 9 months prior. The boxed set came out two months ago.

Then, of course, there’s good ol’ #14: Bobby (Boris) Pickett. The one-hit wonder who produced “Monster Mash” and an album full of other songs that all sound exactly like “Monster Mash.” I picked up that album for Halloween. I’m pretty sure all 48 of those scrobbles are from a 48-hour time period. No, I didn’t listen to a song an hour.

Also surprising on this list is #17: The Most Serene Republic. Surprising mainly because I had forgotten I even owned anything by them. This is one of the biggest downsides for me about digitally distributed music: it’s incredibly easy to acquire, and even easier to forget. I’m just lucky I haven’t accidentally double-purchased music this way. (That is, I assume I haven’t.)

And the last one worth noting: #20: Vince Guaraldi. The only album I have by him is A Charlie Brown Christmas. Is it too early?

Last 7 Days

Scrobbles - 7 days

It’s a shorter list, because apparently I’ve only listened to 17 different artists in the past week. And now, a realization, or more accurately, a recollection: Last.fm scrobbles TV shows watched in iTunes or on the iPod/iPhone just like it scrobbles music. Hence The Venture Bros. tied for 15th place.

I’ve been on a Yes kick this week. I have not, however, been on a The Cars, Gordon Lightfoot, Seals & Crofts, or Christopher Cross kick. I did purchase those EPs today, but I haven’t even listened to each of them once. The scrobbles lie! iTunes was running all afternoon and early evening, but my speakers were turned off, and for much of that time I wasn’t even in the house.

Conclusion

Yes, there is a point! Internet log data does not equal the truth. Just because Last.fm says I listened to this music, that doesn’t mean I listened to this music. What it really says is that my computer was turned on, iTunes was running, and it was processing these MP3s. Sending the music to speakers that weren’t turned on, for the benefit of ears that weren’t even in the room.

And if logs can be wrong about this, what else might they be wrong about?

The new site design, phase two

Lots to choose from...As I mentioned the other day, the initial launch of this new site design was just phase one — window dressing. Window dressing I happen to like a lot, but still… same old clunky underlying structure. But not anymore.

WordPress has a pretty rudimentary home page structure by default. Everything’s just *SPLAT* right out there on the home page. Sure, you can use the <!--more--> tag to trigger some automagic stuff with “Read more” links, but overall, it’s not too fancy. Which isn’t to say it’s bad. Now, the default page layouts for some other open source CMSes like Drupal or Joomla, on the other hand… yeah, they’re bad. (Or at least they were, the last time I bothered to care.)

So while WordPress out of the box doesn’t do much fancy stuff with the home page layout, it’s extensible enough that a crafty developer (or a well-read tinkerer) can do some pretty nifty stuff with it. And that was my goal with this new redesign: I’ve got hundreds of posts dating back over seven years now, and most are eternally buried in the archives. I’m hopeful this new approach will bring some of that older content to light, with the random articles list on the home page and the related articles list at the end of each article page.

I didn’t do it all alone… I had some help from a nifty article from Smashing Magazine: 10 Exceptional WordPress Hacks. In particular I made use of numbers 5 through 8 on this list… with some modification. Some of my changes were purely to suit my taste, but others were to improve the usability of the features and in at least one case to fix a bug in the provided sample code. It’s probably worth discussing the details here.

5. Display Related Posts Without A Plug-In

I set this up in single.php so it will appear at the end of each of my articles. I experimented a bit with matching both tags and categories, but I found (for reasons I didn’t dig deep enough to explain) that WP_Query() does well with either tags or categories, but not both.

And, most importantly, I found (or actually, SLP did) that this sample as given breaks comments on the page. Some commenters on the original post mentioned this problem too, along with its solution: you need to call wp_reset_query(); at the end, to tell WordPress to go back to working with the original post’s content.

I also modified the example to look at all of the tags associated with the post, not just the first (can’t really figure out why the original version did that), and tweaked the HTML/CSS output to suit my design. Here’s a simplified version of the code I’m running:

<?php
// Get related posts
$tags = wp_get_post_tags($post->ID);
if (!empty($tags)) {
  $tag_list = array();
  foreach ((array)$tags as $tag) {
    $tag_list[] = $tag->term_id;
  }
  $args = array(
    'tag__in' => (array)$tag_list,
    'post__not_in' => (array)$post->ID,
    'showposts' => 5,
    'caller_get_posts' => 1,
    'orderby' => 'date'
  );
  $related_posts = new WP_Query($args);
  if ($related_posts->have_posts()) {
    ?>
    <h2>Related Posts</h2>
    <ul>
      <?php
      while ($related_posts->have_posts()) {
        $related_posts->the_post();
        ?>
        <li>
          <a href="<?php the_permalink() ?>"
          rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
        </li>
        <?php
      }
      ?>
    </ul>
    <?php
  }
  wp_reset_query();
}
?>

My version also uses a special truncation function I wrote to display a short excerpt of each post, not shown here. (And yes, eventually I am going to get syntax highlighting set up.)

6. Automatically Retrieve The First Image From Posts On Your Home Page

This one worked pretty well. I changed the function name to something a little less quirky, and I also added some code to verify that the image actually exists, instead of just looking for an <img src> and assuming everything’s OK. This involved inserting the following block of code into the function immediately before if (empty($first_img)) {:

// Check that file exists
if (!empty($first_img)) {
  // remove http/ https/ ftp
  $src = preg_replace("/^((ht|f)tp(s|):\/\/)/i", "", $first_img);
  // remove domain name from the source url
  $host = $_SERVER["HTTP_HOST"];
  $src = str_replace($host, "", $src);
  $host = str_replace("www.", "", $host);
  $src = str_replace($host, "", $src);
  if (!file_exists(ABSPATH . $src)) {
    unset($first_img);
  }
}

If some of that code looks familiar, that’s because I copied it straight out of the next item. If I were writing it myself, or bothering to rewrite it, I would swap out that slightly cumbersome-looking three lines of str_replace() with a single preg_replace() — although perhaps the original coder knows something I don’t, like that doing it this way is actually faster. It very well could be; I know regular expressions are significantly slower than straight-up string replacements.

7. Resize Images On The Fly

I’m using this in conjunction with all of the other items here, no big surprise. I left it mostly as-is, although I did make one small change. I know well the dangers of scaling images up — they look like crap, basically. But a little scaling up doesn’t hurt. At least, it’s much less glaring than having a big set of uniform-looking images marred by one image that’s slightly smaller than the rest. That happened to me as I was putting this together, so I tweaked the script to allow images to be enlarged up to 1.5 times their original size. In timthumb.php I changed lines 103-109 to be:

// don't allow new width or height to be more than 50% greater than the original
if( $new_width > $width * 1.5 ) {
  $new_width = $width * 1.5;
}
if( $new_height > $height * 1.5 ) {
  $new_height = $height * 1.5;
}

8. Get Your Most Popular Posts Without A Plug-In

There was something about the way this one was written that really bothered me. Maybe it’s just that I have a knee-jerk reaction to seeing SQL code appear directly in a page template. But mostly it was that this didn’t match #5 closely enough. Luckily I discovered along the way that regardless of whether you retrieved post data using WP_Query (which returns an object) or with the $wpdb->get_results() method (which returns an array), you can use the same post functions once you’ve called setup_postdata(). So I kept everything from this example up through that, and then I used my modified version of the output code from #5 and it worked like a charm.

One other thing I’d recommend changing: it’s kind of silly to have the if ($commentcount != 0) conditional in there. Much better to just put WHERE comment_count > 0 in the SQL. I also added a date range to the SQL, to keep the list dynamic. In my case, it’s only looking at the most popular posts over a 3-month range. More active blogs could shorten that time frame. My full query looks like this:

$popular = $wpdb->get_results("SELECT * FROM " . $wpdb->posts .
" WHERE post_date > '" . date('Y-m-d',mktime(0,0,0,date('n')-3,date('j'),date('Y'))) .
"' AND comment_count > 0 ORDER BY comment_count DESC LIMIT 4");

There may have been some other changes I made that were relevant here but I think I covered all of the major ones. The tips on the Smashing Magazine site were invaluable in kick-starting my overhaul of the home page. It was uncanny that I stumbled upon this page today, just as I was getting down to this task anyway. It saved me a ton of time. But it still kept me on my toes, since all of the so-called “hacks” required some additional hacks of my own to get them working, or at least, to get them working the way I wanted!

The Something Manifesto, Part Two

Darts_in_a_dartboardThere have been plenty of manifestos over the years, perhaps the most famous being Marx’s The Communist Manifesto. The manifesto that has defined the first decade of the 21st century, or at least the decade’s online component, is without a doubt The Cluetrain Manifesto.

Defining Success

I have always harbored almost a knee-jerk disdain for Cluetrain, quite possibly just because I think its title is stupid. It doesn’t help that the first of its Lutheresque “95 theses” is:

Markets are conversations.

I don’t really believe this. Markets are places where people try to sell you stuff. Luring you into conversation is just a sales tactic. Everything that follows in Cluetrain is dependent upon this one central illusion: make the market look like it is two people engaging in a meaningful interaction, instead of simply exchanging money for goods and services. Even Homer Simpson’s inner voice knows the value of a $20 bill, and not since Ayn Rand has capitalism so effectively masqueraded as philosophy.

This doesn’t make the market evil, it just exaggerates the human value of the quest for profit. Which brings me back to the Jason Fried interview I linked to in part one. Fried says:

It really bothers me that the definition of success has changed from profits to followers, friends, and feed count. This crap doesn’t mean anything. Kids are coming out of school thinking, I want to start the next YouTube or Facebook. If a restaurant served more food than everybody else but lost money on every diner, would it be successful? No. But on the Internet, for some reason, if you have more users than everyone else, you’re successful. No, you’re not.

Fried is absolutely right about the dangers in the Internet era of equating popularity with success. But the original equation is no less dangerous. Does profit equal success? That depends. Is profit your goal?

Meeting your goals equals success.

The problem is that following this axiom requires that you have goals, and sadly that often seems too much to ask.

I think most people have an innate desire to matter. We want to feel like our lives are important, or at the very least, that they mean something. That’s been the essence of religion for thousands of years. Fame is an easy thing to latch onto in this regard: if everyone knows who I am, then I must be important. Eventually, though, this quest for fame is going to result in dissatisfaction, regardless of the outcome. Either you fail to become famous, languish in obscurity, and lament your lack of success, or you achieve the fame you seek, realize it’s a hollow victory, and continue to seek out one new fix after another. But they’re all the same, and you always come down.

The Freedom to Be Productive

Unwarranted hallowing of “The Market” aside, both Cluetrain and Jason Fried’s philosophy represent a prevailing attitude of this decade: that breaking down the old, rigid structures of the 20th century corporate world will produce happier, more productive employees/citizens/people. I agree. But there’s a major problem: it’s just really hard for a calcified corporate hierarchy to adapt to this kind of flexibility. Lots of companies have tried it, to be sure. I’ve been there. But the efforts are usually hampered by lack of enthusiasm and buy-in by the employees, lack of focus and direction by management, or sheer inertia.

At best small pockets — rogue departments — can collectively “break the rules” and implement a more flexible structure, but they’re destined to remain on the fringe. Or, a few of the principles will be implemented company-wide, but they’ll be so mutilated by that point that they result in absurdities like once-a-month “denim days” where employees have to pay (in the form of a charitable donation) for the “privilege” of dressing comfortably.

There’s another problem that doesn’t get stated explicitly in Inc.’s article on Jason Fried’s Facebook-like recitation of the daily minutiae of his life. He gets up before 7 AM. He does some work while he’s getting ready. He arrives at work (or works from home) around 10 AM, and stays until 6 PM. Then after his regimen of Fox TV, he may put in a few more hours of work at night. In other words, his job is his life. It’s integrated with other things, to be sure. He fits in plenty of non-work activities during the day. But work is always there. It’s no surprise that he’s single, no kids. There may not be a causal connection, and if there is, one can’t determine from the article in which direction it points. But the simple fact remains that a life this focused on work cannot simultaneously accommodate a relationship, much less kids.

This was the problem I had at my last job before I went freelance. In many ways, it was the ideal place for someone of my geeky persuasion to work. And I often lament that I am not a part of that world anymore. But the arrangement was unsustainable for me: developers pulling “all-nighters,” crashing on couches in the lobby, getting pizza delivered in at 10 PM, these are all standard practice. It’s a culture of work that expects a level of availability that someone who’s also responsible for two young children simply cannot afford to provide. But it’s an inherent element of the kind of “flexible” work environment these philosophies inspire.

And so it was that I set out on my own. The environment I’m attempting to create for myself is, in many ways, not unlike that which I left, or which I’ve been criticizing in the preceding paragraphs. The major difference is in the amount of time I am expected to devote to work (that is, billable hours) versus the other aspects of my life which, to many an employer’s chagrin, continue to exist. But this true freedom comes at a price: less billable hours means… less money. And not being on someone else’s payroll means I’m shouldering all of the risk of the operation. The business is mine to make into a success or to allow to become a failure. But at least it’s mine.

Call to action: Find ways to work that work for you.

To be continued…

The Something Manifesto, Part One

somethingI’ve been thinking a lot lately. Or, not so much thinking, but thinking it would be nice to have more time to think. Or more time to do anything. I want to be more productive, even if I’m not sure what I want to produce. I haven’t had time to figure that out yet.

I’ve noticed a convergence of ideas lately, both inside my own head and in the larger world, a world I increasingly interact with primarily via the Internet, despite the fact that I am fully capable of going outside and interacting with it directly. These ideas are mostly circling around a disturbing premise: the tools that are allowing us to share these ideas are consuming our ability to produce them in the first place.

I’ve become something of a Facebook and Twitter addict over the course of the past year. I need the constant affirmation they provide in the form of comments from acquaintances and strangers alike on the random scraps of brainstuff I frequently distribute via this medium. Comments tell me people know I exist. They make me feel important. Increasingly, they serve as a sterilized substitute for genuine human interaction.

But there may just be some hope yet: I’m seeing encouraging signs that I’m not alone in… uh… being alone. Joshua Wentz (of SIDEDOWN) laments the vacuous experience of Facebook. Jason Fried (of 37signals) tells Inc. how popularity on social networking sites does not equal success. Nick Kallen (of Twitter, no less!) discusses how our brains buckle under the sheer mass of information in the modern world.

And so, I present my manifesto. My statement of beliefs about… something. I’m just not sure what.

Family > Work > Social Networking

I need to prioritize. We all need to. What’s really the most important to us, or, more accurately, who is? Our interactions with the people who really mean something to us, who are a part of our daily existence, must come first. These people are our “family,” whether we’re related by blood or not, whether our relationships are legally recognized by the government or not.

Work is next. Work is what we do that matters to us. It’s not necessarily what we get paid to do — though if we’re lucky, we can sometimes make that happen. It’s what drives us and fulfills us.

Social networking? Well, now we begin to see its real place in the hierarchy of things. These tools can help us to reconnect with the people we care about but with whom we no longer share physical space. They can help us meet and develop meaningful relationships with people whose interests we share, but whose physical space we never have (and likely never will). But much of the time they simply provide needless distractions, inundating us with useless details about the lives of people who don’t really mean that much to us. Just because information exists, doesn’t mean it’s important.

Call to action: Delete your social networking bookmarks.

To be continued…