Monday, October 26, 2009

Running Synergy with Linux, XP and Mac

In the past I have used Synergy 1.3.1 with Linux (CentOS 5) and Windows (XP), this is a great solution and worked well. Now I wanted to add my Mac to the mix and found a couple of hurdles, hopefully you can avoid with this tutorial.

For my Mac I'm running Snow Leopard 10.6.1, CentOS 5 and Windows XP sp2.

So after I downloaded synergy 1.3.1 from the main site (http://synergy2.sourceforge.net/) and installed (unpacked it) onto my Mac I had to open the terminal and run it from the command line (No biggie), but still wasn't working.

Came across this site: http://stevehorbachuk.com/?p=19 which had a workaround but still no go for Snow Leopard.

After reading the comments for Steve's site someone posted this gem:ERROR: Server Refused Client Name “my-macbook”

http://sourceforge.net/projects/synergykm/

It's just a GUI tool for your already installed synergy 1.3.1 (Which you still need from the main site).

After I installed it and configured it in the System Preferences I kept getting an error: ERROR: Server Refused Client Name “my-macbook”

After checking my config file on my server (CentOS) all looked ok. Then I tried to ping my Mac from my Linux box and could not. After some searching I found I needed to add my Mac's hostname and IP to the Linux /etc/hosts file which made my Mac pingable, Yeah!!!

I started up Synergy again and Bingo! my Mac is now connected.

Thursday, October 01, 2009

MySQL IN clause gem

Well today was a good day as I found a GEM for the MySQL IN clause. Normally I would use the IN clause to search for multiple values in a field like this:


SELECT *
FROM tbl_name
WHERE field_name
IN ('value_1', 'value_2', 'value_3', 'value_x')


But today discovered that you can reverse the fields and values. So instead of using the OR clause, you could use something like this:


SELECT *
FROM tbl_name
WHERE value_x
IN ('field_name_1', 'field_name_2', 'field_name_3', 'field_name_x')


This makes it super simple to search for one value across multiple fields.

Thursday, May 07, 2009

wife breaks iPhone 3G screen, but Apple comes to the rescue (Again)

Ok so I get a call from my wife stating she has dropped her 3G iPhone and the screen is starting to crack (plastic film holding it together). Told her to take it into Apple to see what they could do. She informs me that Apple has a new screen replacement program that starts the next day (Which would be Thursday), so she makes an appointment for Saturday to get the screen replaced (Costing $150 to replace the screen as claimed by an Apple employee). She calls me to tell me the details and I ask her why are you waiting till Saturday? do it ASAP. She calls them back only to find out that Apple does NOT have a screen replacement program starting, but Apple has a heart and for misleading her they just replace the broken iPhone 3G with a new one. Amazing, just amazing :)

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 ;-)

Tuesday, February 03, 2009

Configure Aptana for CentOS 5

While moving from a Windows environment to Linux I wanted to use Aptana's free IDE for development, but was having a ton of issues getting Aptana to run correctly on Linux CentOS 5.
So here are my finding:

After I installed Aptana (install directory: /usr/share/aptana )

I keep getting errors like this:

SWT-ERROR

looking in the logs I see this:

!MESSAGE No more handles (java.lang.UnsatisfiedLinkError: /root/.Aptana/Aptana Studio/configuration/org.eclipse.osgi/bundles/72/1/.cp/libswt-mozilla-gtk-3236.so: libxpcom.so: cannot open shared object file: No such file or directory)

!STACK 0

org.eclipse.swt.SWTError: No more handles (java.lang.UnsatisfiedLinkError: /root/.Aptana/Aptana Studio/configuration/org.eclipse.osgi/bundles/72/1/.cp/libswt-mozilla-gtk-3236.so: libxpcom.so: cannot open shared object file: No such file or directory)


Well after search the forums and other sites for about an hour, people suggested I install these packages.
  • yum install gtk2-devel
  • yum install xulrunner
  • yum install libstdc*
  • yum install gtk2*
  • yum install libswt3-gtk2*
  • yum install compat-libstdc++-33
I had some already installed and I don't know if they are really required but there they are for you.

After all that it still didn't work until I came across this post. in the post it has a file you need to download called aptana.sh.

Here is the code if the file is not available:

/*************** START OF FILE **************/

#!/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/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
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


/*************** END OF FILE **************/

Still didn't work so I decided to see if the file it was trying to call existed. the command for the file name in:

locate libgtkembedmoz.so

it found it so I added the condition to the script and now it works great, YEAH!!

elif [ -e /usr/lib/esc-1.0.0/xulrunner/libgtkembedmoz.so ]; then
export MOZILLA_FIVE_HOME=/usr/lib/esc-1.0.0/xulrunner

Let me know of any other findings that might help out.

Thanks,
--Phill