Thursday, April 23, 2009

virtualbox how to adjust the screen size

I had an issue where Virtualbox would start my OS (Win XP in this case) at 800x600 screen resolution. I wanted to increase the size to fill my 22 inch monitor so under the Machine drop down I select "Fullscreen mode", but to my surprise it just centered the 800x600 with a black background to fill the rest of the area for the full screen view. Meh, this is not what I wanted! After much searching I found nothing that anyone had posted to fix the problem. Well stop searching!!!

How to fix:

Login to your VirtBox machine and change the XP display settings, Yep it's just that simple =P

Detailed how to:
1- Start VirtBox
2- Login to XP
3- Right click the desktop
4- Select Properties
5- Select the Settings tab
6- Slide the Screen resolution slider towards the More side
7- Click Apply
8- Click Yes to confirm your settings
9- Click Ok

That's it, enjoy!!!

jQuery CSV validation for user input

I'm using jQuery 1.3.2 with the jQuery Validation plugin 1.5.2 and noticed there was no validation for CSV formatted user input. After looking for a while I did find that I could extend the validation plugin with the additional-methods.js file. It's has some great added validations but still nothing for CSV. So this is to all looking for something for CSV (Comma Separated Values).

Validates for a-z A-Z 0-9

jQuery.validator.addMethod("validcsv", function(value, element) {
return this.optional(element) || /^([a-zA-Z0-9])+(,[a-zA-Z0-9]+)*$/.test(value);
}, "Must be comma separated if entering multiple values: Value1,Value2");


Validates for a-z A-Z

jQuery.validator.addMethod("validcsv", function(value, element) {
return this.optional(element) || /^([a-zA-Z])+(,[a-zA-Z]+)*$/.test(value);
}, "Must be comma separated if entering multiple values: Value1,Value2");


Validates for 0-9

jQuery.validator.addMethod("validcsv", function(value, element) {
return this.optional(element) || /^([0-9])+(,[0-9]+)*$/.test(value);
}, "Must be comma separated if entering multiple values: Value1,Value2");


Alt validation for 0-9

jQuery.validator.addMethod("validcsv", function(value, element) {
return this.optional(element) || /^([\d])+(,[\d]+)*$/.test(value);
}, "Must be comma separated if entering multiple values: Value1,Value2");


Validates for a-z A-Z 0-9 _


jQuery.validator.addMethod("validcsv", function(value, element) {
return this.optional(element) || /^([\w])+(,[\w]+)*$/.test(value);
}, "Must be comma separated if entering multiple values: Value1,Value2");


Now this will validate values for a-z upper and lower case and 0-9 numeric values that are separated by a comma. If you need to modify the Regular Expression to fit your needs please post back with your findings.

Thursday, April 16, 2009

jQuery (1.3.2) w/ Thickbox (3.1) and Java .action hack

Here goes:

While trying to incorporate jQuery Thickbox into my JSP page I encountered a problem. The problem being is that I did not want to use the iFrame call but the Ajax call but I was getting a 404 Error. After looking at the URL Ajax was calling I noticed the Ampersand symbol (&) was being passed in the URL but the .action method needs a ? to pass parms in the URL.

Looking at thickbox.js line (303 I think)

[CODE]url += "&random=" + (new Date().getTime()), function() {[/CODE]

I just replaced the & with ? and bingo.

[CODE]url += "?random=" + (new Date().getTime()), function() {[/CODE]

Just a FYI for all with headaches ;-)

Wednesday, April 15, 2009

Firefox 3.0.7 update breaks Aptana + how to fix

Okay so after much digging around I found that Aptana needs libgtkembedmoz.so to run (Aptana team please fix this, just include the file in the next build please!!!).

Work around:

Well xulrunner (the new version) doesn't include libgtkembedmoz.so file. So after much Googling I found that Thunderbird does. So I YUM install thunderbird and went to check if the file libgtkembedmoz.so was there. (BTW: thunderbird version 2.0.0.18 on CentOS 5). Yeah it's there.

So I have a script that looks for the libgtkembedmoz.so file

[SCRIPT]
#!/bin/bash

# Set path for the Mozilla SWT binding
MOZILLA_FIVE_HOME=${MOZILLA_FIVE_HOME%*/}
if false && [ -n "$MOZILLA_FIVE_HOME" -a -e $MOZILLA_FIVE_HOME/libgtkembedmoz.so ]; then
:
elif [ -e /usr/lib/mozilla/libgtkembedmoz.so ]; then
export MOZILLA_FIVE_HOME=/usr/lib/mozilla
elif [ -e /usr/lib/firefox/libgtkembedmoz.so ]; then
export MOZILLA_FIVE_HOME=/usr/lib/firefox
elif [ -e /usr/lib/xulrunner/libgtkembedmoz.so ]; then
export MOZILLA_FIVE_HOME=/usr/lib/xulrunner
elif [ -e /usr/lib/esc-1.0.0/xulrunner/libgtkembedmoz.so ]; then
export MOZILLA_FIVE_HOME=/usr/lib/esc-1.0.0/xulrunner
elif [ -e /usr/lib/mozilla-firefox/libgtkembedmoz.so ]; then
export MOZILLA_FIVE_HOME=/usr/lib/mozilla-firefox
elif [ -e /usr/lib/mozilla/libgtkembedmoz.so ]; then
export MOZILLA_FIVE_HOME=/usr/lib/mozilla
elif [ -e /usr/lib/thunderbird-2.0.0.18/libgtkembedmoz.so ]; then
export MOZILLA_FIVE_HOME=/usr/lib/thunderbird-2.0.0.18
else
$DIALOGW \
--title="Integrated browser support not working" \
--text="This Eclipse build doesn't have support for the integrated browser."
[ $? -eq 0 ] || exit 1
fi

# libraries from the mozilla choosen take precedence
LD_LIBRARY_PATH=$MOZILLA_FIVE_HOME${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}

# Do the actual launch of Aptana Studio
exec ./AptanaStudio
[/SCRIPT]

make it executable (chmod 755 scriptname) and run.

Note:

Just cjeck to make sure you have the right version of the program and/or that the path works.

[user@machine]# ls /usr/lib/thunderbird-2.0.0.18/libgtkembedmoz.so
/usr/lib/thunderbird-2.0.0.18/libgtkembedmoz.so

So if you have thunerbird 2.0.0.14 please make the change in the script as well.

Hope this help ;-)