Keith’s Blog Random thoughts on a variety of subjects

28Dec/090

Wordpress 2.9 and a New Look

This site has been upgraded to Wordpress 2.9. If you see any oddities, please post a comment to this post. Also, the theme of this site has been changed from my custom theme to a much more simpler one that should load much faster. My custom theme was the test bed for some posts I wrote on Wordpress themes last year, and was never really finished. I went back and reread those posts, and found that they stood on their own pretty well, so hopefully removing the sample code from this sites template won’t reduce their value.

Filed under: wordpress No Comments
2Jan/094

Using PHPUnit with Eclipse PDT (PHP Development Tools)

Eclipse PHP Developer Tools (PDT) is a very capable and mature platform for developing PHP applications. For those that develop only in PHP, an integrated installation is available that includes the Eclipse platform and any dependencies. For developers that may already be using Eclipse for development in another language, PDT can be installed using Eclipse's software update facility.

The one feature that PDT lacks is integration with PHPUnit. This can be a real hindrance for teams using Test Driven Development, and discourages everyone from frequently running their unit test suite while developing.

Luckily, the Eclipse platform has a mechanism for adding external tools to a project, and makes it very easy to call these tools once they are configured. In this post, I'll outline the steps I took to add PHPUnit support to my installation of PDT.

This post assumes that you have already installed Eclipse, and have a local development environment for PHP and PHPUnit. Jonathan Tran has a handy tutorial on installing PHPUnit on a Windows machine that I found very helpful.

In my PHP projects, I keep my unit tests in a directory called /tests. To start, select any unit test file - I chose AllTests.php, which executes a test suite containing all my unit tests for the project. Once the file is selected, select the menu item Run->External Tools->External Tools Configurations... That brings up a dialog box similar to this.

jan2screen1

Select the Program configuration category, and click on the first icon - New Launch Configuration. Name your new configuration PHPUnit.

The location field should contain the full path to your phpunit shell script. On windows, this will be called phpunit.bat. On my computer, the correct location is c:\pear\phpunit.bat; however, this will vary by system.

The Working Directory should be set to the base location of your unit test files. In my case, this is the fully qualified \tests path.

For the Arguments list, you should have one entry - ${resource_name}. This tells Eclipse to pass the name of the currently highlighted unit test to phpunit.bat. To add this, click on the Variables... button and find resource_name in the displayed list.

The remainder of the tabs can be left with their default values. Your finished configuration should look like this:

jan2screen2

Press Apply to save your changes. You can now press the Run button to execute PHPUnit immediately, or press Close to exit this dialog box.

After the first time you run PHPUnit using the External Tools Configurations dialog box, your PHPUnit configuration will be associated with the Run External Tools icon on you Eclipse workspace - this is the green Play Button icon decorated with a little red toolbox. To execute any unit test script as you develop, simply select the script in the PHP Explorer and press the Run External Tools icon.

jan2screen3

Tagged as: , , 4 Comments
29Dec/080

Writing a last.fm plug-in for Wordpress – Part Three: The Plug-In

This is the third and final post describing how to write a plug-in to last.fm for Wordpress. In the first post, we looked at the last.fm API. In the second post, we took this information and made a PHP application to create a weekly Album Chart using the API. In this post, we use the PHP appication as the basis for a Wordpress plugin.

26Dec/080

Writing a last.fm plug-in for Wordpress – Part Two: The PHP Application

This is the second post in a three part series on writing last.fm plug-in for Wordpress. In the first part of this series, we explored the last.fm API and wrote some simple PHP scripts to demonstrate two of the last.fm API methods. In this post, we'll create a complete PHP application that creates the last.api widget. This application will be generic enough to use in any web page. In the third post in this series, we'll convert the generic application into a Wordpress plug-in.

Before getting started, we should decide what we want to the widget to look like, and what information it should display. Since we'll be pulling in the weekly Album Chart, it makes sense for our widget to display the top five albums that the user has listened to over the past week - that is, the first five entries in the Album Chart. Once we have the list, we'll pull in additional information about each album. This will allow us to display a little thumbnail image of the album's CD cover if one is available.

23Dec/080

Writing a last.fm plug-in for Wordpress – Part One: The last.fm API

last.fm is an online music listening and recommendation service that began life as a University project by one of it's cofounders,  Richard Jones. In addition to generating custom online "radio stations", users can create a profile that keeps track of the music they listen to. This process is called scrobbling and is used as a baseline for generating recommendations and custom playlists. To keep the data flowing, last.fm provides an easy-to-use API based on passing XML over HTTP.

This post is the first in a series of three exploring this API, and showing how the API can used to create a Wordpress plug-in for displaying information from your last.fm profile on your blog. In this first post, we'll take a look at the last.fm API, and create some simple PHP scripts to test out the API. In the second post, we'll turn our simple scripts into a complete PHP application. In the third post, we'll create a Wordpress plug-in that leverages our PHP application to display our last.fm data on a blog.

12Dec/080

Now Running Wordpress 2.7

Upgraded the site tonight to Wordpress 2.7. I've been running Release Candidate 1 on my test server since it came out, and have been putting it through it's paces - so I don't expect any issues.

Tagged as: No Comments
4Nov/080

My Vote is In

I voted in the U.S. elections today. I was at my local polling station at 6:30am for the early start that some locations in Massachusetts are trying. When the doors opened, I was number 18 in line with another ten or so people behind me. In previous elections, I have been as close to the front of the line as number five - not sure how statistically relevant the "long" line is. The poll workers were ready for a big turnout and were very organized. Plenty of voting machines set up, and enough room so that a long line of people could queue up indoors out of the cold. There were ushers at the front doors and a few other places to help out people and keep things organization - the first time I've seen that, and pretty comical considering the number of voters waiting in line that early.

Despite being my sixth presidential election, I don't remember ever being this excited to vote. I was shaking with excitement - hopefully the machine can read my slightly wobbly arrows.

Tagged as: No Comments
21May/082

Windows Audio Sucks Monkey Balls

There are two simple things that Windows should really be able to handle by now, but can't. (1) I have a Soundblaster card driving my external speakers, and a BitHead USB headphone amp for listening with cans. Switching between the two output devices involves going deep into Control Panel, then, when I finally switch devices (from speaker to headphones, say) I have to shut down the application I'm using, and restart it to get audio to "flip over". What's up with that? (2) I'd love to be able to set the audio level on an application by application basis - so that I can have Media Center playing in a window either muted or at low volume, while my browser is playing a video at full volume. How hard would that be? Amazing how poorly this works.

Tagged as: , 2 Comments
26Apr/080

Wordpress Upgraded to 2.5.1

I upgraded Wordpress to 2.5.1 this morning. Seems like a pretty big upgrade, although the upgrade itself went smoothly. If you see any problems, or if you notice the RSS feed is broken, let me know.

Tagged as: No Comments
19Feb/080

World’s Largest Record Collection for Sale

I first heard this on NPR, but it looks like Wired has grabbed on to the story. The world's largest album collection is up for sale on eBay. It contains over 3,000,000 vinyl records (mostly 45 rpm singles) as well as over 300,000 CDs. Once the collection hit 160,000 records (or so) he had to move them to a warehouse. Once space was not longer an issue, he started buying albums by the tractor trailer load, usually as they were being returned from the distributor to the manufacturer as unsold. Minimum bid is a bargain at $3,000,000.

Filed under: Music No Comments