David Sterry's Blog


Saturday, December 31, 2005

Chatr 0.4

I released 0.4 of Chatr, my AJAX/php chat software today. It getting fairly useable and I think any site that's interested in having their users meet spontaneously, might want to give it a try.

The challenges I tackled in this version had to do with the nature of AJAX and it's usually event-based operation. If someone leaves my chatroom, it's because they generally go to another webpage or close their browser. Both of these operations are quick and provide the javascript client zero time to say, hey we're exiting. I know Blogger does ask if you're sure you want to leave so maybe I should take a look at their code. Anyway, at this point, the user is there and then he isn't.

That means I have to keep track of pings to know that the user is still at the chatroom. I ran into one problem where pings would stop coming in IE thereby leading to people being timed out but still looking at the room and requesting chat text as much as an active user. This "spectator" mode was not desirable so with this version I fixed it, those timed-out users now see an error message and their client recieves a message in the process to halt requests.

You can give it a try, download it or check out the readme.

Friday, December 30, 2005

TST down

Trend Sweet Trend suffered a glitch over the past several days. To begin with my power went out over xmas so updates stopped occurring until I could get back and turn on my Fedora server.

Then TST began to show only one link rather than the 25 or 35 it usually does. This was caused by a deficiency in my livemarks curl script that couldn't handle multiple matches per line. It's all fixed now but it gave me pause.

If you're thinking of using "if(/pattern/) " to match something in a feed and do something with it, you might as well replace that bit with "while(/pattern/g) " so you'll match pattern as many times as it might occur in a line.

With web services, you've got to think ahead and program for the odd change that might happen upstream. You've got to think what if there's more than one match per line in this regex script or if the odd formatting change should occur.

Wednesday, December 21, 2005

Chat-o-licious php

I was so impressed with Kevin Mesiab's Chat-o-licious that I decided to rewrite the server in php. At the time of this writing it can post, add users, and track pings. Stay tuned for an update on a live demo.

Update (7:39pm 12-21-05): Here's the beta.

Monday, December 19, 2005

Home Theater Computer

Home theater is no longer as plug 'n play as it used to be. Time was, you could plug the TV into the wall, attach the VCR and you were good to go. Nowadays, there's TiVo, DVD recorders, Home Theaters in a box, and cable/sattellite set-top boxes not to mention the legacy VCR.

Getting all of these to play together so you can use them can be quite challenging. On the last couple of setups I've done, I've actually gotten out pen and paper and made a circuit diagram to figure out the best way to set this stuff up. Inevitably this is followed by a few minutes of "training" so the user can access their home theater "applications." You know... watch TV? Or record a tv show? Or maybe watch a movie?

Then there are the remotes: I've got a remote for each device and a "universal" remote to try to consolidate tasks when possible. My universal remote is pretty good but for some things you've got to go native so the universal remote mostly just brings my remote total up to 5. Yes, 5.

What about those connections? RCA, component, svideo and fiber don't help to simplify. They give you some control over quality and help with interoperability but if I'm going to need to be a computer expert to setup a home theater, then I'm just gonna say hell with it and build a computer to do this stuff ide, mouse, keyboard and all. When it comes to doing the things you want to do, there really needs to be a bus and that's what "advanced" technologies like SCSI and PCI are for.

What would I tell my Home Theater computer? "Source Action Destination." I would press(or say) "DVD play TV", "DVD record DVD", "TV record VCR". And my life would be simple and quality could be upgraded and the whole home theater can be on the internet, and remotely controllable.

All I need now is a VCR with an IDE interface and an 800w 5.1 sound card.

Saturday, December 17, 2005

Search phrase trends

Using my patented trend technology, I've created another trends page. This one is based on Yahoo! Buzz, their almost daily listing of the most popular search terms for the day.

Whereas Trend Sweet Trend tends to show lots of developer and blog links, the search phrases page shows a lot more celebrities and holidays. It might be useful if you want to get your site or blog read by the masses.

Now if I can just start listing the popular search terms for a few days from now...

Thursday, December 15, 2005

del.icio.us down

Over the past day we've seen some weirdness over at del.icio.us. Last night I saw this error:

System error

error: Can't call method "prepare" on an undefined value at /www/del.icio.us/comp/user/get line 13.
context:
...
9: my $usedb = 'master';
10: my $ret;
11:
12: if (!$auth_user) { $usedb = 'user' }
13: if (!exists ($db->{$usedb})) { $usedb = 'master' }
14: $user_name_q->{$usedb} = $db->{$usedb}->prepare('select * from users where user_name = ?');
15: my $query = $user_name_q->{$usedb};
16: $query->execute(lc($user_name));
17:
...
code stack: /www/del.icio.us/comp/user/get:13
/www/del.icio.us/site/dhandler:194
/www/del.icio.us/site/autohandler:110
raw error


