Developer, Java Evangelist, extensively worked on Java, GWT, Flex, RIA technologies with enterprise frameworks. I have a privilege to conduct lot of Training/Coaching in Java Technologies, and to connect with real people.
Sunday, December 6, 2009
Converting String to Date in Groovy
below is the example.
In groovy, its just a one liner to make this happen
String timeStampStr = "2009-12-01T12:36:22Z"
def strDate = new Date().parse("yyyy-MM-dd'T'HH:mm:ss'Z'",timeStampStr)
println strDate.
Sunday, November 1, 2009
Flex3 Animations
Monday, September 14, 2009
Apache2.2 Proxy and Virtual Hosts
Wednesday, April 1, 2009
Securing Gitweb
This document is based on following assumtions
- Apache2 is running and installed at /etc/apache2 folder
- gitdomain.com is already present and serving gitweb files
Apache2 is run from /etc/apache2/
- Lets created passwd file in
sudo htdigest /etc/apache2/passwd/digest private user2
Note : Omit the -c flag in order to add new user information to an existing password file.
- Enable the auth-digest sudo a2enmod auth-digest
- Edit the gitdomain.com as following
ServerName gitdomain.com
DocumentRoot "/var/www/gitdomain.com/cgi-bin"
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG /etc/gitweb.conf
ScriptAlias /cgi-bin/ /var/www/gitdomain.com/cgi-bin
Options Indexes FollowSymlinks ExecCGI
AuthType Digest
AuthName "private"
AuthUserFile /etc/apache2/passwd/digest
Require valid-user
SetHandler cgi-script
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
Allow from all
# To debug rewrite rules, which were very painful to figure out
RewriteLog /var/log/apache2/rewrite_log
RewriteLogLevel 9
ErrorLog /var/log/apache2/gitweb
- sudo service apache2 restart
Suggested Reading
http://httpd.apache.org/docs/1.3/howto/auth.html
Monday, March 30, 2009
Ubuntu Admin Commands
https://help.ubuntu.com/8.04/serverguide/C/user-management.html
Adding the new created user to sudoer file
sudo useradd -d /home/admin -m admin
sudo gedit /etc/sudoersUbuntu Commands
cat /etc/issue : to check the current version of ubuntu
APT(Advance Packaging Tool) COMMANDS
apt-get update && apt-get upgrade -y (** Neeed to get the packages list and upgrade done before other apache files can be submittied)
**Some Other packaging commands which might be useful
apt-cache search https://help.ubuntu.com/8.10/add-applications/C/advanced.html
To search fro a particular keyword on all files and subdirectories use following command
Creating directories and subdirectories
mkdir -p public_html/domain1.com/{public,private,logs,cgi-bin,backup}
Check which ports are in usenetstat -ant : displays are listening ports
Thursday, March 26, 2009
Apache2 Tomcat5 Conf on Fedora
- sudo yum install httpd
- sun yum upgrade httpd
- Find the service name that is installed for apache to start it
sudo service httpd start
2. Install and start tomcat5
- sudo yum install tomcat5
- sudo yum upgrade tomcat5
- sudo /sbin/chkconfig --list | grep tomcat
- sudo service tomcat5 start
sudo/sbin chkconfig httpd on
sudo/sbin chkconfig tomcat5 on
4.
Monday, March 23, 2009
Apache2 Tomcat6 Java MySql on Ubuntu
Click here to get started with launching EC2 AMIs click here
Installing JDK6, Apache And Tomcat
++++++++++++++++++++
- apt-get update && apt-get upgrade -y
Install APACHE: sudo apt-get install apache2
Install JDK6 : sudo apt-get install sun-java6-jdk
Install Tomcat :
Test if tomcat is running
/etc/init.d/tomcat6 status
Tomcat is installed in /var/lib/tomcat6 with main files linked in /etc/tomcat6
check more about tomcat6 configuration here
Configuring Apache2 with Tomcat6
Congiruation Setup for Apache2 Virtual Host Configuration setup,by SlicetHost clicking here
At this point, I am assuming Apache2 , Java6 and Tomcat6 are installed and running fine independantly.
1. In Order to, Apache and Tomcat to talk, Mod jk connector is needed
sudo apt-get install libapache2-mod-jk
sudo a2enmod jk
2. After that, check whether there is jk.load in the apache 2 modules
sudo ls /etc/apache2/mods-enabled/
5. Edit and save the two lines of workers.properties
sudo vi /etc/libapache2-mod-jk/workers.properties
workers.tomcat_home=/usr/share/tomcat6
workers.java_home=/usr/lib/sun-java6
6. Edit and save the two lines in tomcat-users.xml
sudo vi /etc/tomcat6/tomcat-users.xml
7.
- cd /etc/apache2
- cp /usr/share/doc/libapache2-mod-jk/httpd_example_apache2.conf mods-available/jk.conf
- vi jk.conf and add the following
- JkWorkersFile /etc/libapache2-mod-jk/workers.properties
JkShmFile /var/run/apache2/jk-runtime-status
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel debug
mkdir -p /var/www/public_html/domain1.com/{public,private,logs,cgi-bin,backup}
mkdir -p /var/www/public_html/domain2.com/{public,private,logs,cgi-bin,backup}
- add some index.html files in the public directory
- create a domain1.com file in /etc/apache2/sites-available
#domain : domain1.com
#public /var/www/public_html/domain1.com/
ServerAdmin webmaster@domain1.com
ServerName domain1.com
ServerAlias www.domain1.com
#index file sand doc root
DirectoryIndex index.html
DocumentRoot /var/www/public_html/domain1.com/public
AllowOverride All allow from all Options +Indexes
#custom log file
LogLevel info
ErrorLog /var/www/public_html/domain1.com/log/error.log
CustomLog /var/www/public_html/domain1.com/public/access.log combined
- a2ensite domain1.com
- /etc/init.d/apache2 reload
- Follow the same steps for domain2.com too..
- edit the /etc/hosts file and add entries for domain1.come and domain2.com
127.0.0.1 www.domain2.com
- Open the browser and type www.domain1.com , you should see the domain1.com/public/index.html page
+++++++++++++++++++++++
/usr/share/tomcat6/lib (CATALINA_HOME) (Classes are loaded from here)
Reference Links
UBuntu's apache2 file structure is different with the addition of apache2.con, mods-available, mods-enables, sites-available, sites-enabled convention. Here is a good blog which explains this direcotry structure in details, click here
Good Article on How to Configure Apache2 with Tomcat, click here
Friday, March 20, 2009
Gitweb on EC2
- Setup EC2 with a debian image, this example is based on AMI - ami-7cfd1a15
- apt-get upgrade
- apt-get install git-core gitk gitweb
- Setup up gitosis and test the git works with a client
Also, check the gitosis documentation, click here
To setup git repository with gitosis, here are some excellent articles to get started with
http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
Sample Gitosis conf can be found at http://eagain.net/gitweb/?p=gitosis.git;a=blob;f=example.conf;hb=master
- So now gitosis is working fine and gitweb has been installed. Lets assume following values * Git trees are in /srv/git/repositories
- Lets configiure apache for virtual hosts, so that gitdomain.com gives us the gitweb
- In /var/www create following dirs mkdir -p /var/www/gitdomain.com {cgi-bin}
- In the cgi-bin directory, copy the , git-favicon.png, git-logo.png, gitweb.cgi and gitweb.css files.
- Configure the /etc/gitweb.conf file for gitweb settings
# path to git projects (
$projectroot = "/srv/git/repositories";
# directory to use for temp files
$git_temp = "/tmp";
# target of the home link on top of all pages
#$home_link = $my_uri || "/";
# html text to include at home page
$home_text = "indextext.html";
# file with project list; by default, simply scan the projectroot dir.
$projects_list = $projectroot;
# stylesheet to use
$stylesheet = "/gitweb.css";
# logo to use
$logo = "/git-logo.png";
# the 'favicon'
$favicon = "/git-favicon.png";
#Enable blame, pickaxe search, snapshop, search, and grep
# support, but still allow individual projects to turn them off.
# These are features that users can use to interact with your Git trees. They
# consume some CPU whenever a user uses them, so you can turn them off if you
# need to. Note that the 'override' option means that you can override the
# setting on a per-repository basis.
$feature{'blame'}{'default'} = [1];
$feature{'blame'}{'override'} = [1];
$feature{'pickaxe'}{'default'} = [1];
$feature{'pickaxe'}{'override'} = [1];
$feature{'snapshot'}{'default'} = [1];
$feature{'snapshot'}{'override'} = [1];
$feature{'search'}{'default'} = [1];
$feature{'grep'}{'default'} = [1];
$feature{'grep'}{'override'} = [1];
- Now lets create the virtual host setting in apache2
ServerName gitdomain.com
DocumentRoot "/var/www/gitdomain.com/cgi-bin"
DirectoryIndex gitweb.cgi
SetEnv GITWEB_CONFIG /etc/gitweb.conf
ScriptAlias /cgi-bin/ /var/www/gitdomain.com/cgi-bin
Options Indexes FollowSymlinks ExecCGI
Allow from all
AllowOverride None
Order allow,deny
SetHandler cgi-script
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /gitweb.cgi/$0 [L,PT]
2. a2ensite gitdomain.com
3. Restart apache service apache2 restart
This should get you going on gitweb, Make sure you are running apache2 from a different user and not as a root.
To tell apache to use a different user , vi /etc/apache2/envvars and add the users settings there
Reference Links
http://hokietux.net/blog/?p=58
EC2 Command line and Unix Commands reference
EC2 Commad Line API Tools
- ec2-describe-images -x all : to display all available ec2 images
- ec2-add-key mb-keypair : generates a keypair which will be instead of a root password
- ec2-run-instances ami-a9fe1bc0 -k mbkeypair starts running a EC2 Instance, this is when billing starts
- ec2-authorize default -p 22 : opens up the port 22 for ssh, similary 80 for port 80
- ec2-describe-instances : displays list of ec2 instances running
- ec2-terminate-instances ami-a9fe1bc0 : terminates a ec2 running instances. This is where billing ends
Unix Comands to Run Apache , Tomcat and Deploy war files
PUTTY Tools
Putty is a client program for SSH, Telnet and Rlogin Protocols used to run remote sessions over a network.
SSH protocol allows to remote login to a system, unlike telnet SSH encrypts the login session, making it impossible for intruders to collect clear text passwords.In short SSH, ecrypts everything it sends and recieves.
SSH-keygen
SSH is often required to login to remote systems without requiring passowrd. ssh-keygen is used to generate that key pair for you.
SSH uses public key cryptography to secure transactions and data exchange. Public key cryptography consists of a set of two keys: a public key-private key pair. A public key or a private key is a complex algorithm. The keys are:
Public key: A key that is distributed publicly to other parties and partners to access data without compromising security. It is used to decrypt data.
Private key: Used to generate messages. It is used to encrypt data. Access to the private key is possible only for authentic users who have the rights to initiate the data exchange
Grails Plugin
Screencast on Grails EC2 Plugin by Chris Richardson
A very good EC2 Presentation by Chris Richardson
Thursday, January 22, 2009
Working with Remote Branch on Git
How do I get the trial branch, here are the commands
$ git branch -a //lists all branches on remote,
$ git checkout origin/trial //to preview the remote branch
$git checkout -b trial origin/trial //to clone the remote branch
$git branch //verify the local branches
Here is a good link on Git Remote Branches