Archive for Hacks

Deploying GWT Applications with Jetty

I’m not a big fan of tomcat, preferring Jetty where possible. Unfortunately there are a lot of catches involved with getting GWT applications working. I’ll try to break the changes down here. This assumes that you already have a GWT project built and made with projectCreator which you are migrating into Jetty.

1) Pull the start.jar, bin/jetty.sh script (which will be moved to the base of your distribution), lib and etc directories from your Jetty distribution, and put them in $DIST (your distribution directory)

2) Change your (appname)-shell script to be like the following:
JettyTest-shell

#!/bin/sh
GWT_HOME=/usr/lib/gwt
ENTRY_POINT=net.cognitiveconsulting.gwt.JettyTest
HOST_PAGE=JettyTest.html
APPDIR=`dirname $0`;
CPGWT=$APPDIR/src
CPGWT=$CPGWT:$GWT_HOME/gwt-user.jar
CPGWT=$CPGWT:$GWT_HOME/gwt-dev-linux.jar
java -cp $CPGWT com.google.gwt.dev.GWTShell -logLevel DEBUG -noserver -port 8080 "$@" $ENTRY_POINT/$HOST_PAGE

3) Change your (appname)-compile script to look like:
JettyTest-compile

#!/bin/sh
APPDIR=`dirname $0`;
echo "Compiling GWT portion of application ... "
java -cp "$APPDIR/src:$APPDIR/bin:/usr/lib/gwt/gwt-user.jar:/usr/lib/gwt/gwt-dev-linux.jar" com.google.gwt.dev.GWTCompiler -out "$APPDIR/webapps" "$@" net.cognitiveconsulting.gwt.JettyTest;
echo "Compiling native Java part of application ... "
ant -f net.cognitiveconsulting.gwt.JettyTest.ant.xml
echo "Moving pieces into Jetty library path ... "
( cd bin ; jar cf ../lib/net.cognitiveconsulting.gwt.JettyTest.jar * )

Remember, after this, your output directory is no longer www, it’s now “webapps”.

4) Create the directory $DIST/webapps/(appname)/WEB-INF, and create a web.xml file like this, with the definitions for your remote services:
webapps/net.cognitiveconsulting.gwt.JettyTest/WEB-INF/web.xml


  [servlet]
    [servlet-name]Test[/servlet-name]
    [servlet-class]net.cognitiveconsulting.gwt.server.TestImpl[/servlet-class]
  [/servlet]

  [servlet-mapping]
    [servlet-name]Test[/servlet-name]
    [url-pattern]/rpc/net.cognitiveconsulting.gwt.client.Test[/url-pattern]
  [/servlet-mapping]

(Please note that because wordpress ate my XML, I used a different kind of brackets, please substitute as required.)

5) Create the ant build file:
/usr/lib/gwt/projectCreator -ant net.cognitiveconsulting.gwt.JettyTest

6) Make sure you have created working servlets under the internal tomcat implementation before you proceed, making sure that the servlet information is in the .gwt.xml file in your source directory like this:

7) Make sure that a copy of $GWTDIR/gwt-servlet.jar and any other libraries you are using are installed in $DIST/lib — forget this and nothing is going to work.

8) Create an empty “logs” directory under $DIST.

You should be able to start Jetty at your convenience and browse to the (appname)/(startpage).html page. If you want to pack it as a war, just zip the (appname) directory in $DIST/webapps with a .war extension. Also, running jetty.sh with the parameter “supervise” will allow you to watch the logs as they go by.

Hope this has been informative and helpful.

UPDATE: Jan, one of the webtide guys, was nice enough to send me an ant build file which does much the same type of thing I was attempting to do here. It is attached here, for anyone else who would like a copy.

Comments (2)

Improved Film Noir rendering

Thanks to my brother, who is much better with gimp-perl than I am, there’s a vastly improved version of the original RenderFilmNoir.pl script, available here.

If you get a chance (shameless plug), please patronize his Flickr page, as we does work very hard at being a great photographer …

Comments

Linux support for ADS DVD Xpress DX2

I take no credit for this at all, but the maintainer of the go7007 linux driver recently added support for the ADS DVD Xpress DX2 (which until recently was conveniently available at Walmart and other retail stores) after I took a picture of the board and asked him *very* nicely. If you get any kind of mileage out of it and decide that you really *have* to send someone money, please send it to him. (To avoid spam, check out the name of the package maintainer.)