Then on clicking raw error it showed this stuff here:

Can't call method "prepare" on an undefined value at /www/del.icio.us/comp/user/get line 13.

Trace begun at /usr/share/perl5/HTML/Mason/Exceptions.pm line 131
HTML::Mason::Exceptions::rethrow_exception('Can\'t call method "prepare" on an undefined value at /www/del.icio.us/comp/user/get line 13.^J') called at /www/del.icio.us/comp/user/get line 13
HTML::Mason::Commands::__ANON__('dbh', undef, 'user_name', 'dsterry', 'auth_user', 'dsterry') called at /usr/share/perl5/HTML/Mason/Component.pm line 134
HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0x1d3f4f0)', 'dbh', undef, 'user_name', 'user', 'auth_user', 'user') called at /usr/share/perl5/HTML/Mason/Request.pm line 1069
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 1068
HTML::Mason::Request::comp(undef, undef, 'dbh', undef, 'user_name', 'user', 'auth_user', 'user') called at /www/del.icio.us/site/dhandler line 194
HTML::Mason::Commands::__ANON__('dbh', undef, 'auth_user', 'user', 'items', 100, 'tagview', 'cloud', 'tagsort', 'alpha', 'bundleview', 'hide', 'cookies', 'HASH(0x1b52740)', 'browser', 'ff') called at /usr/share/perl5/HTML/Mason/Component.pm line 134
HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0x1b14410)', 'dbh', undef, 'auth_user', 'user', 'items', 100, 'tagview', 'cloud', 'tagsort', 'alpha', 'bundleview', 'hide', 'cookies', 'HASH(0x1b52740)', 'browser', 'ff') called at /usr/share/perl5/HTML/Mason/Request.pm line 1074
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 1068
HTML::Mason::Request::comp(undef, undef, 'dbh', undef, 'auth_user', 'user', 'items', 100, 'tagview', 'cloud', 'tagsort', 'alpha', 'bundleview', 'hide', 'cookies', 'HASH(0x1b52740)', 'browser', 'ff') called at /usr/share/perl5/HTML/Mason/Request.pm line 760
HTML::Mason::Request::call_next('HTML::Mason::Request::ApacheHandler=HASH(0x1ad11c0)', 'dbh', undef, 'auth_user', 'user', 'items', 100, 'tagview', 'cloud', 'tagsort', 'alpha', 'bundleview', 'hide', 'cookies', 'HASH(0x1b52740)', 'browser', 'ff') called at /www/del.icio.us/site/autohandler line 110
HTML::Mason::Commands::__ANON__ at /usr/share/perl5/HTML/Mason/Component.pm line 134
HTML::Mason::Component::run('HTML::Mason::Component::FileBased=HASH(0x1b52bd0)') called at /usr/share/perl5/HTML/Mason/Request.pm line 1069
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 1068
HTML::Mason::Request::comp(undef, undef, undef) called at /usr/share/perl5/HTML/Mason/Request.pm line 338
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 338
eval {...} at /usr/share/perl5/HTML/Mason/Request.pm line 297
HTML::Mason::Request::exec('HTML::Mason::Request::ApacheHandler=HASH(0x1ad11c0)') called at /usr/share/perl5/HTML/Mason/ApacheHandler.pm line 134
eval {...} at /usr/share/perl5/HTML/Mason/ApacheHandler.pm line 134
HTML::Mason::Request::ApacheHandler::exec('HTML::Mason::Request::ApacheHandler=HASH(0x1ad11c0)') called at /usr/share/perl5/HTML/Mason/ApacheHandler.pm line 793
HTML::Mason::ApacheHandler::handle_request('HTML::Mason::ApacheHandler=HASH(0x1acc1c0)', 'Apache=SCALAR(0x1087150)') called at (eval 43) line 8
HTML::Mason::ApacheHandler::handler('HTML::Mason::ApacheHandler', 'Apache=SCALAR(0x1087150)') called at /dev/null line 0
eval {...} at /dev/null line 0

then Wednesday from around 4:30 pm to Thursday 1:00 am PST del.icio.us was down showing the following message:

del.icio.us is down for maintenance. we'll be back in one hour.

I just checked again, I saw my user page and then I saw the first error again. It kind of looks like the database is having issues. Unfortunately all this meant that Alex's Livemarks and my Trends were both having issues today too. Hope they get all this worked out soon...

Wednesday, December 14, 2005

Webcron.org

After I wrote my last article on Cron for Web 2.0, I did a bit more searching and found webcron.org. It's very close to what I described and in my looking through the site, they apparently have about 10,000 users which is quite something.

