Wednesday, May 23, 2007

Quick tip on command line short cut in OS X

How many times you’ve type “ssh www.mywebsite.com -l username -p 23423″? want to simplify that?

Here is how you can simplify your shell command:

1. go to shell, type : vi ~/.bash_profile

2. in the following vi editor window, press “a” to switch to insertion mode.

3. put in your short cut command line by line: example: alias sshmyweb=’ssh www.mywebsite.com -l username -p 23423′

4. finish and save your shortcut config by press “ESC” in vim window, then type “:wq”, press enter.

start a new shell window, type in “sshmyweb” and see the magic

this post is originated at Justin's personal blog (click here to see the original post and many others)

Tuesday, May 01, 2007

OS X Tiger Trouble Shooting Tips - /Library/preferences folder

recently my MBP (10.4.9) refuse to shutdown/reboot, and the power button which suppose to trigger the sleep/restart/shutdown command window no loner works either. The only way to restart my MBP is to press and hold the power button. I was wondering what can go wrong, repair permission does not work, clear cache etc does not work either. Searching around and not getting straight answer, then from some other users comment on solving an unrelated problem, I got my solution !

Step 1: create a new user and login as the new user to see if the same problem exists.
step 2: if the problem disappeared, the problem is likely lies in your existing user’s profile (especially ~/Library/preferences/ folder), if the problem does not disappear, try to move the main Library’s preferences folder to to somewhere else temporary (e.g. I moved /Library/preferences to my desktop), then restart to see if the problem disappear.

in my case, once I moved the main /Library/preferences, the shutdown problem is solved. Certainly if I want to , I can try to trial and error to see exactly which preference file caused the problem, but I did not bother to do that.

be aware, since preferences folder is where lots of applications saves their settings, once you moved them away, some application may loose their settings, you can then either put back the particular preference file or just re-do the settings for that application.

the same method should help to identify certain system problems which caused by corrupted preferences file etc.

enjoy . .

this post is originated at Justin's personal blog (click here to see the original post and many others)

Setup Tomcat + Eclipse Dev environment

A quick guide on how to get running:

Tomcat Setup
1) Get your preferred tomcat version from here. In this example I picked 5.x (specifically 5.5.23). Get the 2 zip files Core and Admin (only needed if you want to use the admin app)

2) Unzip these files to /usr/local (typical unix location) ,change the attrib for .sh scripts to 755 (executable) and create a symlink for tomcat so you easily can move between versions:
cd /usr/local
gunzip apache-tomcat-5.5.23.zip
gunzip apache-tomcat-5.5.23-admin.zip
ln - s /usr/local/apache-tomcat-5.5.23 /usr/local/tomcat
cd tomcat/bin
chmod 755 *.sh

For more fancy readers - you can setup a special tomcat account and change owner of the whole tomcat dir to tomcat.

3) Create a user with the admin and manager roles to the default user database in $CATALINA_HOME/conf/tomcat-users.xml - example
role rolename="manager"
role rolename="admin"
user username="admin" password="changeme" roles="admin,manager"

4) Configure tomcat admin and manager to only accept local requests (just in case you're wide open on the internet..):
$CATALINA_HOME/conf/[enginename]/[hostname]/manager.xml add this within the segment
valve classname="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1" valve

Repeat the same for
$CATALINA_HOME/conf/[enginename]/[hostname]/admin.xml

5) Setup a simple webserver access log so you can track who's on your site: In
$CATALINA_HOME/conf/server.xml add this line within the Engine default host:


6) Start tomcat using the bin/startup.sh and /bin/shutdown.sh scripts and go to http://localhost:8080/manager - provide uid/pwd as per above and you should see the manager app.

Integrating w Eclipse

Debugging simple HTTP+javascript apps using local OS X apache:

A) Install the Ajax Toolkit framework (ATF) for nice debugging of ajax apps and javascript in Firefox/Mozilla - detailed instructions on the eclipse site - summary here:
1) Download ATF build to local
2) Help -> Software Updates -> Find and Install...
3) Select Search for new features to install then Select Next then Select New Archived Site...
4) Select the location of the downloaded update site zip file then Select Finish
5) Make sure all ATF features are selected and Follow the remaining prompts to install ATF
6) restart elipse form cmdline using eclipse - clean and close. Then start normally

B) Setup eclipse to use debug apps using mozilla+apache:
1) Setup a new HTTP server resource prefs->server->installed runtimes->add HTTP - suggest you define a prefix so that all your HTML projects get deployed into a specific directory mapped somewhere in local disk

2) Edit httpd.conf to setup new document root that map the prefix to some directory on your local HD

Now debug Tomcat JSP apps:

1) Get com.sysdeo.eclipse.tomcat_3.2.1 - copy into plugin directory
2) Start Eclipse and go to Preferences-> tomcat and configure the tomcathome plugin for 5.x
3) Pref->Server->Install runtime Apache Tomcat 5.5.x
4) Create HelloWorld.jsp using New->Project->Web->DynamicWeb

Debugging:
To-DO: how to run w external tomcat/deploy WARs to have well known

Optional: Eclipse cal also start tomcat within eclipse - in this case the content root is something like ~/eclipse_workspace/.metadata/.plugins/org.eclipse.wst.server.core


more details later..