Blog

Relaunch... again!

After many, many months of development and fretting over design, I've finally completed the latest iteration of dxprog.com! There's quite a bundle of changes in this version both under the hood and... over it? Here are the highlights:

- New look The most obvious change is, of course, the new look. I've opted to go for a super clean look with more attention paid to the textual layout.

- Unified content model This means that items from my portfolio, artwork, videos or blog can all be displayed in the same list yet be treated differently for display. It reduces a lot of code and makes for a much nicer, streamlined presentation.

- Commenting upgrades In addition to being able to use your twitter account to sign-in, there's now the option of Facebook and anonymous. Also, comments are broken down into pages of fifty (there's only one post where you can see this in action).

- Speed I've done a lot of changes to the backend structure to enhance load times. The average load time as I'm writing this is well under a tenth of a second.

- Comics As much as I loathe some of those comics, dxprog.com is meant to be a repository of all my work. As such, you can view the entire Digital Double archive by clicking "Comics" up on the top nav. I'm going to work on getting the newer stuff in as I finish importing content.

- Sidebars There have been many tweaks and additions made to the various sidebars. The first I'd like to point out is the "Most Popular" which, as the name implies, is a listing of the current most popular items on the site. Another interesting one is "Last Listend To" which displays the last song I've listened to through my Music Page. Finally, the archives and tag clouds have been given some nice overhauls.

Of course, these are just the noticable differences. The amount of changes in the codebase are wide sweeping and quite substantial, but will allow for a much more maintainable codebase in the future. I plan on releasing the source within the next month or so after I've had a opportunity to watch it in the wild and fully document it. Until then, I hope you enjoy the new site. If you're having issues or have a suggestion, please feel free to leave comment!

Wordpress - Related Posts Script

At my job, I currently have three Wordpress sites under my watchful eye. On one, I was tasked with creating a related posts feature. Now, there are certainly enough plug-ins that will do just that, but none of them worked how I wanted to or were generally more complex than necessary. So, I whipped up this little script:

Code: php
  1. function relatedPosts($id) {
  2. /* Build a query to get a list of all posts that share similar tags */
  3. $s = microtime(true);
  4. $q = "SELECT count(*) AS total, p.ID, p.post_title, p.post_date FROM wp_posts p INNER JOIN wp_term_relationships t ON p.ID=t.object_id AND t.term_taxonomy_id in (SELECT s.term_taxonomy_id FROM wp_term_relationships s WHERE s.object_id=$id) AND t.object_id != $id AND p.post_status='publish' GROUP BY p.id ORDER BY total DESC, p.post_date DESC LIMIT 5";
  5. /* Format the output */
  6. $out = "";
  7. $result = @mysql_query($q);
  8. if ($result && @mysql_num_rows($result) > 0) {
  9. $out = "<h3 class=\"related\">Related Posts</h3><ul class=\"related\">";
  10. while ($row = mysql_fetch_object($result)) {
  11. $perma = get_permalink($row->ID);
  12. $out .= '<li><a href="'.$perma.'">'.$row->post_title.'</a> - '.date("F j, Y", strtotime($row->post_date)).'</li>';
  13. }
  14. $out .= "</ul>";
  15. }
  16. echo($out);
  17. }
  18. ?>

Just drop that in the wp-content/yourtheme/functions.php file, where yourtheme is the directory of your active theme. Then add the following in your wp-content/yourtheme/single.php where you want the related posts to appear:

Code: php
  1. relatedPosts(get_the_ID());
  2. ?>

You should now have a list of posts with similar tags. Styling is simple: one h3 and one ul, both with the class "related".

Enjoy!

Peace, Quiet and Solitude

I am in the realizing that it's been nearly a month since I last blogged anything, granted this comes on the heels of an unusually active period for me. But, hey. Nothing terribly exciting has happened, so there it is.

I decided that last week would be a pretty good week to blow a whole bunch of my paid vacation time... after all, the best day of the year happened to fall in that week (hint: my birthday). It was nice to just forget about the world around me and piddle around quietly the way I used to back in the days when I was without work. I churned out no less than three distinct (but wholly unfinished) projects.

The first of these is a UX re-imagining for my ongoing project, the Music Page. Now that I am a far better JavaScript guru than I was when this was originally written, I've decided to take a completely different approach in terms of user presentation (though, the underlying functionality is pretty much the same).

Another thing I did was start in on learning some more HTML5 canvas stuffs, as it provides a pretty sweet opportunity for gaming purposes. I started messing around with coding a simple drawing framework and, at the behest of my osu! fanatical brother, began attempting a clone of sorts for that. Ultimately, I made some good progress and the canvas object is certainly a powerful tool, but there are some simple things that it simply can't do that keeps Flash at the advantage (I'm looking at you, per blit alpha).

Other than these few programming things and a goodly amount of time with my nose in books, it was a slothful week to be sure. But, then again, that's the whole point of "vacation."

Tune in this weekend as I head to yet another anime con.

Walking for Cash

As I'd briefly touched upon in an earlier post, my place of employ is currently having a little fitness competition: can you walk 10,000 steps a day for 75 days? If you reach the grand and glorious total of 750,000, you are awarded two free days of vacation. Everybody was provided with company branded pedometers to keep track of our steppings and left to our devices.

Now, I'm never one to turn down an opportunity to make money for nothing, so I'm doing my best to make a firm effort and accomplish this goal. If you take a look at the blog main page, you'll see that there is a graph with my current progress on this mission (assuming you're using an HTML5 compliant browser). As you may well notice, I'm a few thousand steps shy of my quota for this week (shame on myself).

Now, that's the boring part. The cool part (and the reason I'm posting) is the really the graph itself. Back in December I switched the site codebase over to HTML5. Now, this was mostly a change in semantics, using new tags such as <article> and <section>. I'd not done anything special with CSS3 or some of the newer, funner tags such as <video> or <audio>. One major thing I'd really not looked too much into was the new <canvas> tag, with the ability to draw images in the browser on the fly.

That all said, I needed some place to test this exciting new functionality, and making the graph was just the place. To update update said graph, all I do is modify a JSON data file with my step information, and HTML5/JS takes care of the rest. Of course, this leaves people using IE in the dust, but this site was never designed for them anyways.

So, there you have it. A fitness contest spurned my thirst for learning. Now, if IE9 could speed along and summarily obliterate the install base of all previous versions before it, life would be a joy of canvasy win!