development

Running the Glassfish updatetool on a remote server

I’ve been playing around with JRuby on Rails and Glassfish and really like the simplicity of deploying simple WAR files to a Glassfish server. Messing around with Apache configurations and managing a bunch of mongrel processes is just not my favorite pastime, plus I like to have the option of running other J2EE webapps on the same server, and interface my RoR app with existing Java libraries.

I ran into some problems trying to get the updatetool for Glassfish working on my VPS (at Rimuhosting) though. The updatetool is a Java Swing app and I’ve never run any GUI apps on this remote host before. It doesn’t have Gnome or KDE running so VNC was not an option. The trick is mostly just to set up your systems for running remote X11 applications over a SSH tunnel. Here’s how I got it to work…. I should say this server runs Ubuntu Hardy and locally I’m on Mac OS X so the X11 install from the Mac OS installation disks was the easy part.

Here’s what I had to do on the remote host:

(continue reading…)


jQuery plugin for communication between browser windows

Ajax is great for sending data back and forth between a browser window and the server, but when it comes to communication between two browser windows, there are few libraries that can help you out there.

I’ve been working with jQuery for over a year now and have always wanted to give something back to the user community by releasing my own plugin. Unfortunately it seemed like every type of generic functionality I might ever need had already been developed by others. Until last night.

I was working on a webapp in which my main browser window had to open a popup window, and the user would then perform an action in this window. Upon completion of that action the main (parent) browser window needed to be notified.
Though parent and child window can easily access eachother’s DOM, a common way to get a value from one window to another is by setting a value on a hidden input field of a form in the other window. This requires you to add form markup to your page, which is clunky. A second issue is that if you have several types of events or data to send to the other window, you’ll need to add an input field for each type. And a third issue I ran into is that ‘change’ events do not seem to fire for an input field if that field was updated by another window. ‘change’ or custom events using jQuery didn’t work either this way. ‘click’ events on links or buttons do work, but they would need to be hidden, otherwise the user could click on them too. I got it all working but this all started to look like an ugly hack, cluttering my pages with messy javascript and markup code.

(continue reading…)


Ruby controller for the Trendnet TV-IP400W PTZ camera

I thought I’d follow up on my post of a little while ago about the drivers for the Trendnet TV-IP400W Pan-Tilt-Zoom camera. I wrote a ruby driver for this thing, which makes it trivial to control the camera from any Ruby application. It’s just a single Ruby file, and though I’ve entertained the thought of figuring out how to pour it into a gem and publish it to the plugin repository, I’d probably only do that if there are a significant amount of people interested in using it and/or contributing to it.

As with the old Perl driver for Zoneminder (which I’ve been told doesn’t work anymore with the latest version of ZM, since the interfaces for the PTZ drivers have completely changed), this driver only controls the pan and tilt functions of the camera. Actually, you can also put it in swing mode and store or access preset positions, but none of the available functions actually do anything with the video stream. The video can simply be accessed at:

http://yourcam/image.jpg to grab a single frame of the current camera view
http://yourcam/video.cgi to get the mjpeg stream from the camera

There’s no real zoom control since the cam only has a digital zoom, which I believe is implemented in the client software only (so there’s no way to actually have it stream a zoomed image to your client).

(continue reading…)


The Trendnet TV-IP400 / TV-IP400W protocol

The Trendnet TV-IP400 is a fun little camera that will work great for home surveillance, as a controllable web cam, etc. The only problem is that the software that comes with it really sucks. I reverse engineered the protocol that is used to control the camera, and wrote a ZoneMinder driver for it… go here for more information. This follow up describes the control protocol that I reverse engineered, and contains most information that you’ll need if you want to write your own driver. I’m assuming that you are familiar with HTTP requests and that you know how to send GET and POST requests to an IP address.

Feel free to use the information in this page in any way you want. I make no guarantees as to its accuracy or completeness. If you write any software based on this info, please let me know!

(continue reading…)


Controlling the Trendnet TV-IP400W camera with ZoneMinder

