Mac Detail:
banl09d5acb54:clerk vsrinivasan$ uname -a
Darwin banl09d5acb54.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
MySQL:
Install mysql-5.5.10-osx10.6-x86_64.dmg
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -v 2.7 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Other Gems:
actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
daemons (1.1.0)
linecache (0.43)
mocha (0.9.12)
mysql (2.7)
rack (1.0.1)
rails (2.3.5)
rake (0.8.3)
rcov (0.9.9)
rmagick (2.13.1)
ruby-debug-base (0.10.5.jb2)
ruby-debug-ide (0.4.17.beta3)
rubygems-update (1.3.6)
stomp (1.1.6)
will_paginate (2.3.15)
Thursday, April 07, 2011
Uninstall MySQL from Mac
Step1:
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
Step2:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm /etc/my.cnf
sudo rm -rf /var/db/receipts/com.mysql.mysql*
edit /etc/hostconfig and remove the line MYSQLCOM=-YES-
Step2:
sudo rm /usr/local/mysql
sudo rm -rf /usr/local/mysql*
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm /etc/my.cnf
sudo rm -rf /var/db/receipts/com.mysql.mysql*
Friday, March 11, 2011
விமர்சிக்கும் உலகம் இது!!!
பட்டினத்தார் எத்தனை பெரிய துறவி? கோடிக்கணக்கான சொத்தை அப்படியே விட்டுவிட்டுக் கோவணத்துடன் வெளியேறிய கடுந்துறவி. சோற்றாசை கூட இல்லாத சந்யாஸி.கையில் ஓடு வைத்திருந்த பத்திரிகிரியாரைத் சொத்து வைத்திருக்கும் குடும்பஸ்தன் என்று கிண்டலடித்த அப்பழுக்கற்ற துறவி. அவரையே உலகம் என்ன பாடுபடுத்தியது தெரியுமா?
நடந்த களைப்பால் வயலில் படுத்திருந்தார் பட்டினத்தார். அறுவடை நடந்திருந்த வயல் அது. குச்சி குச்சியாய்ப் பூமியில் இருந்து கிளம்பி அறுபடாதிருந்த வைக்கோல் அவர் உடம்பில் குத்திக் கொண்டிருந்தது. அதைச் சட்டை செய்யாமல் (சட்டை இல்லாமல்) படுத்துக் கிடந்தார். இருக்கும் போதே இறந்து போன மாதிரி இருந்தார்.
அந்த வழியாகப் போன இரண்டு பெண்கள் வரப்பு வழியாக நடந்து போக முடியாதபடி பட்டினத்தார் வரப்பு மீது தலைவைத்துப் படுத்திருந்தார். ஒரு பெண்மணி, “யாரோ மகானா!” என்று அவரை வணங்கி வரப்பிலிருந்து இறங்கி நடந்தார். மற்றொரு பெண்மணியோ, “ஆமாம்… ஆமாம்… இவரு பெரிய சாமியாராக்கும்… தலையணை வைச்சுத் தூங்கறான் பாரு… ஆசை பிடிச்சவன்” என்று கடுஞ்சொல் வீசினார்.
அவர்கள் அங்கிருந்து போனதும் எழுந்து உட்கார்ந்த பட்டினத்தார், “ஆஹா… நமக்கு இந்த அறிவு இது நாள் வரை இல்லையே” என்று வருந்தி வரப்பிலிருந்து தலையைக் கீழே வைத்துப் படுத்தார்.
சற்று நேரத்தில் அந்த இரண்டு பெண்களும் அதே வழியாகத் திரும்பி வந்தனர். வரப்பிலிருந்து தலையை இறக்கிக் கீழே வைத்திருந்த பட்டினத்தாரைப் பார்த்து முதல் பெண் பரிதாபப்பட்டு, “பார்த்தாயா… நீ சொன்னதைக் கேட்டு உடனே கீழே இறங்கிப் படுத்துட்டாரூ… இப்பவாவது ஒத்துக்கோ… இவரு மகான்தானே…! என்றார். அந்த பெண்மணியோ, தனக்கே உரித்த பாணியில் “அடி போடி… இவனெல்லாம் ஒரு சாமியாரா?
தன்னைப் பத்தி யார் யாரு என்ன என்ன பேசுறாங்கன்னு ஒட்டுக் கேட்கிறான்… அதைப் பத்திக் கவலைப்படறான். இவனெல்லாம் ஒரு சாமியாரா?” என்று ஒரு வெட்டு வெட்டினாள். பட்டினத்தாருக்குத் தலை சுற்றியது.
எப்படி இருந்தாலும் உலகம் நம்மை விமர்சிக்கும். இது பேருண்மை. தரமானவர்களின் தரமான விமர்சனத்தை மதிக்க வேண்டும். விமர்சிக்க வேண்டும் என்கிற வெறியுடன் விமர்சிக்கிறவர்கள் விமர்சனத்தைப் புறக்கணியுங்கள்!!!
நடந்த களைப்பால் வயலில் படுத்திருந்தார் பட்டினத்தார். அறுவடை நடந்திருந்த வயல் அது. குச்சி குச்சியாய்ப் பூமியில் இருந்து கிளம்பி அறுபடாதிருந்த வைக்கோல் அவர் உடம்பில் குத்திக் கொண்டிருந்தது. அதைச் சட்டை செய்யாமல் (சட்டை இல்லாமல்) படுத்துக் கிடந்தார். இருக்கும் போதே இறந்து போன மாதிரி இருந்தார்.
அந்த வழியாகப் போன இரண்டு பெண்கள் வரப்பு வழியாக நடந்து போக முடியாதபடி பட்டினத்தார் வரப்பு மீது தலைவைத்துப் படுத்திருந்தார். ஒரு பெண்மணி, “யாரோ மகானா!” என்று அவரை வணங்கி வரப்பிலிருந்து இறங்கி நடந்தார். மற்றொரு பெண்மணியோ, “ஆமாம்… ஆமாம்… இவரு பெரிய சாமியாராக்கும்… தலையணை வைச்சுத் தூங்கறான் பாரு… ஆசை பிடிச்சவன்” என்று கடுஞ்சொல் வீசினார்.
அவர்கள் அங்கிருந்து போனதும் எழுந்து உட்கார்ந்த பட்டினத்தார், “ஆஹா… நமக்கு இந்த அறிவு இது நாள் வரை இல்லையே” என்று வருந்தி வரப்பிலிருந்து தலையைக் கீழே வைத்துப் படுத்தார்.
சற்று நேரத்தில் அந்த இரண்டு பெண்களும் அதே வழியாகத் திரும்பி வந்தனர். வரப்பிலிருந்து தலையை இறக்கிக் கீழே வைத்திருந்த பட்டினத்தாரைப் பார்த்து முதல் பெண் பரிதாபப்பட்டு, “பார்த்தாயா… நீ சொன்னதைக் கேட்டு உடனே கீழே இறங்கிப் படுத்துட்டாரூ… இப்பவாவது ஒத்துக்கோ… இவரு மகான்தானே…! என்றார். அந்த பெண்மணியோ, தனக்கே உரித்த பாணியில் “அடி போடி… இவனெல்லாம் ஒரு சாமியாரா?
தன்னைப் பத்தி யார் யாரு என்ன என்ன பேசுறாங்கன்னு ஒட்டுக் கேட்கிறான்… அதைப் பத்திக் கவலைப்படறான். இவனெல்லாம் ஒரு சாமியாரா?” என்று ஒரு வெட்டு வெட்டினாள். பட்டினத்தாருக்குத் தலை சுற்றியது.
எப்படி இருந்தாலும் உலகம் நம்மை விமர்சிக்கும். இது பேருண்மை. தரமானவர்களின் தரமான விமர்சனத்தை மதிக்க வேண்டும். விமர்சிக்க வேண்டும் என்கிற வெறியுடன் விமர்சிக்கிறவர்கள் விமர்சனத்தைப் புறக்கணியுங்கள்!!!
Thursday, March 10, 2011
Access Application Context from JSP
<%
ApplicationContext context =
WebApplicationContextUtils.getWebApplicationContext(
pageContext.getServletContext());
MyBean myBean=(MyBean)context.getBean("myBeanId");
%>
Windows: Rails with MySQL Problem
After successfully installing the Ruby 1.8.7 and Rails 2.3.5, MySQL 2.8.1 x86-mingw32 gems
When we try to create a db using the following command
>> rake db:create
It throws the following error:
!!! The bundled mysql.rb driver has been removed from Rails 2.2.
Please install the mysql gem and try again: gem install mysql.
rake aborted!
126: The specified module could not be found.
- */1.8/gems/mysql-2.8.1-x86-mingw32/lib/1.8/mysql_api.so
(See full trace by running task with --trace)
Process finished with exit code 1
To solve that we need keep the libmySQL.dll file under RUBY_HOME/bin
When we try to create a db using the following command
>> rake db:create
It throws the following error:
!!! The bundled mysql.rb driver has been removed from Rails 2.2.
Please install the mysql gem and try again: gem install mysql.
rake aborted!
126: The specified module could not be found.
- */1.8/gems/mysql-2.8.1-x86-mingw32/lib/1.8/mysql_api.so
(See full trace by running task with --trace)
Process finished with exit code 1
To solve that we need keep the libmySQL.dll file under RUBY_HOME/bin
Tuesday, December 21, 2010
Install Apache Http Sever using yum
> yum install httpd
> service httpd start
> service httpd start
Install mysql using yum
Install MySQL Sever & Dev Tools
> sudo yum install mysql
> sudo yum install mysql-server
> sudo yum install mysql-devel
> sudo /sbin/service mysqld start
To change root password:
/usr/bin/mysqladmin -u root password 'mysql'
Optional Steps:
> chgrp -R mysql /var/lib/mysql
> chmod -R 770 /var/lib/mysql
> sudo yum install mysql
> sudo yum install mysql-server
> sudo yum install mysql-devel
> sudo /sbin/service mysqld start
To change root password:
/usr/bin/mysqladmin -u root password 'mysql'
Optional Steps:
> chgrp -R mysql /var/lib/mysql
> chmod -R 770 /var/lib/mysql
Thursday, November 25, 2010
Wednesday, November 24, 2010
When is a Singleton not a Singleton?
Yesterday happen to read this post, very nice one http://java.sun.com/developer/technicalArticles/Programming/singletons/
Wednesday, November 03, 2010
Use of static inner classes
We have HashMap.Entry class that is declared as a static inner class, I was searching for why it has been declared as static inner class and I found this post, which talks about when to use what type of inner classes.
In Short,
- Convenient way of grouping classes without using packages
- To create an instance of this class, we don't need outer class's object
- It will help you to extend from some other class
java.util.HashMap.Entry
- java.util.LinkedHashMap.Entry
- java.util.HashMap.EntrySet
- java.util.HashMap.HashIterator
- java.util.LinkedHashMap
Wednesday, September 22, 2010
Fast way to multiply a number by 7
/**
* @author Vijayan Srinivasan
* @since Sep 22, 2010 3:47:15 PM
*/
public class MulBy7 {
public static void main(String[] args) {
for(int i=0;i<10;i++){
System.out.print("i="+i+",");
int value=(i<<3)-i;
System.out.println("i*7="+value);
}
}
}
Output:
i=0,i*7=0
i=1,i*7=7
i=2,i*7=14
i=3,i*7=21
i=4,i*7=28
i=5,i*7=35
i=6,i*7=42
i=7,i*7=49
i=8,i*7=56
i=9,i*7=63
Tuesday, August 31, 2010
Comparison of different SQL implementations
Most of the time when we port application from one database to other we look for equivalent command in other database. Here is a site that provides a comprehensive list of different sql implementations. more info at http://troels.arvin.dk/db/rdbms/
Wednesday, June 30, 2010
எளிமையாய் சொன்னேன்
என் பிறந்தநாள் வாழ்த்தே
முதன்முதலாய் இருக்க
முந்தியநாள் நள்ளிரவே
வாழ்த்து சொல்லியிருக்கிறேன்
தொலைபேசியில்...
உன் விழிகள் என்னையே
முதன்முதலாய் சந்திக்க
அதிகாலை ஐந்து மணிக்கே
உன் விடுதி வாயிலில் நின்றிருக்கிறேன்
வாழ்த்து அட்டைகளுடன்...
உன் பிறந்தநாளின்
முதல் மின்னஞ்சல்
என் கவிதையாய் இருக்க
மென்பொருளொன்று செய்திருக்கிறேன்
ஆயிரம் கவிதைகளுடன்...
இதுவரை இப்படித்தான்
உன்னை ஆச்சரியமூட்டியிருகிறேன்
என் வாழ்த்துகளால்...
இன்று உன் பிறந்தநாள்
இது என் மனைவியாக
உனக்கு முதல் பிறந்தநாள்...
எப்படி சொல்வது
என் வாழ்த்துகளை
இதுவரை இல்லாத வகையில்?
என்று எண்ணி எண்ணி
ஏதும் கிடைக்காமல்
எளிமையாய் சொன்னேன்
"இனிய பிறந்தநாள் வாழ்த்துக்கள்..."
வாழ்த்துக்களுடன்
விஜயன் சீனிவாசன்
Thursday, April 15, 2010
Check what all ports running
If you know the port at which that service runs then issue the following command
[vijayan@boarddown-dr ~]$ netstat -an | grep LISTEN | grep 80
tcp 0 0 0.0.0.0:807 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN
tcp 0 0 :::80 :::* LISTEN
To know which process id owns this port
[vijayan@boarddown-dr ~]$ sudo /sbin/fuser 80/tcp
80/tcp: 25529 25530 25531 25532 25533 25534 28522
To know which executable/script runs on that process id
[vijayan@boarddown-dr ~]$ ps -lfwwwwwp 25529
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
5 S root 25529 1 0 75 0 - 953 - Feb17 ? 00:00:00 /home/vijayan/dev/Apache2/bin/httpd -k start
[vijayan@boarddown-dr ~]$ netstat -an | grep LISTEN | grep 80
tcp 0 0 0.0.0.0:807 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5801 0.0.0.0:* LISTEN
tcp 0 0 :::80 :::* LISTEN
To know which process id owns this port
[vijayan@boarddown-dr ~]$ sudo /sbin/fuser 80/tcp
80/tcp: 25529 25530 25531 25532 25533 25534 28522
To know which executable/script runs on that process id
[vijayan@boarddown-dr ~]$ ps -lfwwwwwp 25529
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
5 S root 25529 1 0 75 0 - 953 - Feb17 ? 00:00:00 /home/vijayan/dev/Apache2/bin/httpd -k start
Thursday, February 04, 2010
Get Password without displaying it on console
JDK 1.6 provides option to get secret inputs without displaying them on console. Here is the code sample to do that.
System.console().readPassword("[%s]", "Password:");
Tuesday, February 02, 2010
Online Free Flex based Building Plan Software
If anyone of you thinking to build a new home and looking for a software that can help you model your home. Here is the link you can use this for free.
http://dragonfly.autodesk.com/
http://dragonfly.autodesk.com/
Thursday, January 28, 2010
Specifying default schema name in JPA
Often we use different user name to connect to oracle database instead of the using the same user name with schema name. In that case queries needs to be prefixed with schema names. to do that in JPA we can add the following property in persistence.xml file
com.foo.bar.Test
Tuesday, January 19, 2010
Access Oracle Blob and Timestamp Columns
Many of the time we use Blob and Timestamps column in Oracle. When we access them using JDBC, we will get Oracle specific Java objects when result set is returned from DB. e.g oracle.sql.BLOB, oracle.sql.TIMESTAMP but we may need them in the form of java.sql.Blob and java.sql.Timestamp
To get it in right way we need add the following start-up properties
-Doracle.jdbc.J2EE13Compliant=true
To get it in right way we need add the following start-up properties
-Doracle.jdbc.J2EE13Compliant=true
Saturday, October 03, 2009
Ways by which singleton can be created
Singleton classes can be created in 3 ways
Case 1:
In this case the statically created object is made final and publicly exposed to everyone.
Case 2:
Case 3:
In this third case is preferable because it creates the object on-demand. But it can create issue when it is used in multi threaded environment.
So the code can be changed to case 4
Case 4:
Though it takes care multi threaded this will become a costly method. to make it a light-weight we can change the code to case 5
Case 5:
This method is an efficient but complex one, this is also called as double-null checking method. more info on this can be found in http://en.wikipedia.org/wiki/Double-checked_locking
Output:
org.vijayan.sample.Singleton@10b62c9
org.vijayan.sample.Singleton@10b62c9
org.vijayan.sample.Singleton@10b62c9
org.vijayan.sample.Singleton@10b62c9
Please note all 4 times it returns the same object reference.
Case 1:
package org.vijayan.sample;
public class Singleton {
/**
* Advanced Initialization
*/
public static final Singleton SINGLETON=new Singleton();
private Singleton(){
}
public static void main(String[] args) {
for(int i=0;i<4;i++){
System.out.println(Singleton.SINGLETON);
}
}
}
In this case the statically created object is made final and publicly exposed to everyone.
Case 2:
package org.vijayan.sample;
public class Singleton {
/**
* Advanced Initialization
*/
private static Singleton singleton=new Singleton();
private Singleton(){
}
public static Singleton getInstance(){
return singleton;
}
public static void main(String[] args) {
for(int i=0;i<4;i++){
System.out.println(Singleton.getInstance());
}
}
}
Case 3:
package org.vijayan.sample;
public class Singleton {
/**
* Lazy Initialization
*/
private static Singleton singleton=null;
private Singleton(){
}
public static Singleton getInstance(){
if(singleton==null){
singleton=new Singleton();
}
return singleton;
}
public static void main(String[] args) {
for(int i=0;i<4;i++){
System.out.println(Singleton.getInstance());
}
}
}
In this third case is preferable because it creates the object on-demand. But it can create issue when it is used in multi threaded environment.
So the code can be changed to case 4
Case 4:
package org.vijayan.sample;
public class Singleton {
/**
* Lazy Initialization
*/
private static Singleton singleton=null;
private Singleton(){
}
/**
*
* Will take care multi threaded environment but it expensive
*/
public static synchronized Singleton getInstance(){
if(singleton==null){
singleton=new Singleton();
}
return singleton;
}
public static void main(String[] args) {
for(int i=0;i<4;i++){
System.out.println(Singleton.getInstance());
}
}
}
Though it takes care multi threaded this will become a costly method. to make it a light-weight we can change the code to case 5
Case 5:
package org.vijayan.sample;
public class Singleton {
/**
* Lazy Initialization
*/
private static Singleton singleton=null;
private Singleton(){
}
/**
*
* Will take care multithreaded environment also less expensive
*/
public static Singleton getInstance(){
if(singleton==null){
synchronized (Singleton.class) {
if(singleton==null){
singleton=new Singleton();
}
}
}
return singleton;
}
public static void main(String[] args) {
for(int i=0;i<4;i++){
System.out.println(Singleton.getInstance());
}
}
}
This method is an efficient but complex one, this is also called as double-null checking method. more info on this can be found in http://en.wikipedia.org/wiki/Double-checked_locking
Output:
org.vijayan.sample.Singleton@10b62c9
org.vijayan.sample.Singleton@10b62c9
org.vijayan.sample.Singleton@10b62c9
org.vijayan.sample.Singleton@10b62c9
Please note all 4 times it returns the same object reference.
Synchronization usecases
Consider a class called A, it has m1() and m2() methods, 2 instance of this A class is created a1 and a2 and there are 2 threads t1, t2
Case 1: m1() and m2() are not synchronized
t1 uses a1 and calls m1()
t2 uses a2 and calls m2()
both thread t1 and t2 can run at the same time because both threads are using different objects.
Case 2: m1() and m2() are synchronized
t1 uses a1 and calls m1()
t2 uses a2 and calls m2()
both thread t1 and t2 can run at the same time because both threads are using different objects.
by default synchronization will acquire lock on the object, since here both are using different object locking will not happen.
Case 3: m1() and m2() are synchronized
t1 uses a1 and calls m1()
t2 uses a1 and calls m2()
both thread t1 and t2 cannot run at the same time because both threads are using same object.
if t1 first access m1() then t2 will have to wait for t1 to complete running m1()
Case 4: m1() is static and m2() is non static and both are synchronized
t1 uses a1 and calls m1()
t2 uses a1 and calls m2()
both thread t1 and t2 can run at the same time because though both threads are using same object when t1 first access m1() it is not accessing via a1 object rather it will use A class for accessing the static method that is A.m1() is what called. For doing the same A.Class object will be created and it will be synchronized using A.Class object and t2 will be using a1 object for locking since both objects are different they can work parallel.
Case 5: m1() is static and m2() is static and both are synchronized
t1 uses a1 and calls m1()
t2 uses a1 and calls m2()
both thread t1 and t2 cannot run at the same time because though both threads are using same object (A.Class object)
Subscribe to:
Posts (Atom)