I’m posting a copy of this as a kind of public service, since I haven’t seen any upstream releases in a while. Disclaimer that your mileage may very. I have had great luck with this, and have used it to preserve old VHS content … I would also recommend using the ffrecord tool, since it has better av sync than the included tools.

Original driver : http://oss.wischip.com/wis-go7007-linux-0.9.8.tar.bz2
Patch : http://jeff.ourexchange.net/wp-content/uploads/2007/07/wis-go7007-linux-20061021diff.gz
Site for device : www.adstech.com

Comments

Cisco VPN Client with Ubuntu Feisty

I worked out a simple patch to get the Cisco VPN client working with Ubuntu Feisty, which I’m attaching here.

Comments

No more hotlinking images

For those who use Apache 2.x, this is a nice trick to keep people from hotlinking your images. I’ve seen a few variants of it, but this one I picked up most recently from a slashdot comment, of all places.

Make sure you have enabled mod_rewrite, then add this in your .htaccess file for any directory with images in it:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain\.com [NC]
RewriteRule .* /files/goatse.jpg [NC,L]

to redirect to an awful image, or use my own personal variant:

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?sitename.com/.*$ [NC]
RewriteRule \.(gif|jpg|png)$ - [F]

which doesn’t return *anything* if someone else hotlinks your images. If they like your images enough, they can like them enough to save a copy on their own webserver.

Comments

WRT54G Multiple External IP Trick

To assign multiple external IP addresses to a WRT54G/S, you have to push a multiline variable into the rc_firewal nvram variable (non-volatile ram):


nvram set rc_firewal="
iptables -t nat -I PREROUTING -d x.y.z.1 -j DNAT --to-destination 192.168.1.x
iptables -t nat -I PREROUTING -d x.y.z.2 -j DNAT --to-destination 192.168.1.x
"
nvram commit

This will protect the changes against being lost when the router is reset.

Comments (2)

Ubuntu Dapper studio patched kernel 2.6.17

I have compiled an initial 2.6.17 kernel for Ubuntu Dapper Drake, as described on ubuntustudio.com. It has the EVMS patch needed by Ubuntu as well as the realtime patch installed. This version is not usplash patched. Files : kernel-headers-2.6.17-rt7_1_i386.deb, kernel-image-2.6.17-rt7_1_i386.deb

Comments

Wordpress 2.0.3 upgrade

I have created a wordpress “diff” which can be applied to easily upgrade Wordpress 2.0.1 to Wordpress 2.0.3 instead of going through the long and involved method on the Wordpress Codex. Use diff and a grain of salt with wordpress-patch-2.0.1-to-2.0.3.gz.

Comments

Ubuntu touchpad annoyance

After more than six months of dealing with the Synaptics touchpad driver interpreting my hand brushing against the pad as a “click”, I found a small change to xorg.conf which will take away the sting of using a touchpad with Ubuntu/Kubuntu.

Simply add the following lines in /etc/X11/xorg.conf in the InputDevice clause for the touchpad, and restart X:

Option "SHMConfig" "on"
Option "MaxTapTime" "0"

Just had to share that, it took me so long to get up the resolve to actually *look* for a solution …

Comments

Creating TTS Prompts for Asterisk with Realspeak

I was playing around with using ScanSoft Realspeak for Linux, and finally found the “magic sequence” to generate the appropriate GSM prompts for Asterisk.

    Requires:

  • Standard installation of Scansoft Realspeak 4 with American English Jill voice
  • Debian’s libgsm-tools and sox


cd /usr/local/ScanSoft/RealSpeak_4.0
echo " - TTS being performed on $1 ... "
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/ScanSoft/RealSpeak_4.0/api/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/ScanSoft/RealSpeak_4.0/speech/components/common/
./standard "American English" Jill ./speech text.txt
echo " - Converting to 8000Hz WAV ... "
sox -r 8000 -t raw -w -s /usr/local/ScanSoft/RealSpeak_4.0/standard.pcm text.wav
sox text.wav text.au
cat text.au | toast -c -s > text.gsm

Comments

Next entries »