Update (7/18/08): this driver and instructions work for ZoneMinder 1.22.x only, see my update for ZM 1.23.x support.

I can’t even remember when was the last time that I had to reverse engineer something.. it may have been as long ago as my college days. But last week I had a couple of evenings of fun figuring out the inner workings of my Trendnet TV-IP400W. This is a cool little internet camera with built in wifi and a built in web server. You can control it from a browser and you can actually pan and tilt this camera around the room, so even though the picture quality isn’t great (probably comparable to your average webcam), it can be very useful if you want to keep an eye on your house, your pets, your baby, etc from anywhere in the world. The best part: you can pick one up online for less than $200, which is a steal for a pan/tilt IP camera.

The built in web server is useful for checking up on the live situation, but it does not have any features to automatically notify something or someone if motion is detected in front of the camera. The windows control application does do motion triggered recording, but if you want to monitor your camera from outside your home you’ll have to set it up to email all the videos to yourself, as the windows app can’t function as a web interface.

All of this makes this camera more of a toy, with limited remote monitoring features. But, I wouldn’t be me if I didn’t figure out a way to get what I wanted from this thing. Since I already have 2 Linux boxes running Misterhouse, MythTV and various databases and developer tools, I figured one of these boxes could easily function as a surveillance system as well.

So I set out to install ZoneMinder on my Ubuntu system. ZoneMinder is an extremely full featured (open source) video camera security and surveillance system. It supports multiple CCTV and IP cameras, has a web interface, it can control PTZ (Pan Tilt Zoom) cameras, and supports custom triggers, multiple motion zones per camera, etc.

After a little bit of tinkering I got ZoneMinder running, and it turned out that even getting it to capture video from my Trendnet cam turned out to be trivial… All I needed to do was to configure the camera stream to http://192.168.0.140/video.cgi on my home LAN!

Unfortunately, that’s as much as I’d be able to do with ZoneMinder and this cam. The IP400W uses a proprietary control protocol to move the camera and there wasn’t any ZoneMinder driver for it yet.

But how hard could it be to write one?

(continue reading…)


TimeBridge is live

Today is the public release of the TimeBridge.com service. TimeBridge allows people to schedule meetings with each other, and also share availability information with your contacts, which works both with your Outlook or Google calendar. If you’ve ever tried to set up a meeting with a few people then you know the problem: finding a meeting time that works for everyone can easiliy take more time than the meeting itself. TimeBridge alleviates that pain and will contact all meeting attendees with your proposed meeting times, and (if possible) automatically confirm that time that works for everyone. TechCrunch just wrote up an article on Timebridge, do check it out, or of course go straight to TimeBridge.com and start organizing!

I’ve been doing contract work for TimeBridge since February, when me and my biz partner Tim from
BarbaryCodes
wrote the very first lines of Ruby on Rails code for their webapp. It’s been a fun project, and the site is very client side heavy so there was a lot of interesting Ajax and Javascript work involved. They’ve been building up an excellent development team of their own and while I’m still involved in troubleshooting and bugfixing, that work may be dwindling down soon. So if you need help with any Rails or J2EE projects, drop me a line, I may be available again soon.

1 Comment more...

how to replace urls in (user submitted) text with active links

Ever had to display user submitted content on a web site you’ve created? Then you’ve probably had a requirement to display urls in submitted text as actual live links.

Despite the fact that this must have been done a gazillion times before, I couldn’t find any site that would give me a ready to use regular expression to turn text bits that look like URLs into actual hyperlinks. But some Googling, a couple of hours and regex-refresher later I had something that appears to work quite well:

