Friday, September 11, 2009

Setting Gnome to open Windows in different workspaces

Virtual workspaces are nice. That feature is implemented in almost every window manager currently and I'm used to work with them in Gnome: one workspace for code editor and other for browser, usually Firefox. On other two desktops I use to open other browsers and/or file managers.
It's very handy to use a shortcut to start both programs, so my one-liner script on desktop to start both applications is:

geany (or Aptana) | firefox

But how can I start the apps in different workspaces? The answer is simple: Devil's pie. Devilspie is a tool let's the user configure window application launchs.
Once installed, you can launch it via command line for testing. When you feel comfortable, simply add it to the window manager session startup (in Ubuntu: System -> Preferences -> Settings).
To customize an application launch, you have to create lisp-style s-expressions on custom files on ./devilspie folder. Only one expression is allowed per file. Custom S-Expression:


(if
(is (application_name) “firefox”)
(set_workspace 2))



Simple and powerful.


Last thing to remember: set_workspace do not work in metacity, use set_viewport. Metacity uses viewports instead of workspace, despite Gnome shows "workspace" label on context menus and docs.

Thursday, September 10, 2009

New application on Google App Engine

A few weeks ago, I started an experiment with the <canvas> element. That element let's javascript developers create simple 2D vector graphics on Firefox, Safari and Opera browsers. Currently is not available for IE, but there is an interesting proyect to do an abstraction layer.
One of the goals of the experiment was to replicate the behaviour of an old VGA game I'd coded 12 years ago: the player controls a character that moves across the screen, showing a nice photograph. When player reaches a percent of completeness, the level is finished and game starts on the next level.
The old VGA game used memory buffers to create the effect. canvas element doesn't use pixel buffers neither anything similar but vector graphics. Instead of pixel masks, you must indicate mask shape with commands. So, to achieve the effect, my solution was to create one mask by each horizontal line, so I could take the control of how much surface was cleaned.

var screen = [320,200]; // screen dimensions

var limit = []
// control structure of the masks

// limit assignation
for(var k = 0; k < 0; k++) {
limit[k] = [mask.min,mask.max]
}

The main drawback of this approach is that browser has to redraw each mask line on each frame, so it can be very slow on old (and a few newer) machines.

Code for this and other canvas related experiments.

The project running in its current state at the Google App Engine.

Wednesday, September 9, 2009

Setting a lightweight development enviroment

Aptana Studio was the last web development IDE I used. It's based on Eclipse, so it can be very "overbloated". Furthermore, it's not confortable to customize it sometimes.
For that reasons, I changed my development enviroment recently. My new tools:
  • Geany. Lightweight text-editor with many useful plugins. Cross-platform.
  • NautilusSVN. Nice set of SVN (version control) scripts for Nautilus, Gnome navigator. It tries to mimetize TortoiseSVN for Windows.
  • Meld. Diff utility. Complements SVN functions with a nice file differences display. 
  • and Firefox.
Also I use different virtual desktops for each application. I lose javascript code completion, but I'm yet used to work without it!


Monday, September 7, 2009

Firebug issues on POST forms submit

I really like FireBug. I think it's the best tool for web deveploment in years and it's and amazing contribution to open source code and development. But sometimes it does some really tricky, odd things.

Recently I'd serialized a form with jQuery :

var params = $("commentForm").serialize(); // get a string with form parameters

then I use it in a generic ajax call:

$.ajax(
   method: "POST",
   params: params,
   ....
);

Too normal until debugging the result of the query in Firebug. The server's answer contains the params of the form:

Array(

   id:4893
)

But firebug window shows:

Array(
   id:0
)

Different results. Why? Firebug does not capture Firefox query. Instead of that, it replies the query without the parameters. So it can show wrong results to developers who are debugging their ajax posts.
I have noticed that behavior in Linux and formerly in Windows with different versions of Firebug, so don't trust it!