Thursday, September 27, 2012

svn: E165001: svn:eol-style related error

When we add a new file to svn and if this file type has not been configed for eol-style property, this error will returned when you try to commit.

How to fix it:

All we need to do is set eol-style property for this file type.

1) IDE: open the new added file and right click and select 'Subversion' then 'Set Property'.

2) edit your local subversion dir and edit the config file.
 cd ~/.subversion  
 open config and go to the bottom  
 add the following content (e.g. for .java file)  
 *.java = svn:eol-style=native  

Done.

Wednesday, September 26, 2012

Debugging a web application with IntelliJ IDEA

Step 1: go to your tomcat dir and run
             sh bin/catalina.sh jpda start
Step 2: find the port number tomcat is running on.
             ps aux |grep tomcat
             For me I got "address=8000"
Step 3:

 Open you project with IntelliJ IDEA, To do the following steps:
  1. Create a new Run/Debug configuration (click on the drop down list on the left of the green arrow icon) and "Edit configurations".
  2. Click on the '+' (plus) button and create a new "Maven" configuration.
  3. Give it a name.
  4. change the port number to what you get in Step 2.
  5. And you are good to go!
Step 4: just open you application normally. (not in the port number what you get in Step 2, just normal run port number.)

Wednesday, September 19, 2012

JAVA: use regex to validate date and time.

I tried to search correct regex for date and time on google and found that many of them are not working.

Finally, I found the correct one and the java methods shows below.
 /**  
  * Check that a date is formatted according to the following convention:  
  * DD/MM/YYYY OR DD.MM.YYYY OR DD-MM-YYYY  
  * @param dateStr a date string.  
  * @return true if the date text should be rejected  
  */  
  private boolean invalidDate(String dateStr) {  
  String regex = "^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\\d\\d$";  
  return !Pattern.matches(regex, dateStr);  
  }  
  /**  
  * Check that a time is formatted according to the following convention:  
  * HH:MM:SS AM/PM  
  * @param timeStr a time string.  
  * @return true if the time text should be rejected  
  */  
  private boolean invalidTime(String timeStr) {  
  String regex = "^(([0]?[1-9])|([1][0-2])):(([0-5][0-9])|([1-9])):([0-5][0-9]) [AP][M]$";  
  return !Pattern.matches(regex, timeStr);  
  }  

Friday, September 14, 2012

A very good article to explain what's the difference between "iterative vs incremental"

A very good article to explain what's the difference between  "iterative vs incremental"  (see http://gojko.net/2007/12/04/waterfall-trap/).

And plz read the comments, it gives you more practise examples and experience. 

Tuesday, September 4, 2012

subtree merge on GIT



Say merge a project A as a subtree to project B.
 git remote add -f b/a git+ssh://'git repo path'/a.git  
 git merge -s ours --no-commit b/a/master   
 git read-tree --prefix=b/a -u b/a/master   
 git commit -m "Subtree merged a"