Posted by & filed under Developer Blog.

Ever wonder who’s listening to your iTunes music when sharing it on your network? There are one or two widgets and tools made for Mac OSX that allow you to see this information, but I listen to iTunes on Windows XP. My co-worker and I were able to come up with a way to not only see who’s connected, but whether they are listening to a song, which song they are listening to, and which songs they have listened to and when. It’s not fool proof, and the data gets a little skewed when you have more than one person connected and listening. But at least you can get an idea. The process isn’t pretty, but the results are fun.

The first step is to download a simple but very handy and very free application called TCPView by Sysinternals. Once you run TCPView, you will be able to see who’s connected to iTunes and whether or not they are listening to a song. As Sysinternals website says, "TCPView is a Windows program that will show you detailed listings of
all TCP and UDP endpoints on your system, including the local and
remote addresses and state of TCP connections." One of the best features about TCPView is the icon next to the listed connection, which allows you to find the application you would like to get information for quickly at a glance. Once you get TCPView running—assuming iTunes is also running and sharing music—you will see a list of connections with the iTunes icon next to the process name (iTunes.exe) and process number. Look for TCP connections where the Remote address is something other than yourself. This means that whatever machine is listed there is at least attached to your shared music. If they press the "eject" icon next to your list of shares, they are no longer connected to you via TCP and it will not show up in TCPView even if they can still see you listed in the Shared Music list. If that same machine is listed more than once, they are not only connected to your share, but they are also listening to a song!

Now to find out the details about what song they are listening to. Using WindowsXP’s built in file search, enter "*.mp3" as all or part of the file name and ask it to look in your "My Music" directory (or wherever your music is located). Before searching, click the drop down (double down arrow) next to "When was it modified?" then select "Specify dates". In the drop list, select "Accessed Date" and put today’s date as both the "from" and the "to". Now run the search. Once the search has completed, right click one of the column headings (Name, In folder, Size, etc.) and select "More…" at the bottom of the list that opens. From that dialogue check the "Date Accessed" option, then click "OK". Now click the column heading for Date Accessed to sort the results (you may need to click twice to get the most recent at the top). Chances are, the song listed as most recent accessed is the very song being played by the machine connected to your computer! You also have a list of all the songs played today as part of your search results (obviously this includes files you have listened to as well as what others have listened to).

Windows 2k doesn’t let you see the "Date Accessed" in file search results, so it’s more difficult to know most recent songs unless you navigate through each of your songs in your music directory. You can add this column in explorer in Win2k, just not in search results. However, don’t be too sad if you are using Windows 2000, because you can have some fun that Windows XP users most likely can’t. If you are using Windows 2000, open a command prompt (Run -> cmd) and send them a system message! (For those of you who are already familiar with Windows Messaging you can stop reading here.) Do this by entering:

net send hostname write a message here

where hostname is the exact remote address listed in TCPView as the person connected (excluding port number which includes the : and everything after it. For example if you see listed in TCPView, only type in the command prompt) and message is whatever message you want (what do you think of that song you are listening to?). Be careful using this feature! If you forget to put the hostname you could send the message to your entire company! Try sending it to your buddy that sits next to you first so you can see what the result is like.

Posted by & filed under Developer Blog.

Three months ago I posted about getting my Netgear WG511 802.11 b/g wireless card to work in Linux. Well, this weekend I figured out a much, much simpler way, and wanted to update my documentation.

In my previous post I discussed that I had tried the Prism54 method without luck and resorted to the ndiswrapper. Then I proceeded to give lengthy instructions on what I had to do to get the ndiswrapper to work. The last thing I wrote was that you had to put the firmware in the /usr/lib/hotplug/firmware directory to get ndiswrapper to work.

What I didn’t realize is that ndiswrapper wasn’t working at all, and that putting that firmware into /usr/lib/hotplug/firmware was actually enabling Prism54 to work, and therefore was the only step necessary!!

So without further ado, if you want to get your WG511 card working, plug the isl3890 file into the /usr/lib/hotplug/firmware directory and reboot your computer.

There are 2 ways to do this, you can download the PCI driver from Prism54 or you can find the WG511DCB.arm file from Netgear and rename it isl3890. I would offer it for download here, but I don’t want to run into the same problems that have had with making these files publicly available. I actually found it by installing the old driver (I think v1.1) from the CD-ROM that came with the card and looking in C:Program FilesNETGEARWG511Driver, so you might try that first. Once you have this file, simply mkdir /usr/lib/hotplug/firmware if it doesn’t already exist and drop it in there (that’s it!).

Note: One word of caution. My wg511 card says on the BACK in small print on the right side above the MAC address that it is “v2.0” but my co-worker’s wg511 says on the back that it is “v3.0” and we cannot get it to work! If you have a v3.0 card and have it working please let me know

Posted by & filed under Developer Blog.

In MySQL 4.1 and up, the properties of the TIMESTAMP column type change from YYYYMMDDHHMMSS to YYYY-MM-DD HH:MM:SS. If you have built anything in PHP that relies on the old format, it will break if you upgrade from older versions of MySQL (such as this blog!).
If you want the same view of a timestamp field in 4.1.x as it was in in earlier mysql versions, you can add a “+ 0” to the column name.

SELECT ts_col + 0 FROM tbl_name;

That much has at least been documented and can be found after a quick google search. However, getting the earlier format to appear in PHP is undocumented as far as I can tell. You might just guess that you nees to use the exact same sql statement, and you’d be right for the most part:

