Archives for June 2009

Introducting TweetGames

I like to think of TweetGames as a way to interact with Twitter without tweeting every game action to the world. And a way to scratch an itch. The first game is a simple wordsearch generated from Twitter Trends for that given hour. I'll be eventually releasing more to play around with experimental ways of consuming Twitter data.

TweetGames uses Grails on top of the Google App Engine and a front-end using the 2D graphics library Pulpcore. One of the more interesting things other than the stretching your brain has to do to not rely on a RDBMS crutch is how efficient the Groovy syntactic sugar closures are. While I was trying to get key requests under the 30 second limit, I found that replacing some for-loops with find,findAll,or collect closures cut between .718 and 1.3secs from the request runtimes.

Check it out at http://tweetgames.appspot.com or on Facebook at http://bit.ly/tweetgames_facebook

Adding Growl notifications to Griffon applications

One of the things I am reminded of when WWDC rolls around, other than Silicon Valley's crush on all things Apple, is the extra little bit of polish in OS X applications. Part of that polish is the Growl notification system and adding Growl notifications is one way to make your applications feel more native. It exists in some shape or form on all three major platforms. I'll be demonstrating how to integrate Growl in a Mac or Linux Griffon application, Windows will have to wait until I have the time to unify targeting the three in a plugin.

Firstly, Make sure you have growlnotify(OS X) or libnotify-bin(Ubuntu) installed.

Next, add the following script to your src directory of your app:

 
public class Notifier {
	final static String OS_NAME = System.getProperty("os.name")
	
	static void sendNotification(title, msg, icon) {
		try{
		if (OS_NAME.equals("Linux")) {
			def cmd = "notify-send ${title} ${message} -i ${icon}"
			cmd.execute()
		} else if (OS_NAME.equals("OSX")) {
			def cmd = "growlnotify -n ${title} -I ${icon} -m ${message}"
			cmd.execute()
		}
		} catch (IOException ex) {
			// very possible that the required package (libnotify-bin on Linux or growlnotify on OS X) is not installed
		}
	}
}

Now you can call your Notifier from your controller just like any other class. Calling the command-line versions directly is a bit messy but it is probably what the Java libs are doing anyways.

In a plugin, possibly a hook could be added to installer scripts to ask if the user would like to receive growl-like notifications and then install the requisite packages.

What else do you think a growl plugin should do? Comment on this post or better yet on user@griffon.codehaus.org

For those that are curious, there is Growl for Windows.

Thanks to  Colin Harrington and Marc Palmer for the inspiration.