Monday, July 13, 2009

Setting the 'Show Desktop' keyboard shortcut in Ubuntu

Having just moved from a Windows environment to Linux, I have been trying to find my way around Ubuntu 9. Everytime I have something that I want to do in the OS, I have used the Windows way of doing it, without any success :p

For those of you trying to set up your Linux OS to 'Show Desktop' when the Windows + D key is pressed, this is what I found out on how to do it:
1. Go to System -> Preferences -> Keyboard Shortcuts

2. By default, Ubuntu responds to Ctrl-Alt-D to 'Show Desktop'. You can change this to Windows + D by firstly pressing the Windows key (or called Super in Linux which I havent quite figured out why), then simultaneously clicking on the keyboard shortcut for the "Hide all normal windows and set focus to the desktop background" option and hitting the 'D' key.

This will map a Windows-D keypress to 'Show Desktop'!

Friday, May 22, 2009

Firefox Sucking Up Your Memory?

THis is a good article to read on how to tune your Firefox: http://stayupdate.com/tips-tricks/increase-firefox-speed-and-decrease-firefox-memory-usage-20-tips/567

Wednesday, May 20, 2009

Divide 0 by 0

Here's a simple algo to divide 0.0 by 0.0:

double a = 0.0 / 0.0;
double b = 1.0 / 0.0;
double c = 0.0 / 1.0;
double d = 1.0 / 1.0;
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);

Here are the results:

NaN
Infinity
0.0
1.0


Good reference: http://www.math.utah.edu/~pa/math/0by0.html

Monday, May 4, 2009

Getting the rendered height of a html body tag

I came across this problem the other day.

I have a html page with a couple of divs in the body tag. My divs had lengthy text and images. Hence, when I made the border of page visible (by setting the border style of the body tag), the border encaptulated all the divs and was visible when i scrolled down.

When I then included a div that had a background image that I wanted to repeat vertically, this image only got repeated to the height of my screen (i.e. when I scrolled to the bottom of the page, I could see that the image did not get rendered all the way to the bottom). I used height = 100% for the style of this div.

After poking around, I realised that the height=100% means that the div (containing the vertical image) only had a height that was equivalent to the height of the visible screen. To get the FULL height of the body, I had to use this function, called from the body's onLoad event:

function borderheight()
{
var leftborder = parent.document.getElementById('leftborder');
leftborder.style.height = document.body.clientHeight + "px";

var rightborder = parent.document.getElementById('rightborder');
rightborder.style.height = document.body.clientHeight + "px";
}


Hope using clientHeight helps all of you who come across this problem.

GWT-EXT error: com.google.gwt.core.client.JavaScriptException: (TypeError): '$wnd.Ext.StatusBar' is null or not an object

The reason why you are getting this error is most probably because you have not installed ext and included the ext.jar file in your build path. Hence, you have a ext wrapper classes (eg. Gwt-Ext) but not EXT itself.

First of all, download EXT 2.0.2 from http://yogurtearl.com/ext-2.0.2.zip (link can be seen in http://code.google.com/p/gwt-ext/)

Then, add the ext-base.js, ext-all.js and ext-core.js files into the public folder of you GWT project. (eg. in com.redflex.gwt.public.js)

Then, define these in your project's html file:
< !--include the Ext CSS-- >
< link rel="stylesheet" type="text/css" href="js/ext/ext-all.css" / >

< !--include the Ext Core API-- >
< script type="text/javascript" src="js/ext/adapter/ext/ext-base.js" >< / script >


< !--include Ext -- >
< script type="text/javascript" src="js/ext/ext-all.js" > < / script >


This provides access to Ext's Javascript functions which resolves the " '$wnd.Ext.StatusBar' is null or not an object" error.


Make sure your paths to the ext-base.js, ext-all.js and ext-core.js files are correct into you < script > tags.

You can also copy all the other css files in the resources folder of Ext 2.0.2. This will allow your widgets to look like the ones shown in http://code.google.com/p/gwt-ext/

GWT-EXT Error: Scanning source for uses of the deprecated gwt.typeArgs javadoc annotation; please use Java parameterized types instead

So I downloaded GWT-EXT 2.0.6 and placed it in my Eclipse project's build path. Then I wrote some simple code:
MapPanel osm = new OpenStreetMap();

Then i placed this in my project's the gwt.xml file



When I ran this code in hosted mode, I got this error:

[DEBUG] Scanning source for uses of the deprecated gwt.typeArgs javadoc annotation; please use Java parameterized types instead
[DEBUG] Type com.gwtext.client.data.NodeModel
[TRACE] Field attributesAllowed
[WARN] Deprecated use of gwt.typeArgs for field attributesAllowed; Please use java.util.ArrayList as the field's type
[TRACE] Field children
[WARN] Deprecated use of gwt.typeArgs for field children; Please use java.util.ArrayList as the field's type
[TRACE] Field properties
[WARN] Deprecated use of gwt.typeArgs for field properties; Please use java.util.HashMap as the field's type

I have GWT 1.5.3.

I scanned forums which all said that the reason for this is because GWT 1.5 uses generics rather than the @gwt.typeArgs annotation. (eg: http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/74037cd1bc9c85d0)

However, I did not use any annotations. Hence, this did not resolve my problem.

I then found out that this was a bug and it was fixed here:
http://code.google.com/p/gwt-ext/issues/detail?id=464

Download the jar file in the above URL. Use that jar file instead. You won't get the error anymore.

Version of Ext in use not compatible with GWT-Ext.

When I ran my GWT application in hosted mode, I kept getting the following error:

Version of Ext in use not compatible with GWT-Ext.
GWT-Ext only supports Ext v.2.0.2.


I was already using EXT 2.0.2 (from http://yogurtearl.com/ext-2.0.2.zip) on GWT-EXT 2.0.6 (http://gwt-ext.com/download/) and I put the ext-all.css, ext-all.js and ext-base.js files into a local js folder so that my html file could access them using this:

< ! --include the Ext CSS -- >
< link rel="stylesheet" type="text/css" href="js/ext/ext-all.css"/ >

< !--include the Ext Core API-- >
< script type="text/javascript" src="js/ext/adapter/ext/ext-base.js" >< / script >


< !--include Ext -- >
< script type="text/javascript" src="js/ext/ext-all.js" >< / script >


The way I solved this was to clear my IE browser cache. In Windows, the hosted mode uses IE.