I figure the market for this is anyone who has a cheap shared webhosting account and needs to schedule regular maintenance. They've been around for 4+ years so how's that for being ahead of the Web 2.0 curve!

They have a highly visible warning when you're signing up not to use the service to simulate clicks though I doubt it's very good for doing such a thing. Imagine all of your clicks coming from a small set of IP addresses and at a highly predicatable schedule. Not too stealthy!

A couple things to note about the site. It doesn't have any support for authentication which is something I would want to use were I to be doing system management tasks remotely.

When I was looking at the site at 12:02 AM PST, it stopped responding. I wonder if the webserver is also the cron server and just how long the queue for web requests takes to complete on the hour requests.

When I first loaded it, it was in French and the button to switch to English is hidden below. They might do well to detect the user's country and display the appropriate language.

Lastly, I wonder if there's any feedback mechanism to the site. Were I to develop something similar I would probably generate a small piece of code that could be pasted into the end of the user's scripts so I would know they finished successfully. Then maybe try up to 3 times to increase reliability.

Anyway, if you're looking to schedule some tasks on a non-cron-enabled web site, you might check out webcron.org.

Sunday, December 11, 2005

Cron for Web 2.0

For TST, I run several processes each hour of the day and I use cron to do it. It's quite simple when you have linux box running 24/7. All you have to do is type "crontab -e" and enter a line like "01 * * * * /script_folder/script_to_run" then ":wq" to save the file.

I discovered yesterday that my internet connection and local power grid are not as reliable as I would like. Consequently, I'd love it if my web host could run cron jobs for me. They don't. Many web hosts offer cron jobs, but if it's not part of your current hosting plan, and you don't really want to upgrade or switch hosting providers, you're at a bit of a loss.

So I've got an idea to create a web-based cron service to grab the url of your choice on the schedule you decide. That way you can make a little php or perl script, put it in an obscure or password-protected folder on your server and have it run when you want.

Now that's what I would call a web service.

Thursday, December 08, 2005

New with Screenshots!

I've taken Trend Sweet Trend further. Now, you can see screenshots of each link via css rollover. The page takes a little longer to load but I think it looks cool and is at least a little bit stickier.

To do this, I created a script that submits urls to Browsershots and later checks to see if they're done. Then I store the images on my server and use css to display them next to each link. The lightweight version of TST is still available here.

I want to thank Johann Rocholl at Browsershots for his help in getting this to work and for making such a cool web service.

Sunday, December 04, 2005

Ultimate iPod

I just acquired a 20gb iPod and decided to set it up in style. That meant I wanted to get my favorite 180 cd's onto it and be able to use it with my car stereo.

I've been keeping up with the latest news about the iPod so I knew I could use Winamp to manage all the songs and an iTrip to connect to the stereo. Here's what I did:

1: Setup Winamp with the ml_ipod plugin. This plugin allowed me to fill up the iPod using Winamp thereby saving myself some headaches that come with using iTunes. I already had Winamp so I just downloaded and installed ml_ipod and was good to go.

Once this plugin was installed, the iPod showed up as a device in the Winamp music library and Winamp could send music to and otherwise manage the iPod. Like butter.

2: Setup Audiograbber with LAME. Audiograbber automated the CD to mp3 process while keeping my music out of some proprietary database like in Musicmatch, Windows Media Player or iTunes...Anyways, once it was setup I only had to click 3 times and wait 20 minutes to rip each CD.

LAME(Lame Ain't an MP3 Encoder) takes the huge wav files and turns them into tiny, yet high-quality mp3 files. I chose to rip at 160kbps to achieve a nice balance between mp3 size and sound quality. To speed up the process, I actually set this up on 4 computers and got up to a rate of about 12 CD's per hour.

3: Move the mp3's to the iPod. With my iPod fully charged, I plugged it in to my laptop, used Winamp to format it and transferred the 3000+ songs I just ripped. Using a USB 2.0 card with my laptop going from an external hard drive to the iPod, this process took about 45 minutes. Not bad.

4: Plug in the iTrip. This little device takes the headphone jack and uses an FM transmitter so the car stereo can pick it up wirelessly. This is the simplest part...just plug it in the top of the iPod, tune the stereo to 87.9 FM and rock out.

One caveat: the Griffin iTrip I was using turned out not give the best quality(frequency response and static) so I'm using a stereo-mini-to-tape adapter with my car stereo until I get an iPod dock installed.

The most time consuming process in all this is the ripping. You're basically baby sitting the computer(s) during that time but once it's done, you never have to do it again. Plus having all your music in mp3s will enable all kinds of iPod and music sharing fun. Which is nice.