in = "go check out www.sfpeter.com or http://sfpeter.com"
in.gsub!(/([^/])(www.([w/_.~])*)/, '\\1\\2')
in.gsub!(/([^"])(https?://([-w.]+)+(:d+)?(/([w/_.]*(?S+)?)?)?)/,
    '\\1\\2')

this will turn both links in the input string into active links (that will open in a new browser window). It will consider strings that either start with www.<something> or http(s)://<something> to be a web URL. Users often don’t add ‘http://’ to links they submit, so this will still work as long as their links start with ‘www.’ .

One of the tricky issues was making sure that after replacing www.sfpeter.com with an active hyperlink, the second regex wouldn’t come by and substitute the link again, so you end up with something like this

www.sfpeter.com">www.sfpeter.com

To prevent this, the second regex ignores any urls that are preceded by a double quote.

This is Ruby code of course, but the patterns should work fine in any language. I could take it one step further and hyperlink anything that ends in .com, .net or other well known top level domains, so just sfpeter.com would be a match too, but I’ll leave that for later. I’m open to suggestions for improvement!


jquery rocks

I’ve been working pretty insane hours lately, because I’m now working on three projects, of which one is a fulltime one. I’m enjoying it though. Ruby on Rails rocks, and it’s fun to be doing a lot of work on front end development again. One of the things I’ve actually been enjoying is Javascript development. The general consensus amongst J2EE developers seems to be that javascript is something that loosely resembles a real programming language like java, that it is useful to script hackers, and that implementing things on the server side is always better than in javascript. Especially if you want it to work in all browsers. I probably even made statements like that myself less than a year ago.

But after playing around with various javascript libraries like the google maps api, the yahoo UI library, prototype and scriptaculous for several months, I now beg to disagree with my former J2EE co-workers. Javascript is, in fact, a real programming language, and a really cool one too. The reason for my most recent excitement about javascript is actually jQuery. If you ever need to write any client side functionality for any site (and you probably do, if marketing is telling you that you need to start using Ajax, even though they don’t really know what that means), you owe it to yourself to check out jquery. Why is it so good? Because it allows you to keep your html markup nicely separated from your javascript code, because you will be able to write your functionality in half the amount of code of what you’d need if you weren’t using jquery, and because browser compatibility issues are a thing of the past with jquery. Props to John Resig for writing such a great library, and for the ever growing user community contributing jquery plugins and jquery based functionality. (Now the only thing that’s left on my wishlist is a tool or library that will make browser CSS compatibility issues a thing of the past too.)

Hopefully, I’ll be contributing to this jquery community myself too soon, since I’ve developed my own javascript library that ecommerce sites in particular may end up being very interested in. Stay tuned, more info to follow soon…


Ubuntu upgrade gone bad

I spent the entire day today trying to install PostgreSQL with PostGIS support on my Ubuntu Linux server. (PostGIS will add features for geographic queries to PostgreSQL, but more about that later). Unfortunately my previous experience with Ubuntu had led me to believe that installing this PostGIS extension would be a breeze. Wrong. I spent all day trying to download, compile and install all of its dependencies… flex, libgeos, proj, etc. Even with the excellent instructions on the PostGIS site I never got it to install and actually work in PostgreSQL. But then the instructions said “At Version 6.10 of Ubuntu, using Postgresql 8.1, postgis is available using apt-get.”… OK, the prospect of being able to install this with one simple command was reason enough for me to upgrade my Ubuntu 6.06 installation to version 6.10.

But disaster didn’t really strike until after the hour and a half download and installation procedure. Ubuntu told me it was time to restart but after restarting I never got to see my desktop again. The GUI crashes with the message “Server Authorization directory (daemon/ServAuthDir) is set to /var/lib/gdm but this does not exist.”, but the problem is even far worse than that. The /home/ directory is completely empty, so all my files are gone, as well as other directories such as /var/lib and /var/spool. The current state of my server is so dire that it looks like I have no choice but to wipe everything clean and install Ubuntu 6.10 from scratch now.

Fortunately there wasn’t any personal data on there, other than the programs I had installed, but I should have done some reading before I tried this. As it turns out there are many other people for whom this upgrade ended in a nightmare as well. Aarrrrggh! I don’t like to complain about open source software because many Ubuntu developers work hard for the community, for little or no pay, but I think that at least a warning on the installation site would have been appropriate here.


Copyright © 1996-2010 sfpeter.com. All rights reserved.
iDream theme by Templates Next | Powered by WordPress