$result = mysql_query("SELECT ts_col + 0 FROM tbl_name");
$row = mysql_fetch_array($result);

But what took some trial and error to figure out for myself, was that you then have to use the “+ 0” again when you refer to that column as such:

$date = $row['tbl_name + 0'];

I haven’t figured out how to get the date formatted yet when doing a wildcard query like this:

SELECT * + 0 FROM tbl_name;

so if you know how to do that please leave a comment here.

Posted by & filed under Developer Blog.

I’ve spent the last few days trying to figure out how to get the mod_jk connector working so that I can use tomcat and httpd together. The problem, like most linux operations, is that it’s very poorly documented. Not only that, but the decent documentation you find is either outdated or is very specific to the writers desired configuration, and things don’t always work right when you try to revert those instructions back to a “default” configuration for your own use. I hope to document my finding before I forget them, and in a manner that is easy for anyone to understand.

First, you need to install 4 things: Apache, Tomcat, JDK, and Apache2-devel. As of this writing, the latest versions are Apache 2.0, Tomcat 5.5, J2EE SDK 1.4, and Apache2-devel is the development tool for Apache2 that will be needed to create the mod_jk connector. I was able to install Apache2 and Apache2-devel as RPMs in Mandriva (formerly Mandrake) LE 2005 (10.2). For instructions on how to install Tomcat and JDK, check out Integrating Tomcat and Apache on Red Hat Linux <–this site is an excellent resource, but after following it’s instructions to a “T”, I was never able to get things working. I’ll refer to this site often, and let you know what WAS useful from it. Hopefully if you are to the point where connecting Tomcat and Apache is important to you, you have already figured out enough about Linux that installing these 4 things isn’t too big of a problem for you.

The next thing you should do is build the mod_jk connector. The Apache website will try to convince you that you should just download a binary rather than build it from source, but I was much more successful building my own than using the binaries from Apache. Once again the Apache website’s documentation is a freaking mess! I’ll refer to it occasionally and let you know what WAS useful. To build the mod_jk connector, refer to section 4.3 on the Integrating Tomcat and Apache on Red Hat Linux page. These instructions are clear and precise so I won’t bother re-writing them here.* One thing I will mention that those instructions were unclear about, is that you need to be inside the CONN_SRC_HOME/jk/native/ directory in order to run ./ and ./configure, otherwise you will get errors. I also had to copy to /usr/lib/apache2/ instead of where he put it.

Next you need to create a file and place it in the /etc/httpd/conf directory. Using the Minimum from Apache’s documentation worked for me. Just copy and paste everything in the blue box into your file.

Next follow the instructions on the Apache website under the subsection titled Using Tomcat auto-configure. These instructions are written backwards, so remember that you need to do the second part before you even know how to do the first part because depending on your flavor of Linux, the mod_jk.conf file will end up in different places and with different names. I also added workersConfig=”/etc/httpd/conf/” to my server.xml file to get this to work, like this:

<Listener className=”org.apache.jk.config.ApacheConfig” modJk=”/usr/lib/apache2/” workersConfig=”/etc/httpd/conf/” />

In tomcat’s default server.xml file, I put this <Listener> tag just between </Host> and </Engine> at the bottom of the document.

Next, copy the Simple configuration example into the bottom of your httpd.conf file. If you are indeed using Apache 2.0, be sure to remove the line “Add Module mod_jk.c”. If you are using Tomcat 5.x, change the /examples/ directories to /servlet-examples/ and /jsp-examples/ respectively, since they are now broken out like that instead of being lumped together.

Now restart both Apache and Tomcat and you should be good to go. The way I tested was by going to localhost:8080 and in the left hand side of the default tomcat screen there is a section titled “Examples”. Click on either JSP Examples or Servlet Examples and then choose an example listed there (preferably the “Hello World” examples, of course!). Now just replace localhost:8080 in your address bar with localhost (port 80) and you should see the exact same examples but without the static content (such as images). The configuration above assumes that your application’s static html files will be served from your Apache directory and dynamic files (servlets and jsp’s) will be served from your tomcat directory.


*If for some reason a site goes down and a link is broken, please let me know! Even if you are reading this 3 years from now! A lot of my frustrations from getting this to work were broken links and I’d hate for this documentation to become one of those.

Posted by & filed under Developer Blog.

I’ve been using an image pre-loader that I wrote myself for several years now, whenever I need to load an external jpeg into my movie. I’ve also been in the habbit of re-naming my .jpg images to .jjj in order to trick AOL’s image compression “feature.”

What I never expected is that AOL would also find a way to break my pre-loader! As far as I can tell, AOL is somehow and for some reason tacking on an extra kilobyte or so to the actual size of my images.

Like most pre-loaders, I am looping through looking at the total bytes loaded and comparing that with the total bytes. The problem is that in AOL (I’ve only tested 9.0 “Security Edition”) when the image has loaded what appears to be 100% of the image, the total bytes loaded is larger than the total bytes. Since my pre-loader was set to fade in the image when total kilobytes loaded was equal to total kilobytes (kbl==tkb), my pre-loader would hang waiting for them to be equal when in fact they were not. I assume that more than one kilobyte was loading everytime my script would loop, and therefore never registered the exact number equal to tkb it just skipped on past.

To fix this problem, I changed my script to fade the image in when the total kilobytes loaded was equal to or greater than the total kilobytes (kbl>=tkb) and the problem went away.