How to upgrade SVN on a mac

Mac OS X 10.5 comes with an outdated svn version, I think it’s 1.4. For work, I need to update this to 1.6.

To check the current version, open the terminal and type:

svn -help

The version number is located on the first line.

To upgrade, download a binary package from: http://subversion.tigris.org/getting.html#osx

Then add this to .profile or .bash_profile:

vi ~/.profile

export PATH=/usr/local/bin:$PATH

Try to check for the version again. If it still uses the same version, try source command

source .profile

Advertisements

Removing ^M at the end of every lines in Vi/Vim

This can be done by running:

:%s/^M//g

This the key to press in order:

:+%+s+/+(ctrl+v)+(ctrl+m)+/+/+g+enter

SVN Repository View in Eclipse

This is a way to browse SVN Repository in eclipse.

To open the SVN Repository View, go to Windows> Open Perspective > Others > SVN Repository Exploring

Rewrite url for webapp, similar to htaccess

Webapp doesn’t seem to support htaccess file. Therefore, url rewrite can be done by using UrlRewriteFilter. It can be downloaded from: http://tuckey.org/urlrewrite/

This package is very easy to install:

1. Download the package

2. Put the library in to lib folder under WEB-INF or add as dependencies through maven

3. Put the filter to web.xml in WEB-INF

<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

4. Copy and Edit urlrewrite.xml to create the rule.

I used this UrlRewriteFilter to take the trailing slashes off the url

For example:

From http://abc.def/ghi/jkl

To http://abc.def/ghi/jkl

What I did was:

1. Tell UrlRewrite to use context path

<urlrewrite use-context=”true”>

2. Add this rule

<rule>
<from>^(.+)/(.+)/$</from>
<to type=”redirect”>$1/$2</to>
</rule>

This may not be a perfect solution but it works 🙂

Get current timestamp with mckoi

Today I have been playing around with mckoi database. In MySQL, there’s a NOW() function. This function simply returns the current timestamp. However, mckoi doesn’t have this function but I need it! This is what I did to get the current timestamp:

SELECT DATEFORMAT(DATEOB(), ‘yyyy-mm-dd HH:mm:ss’)

Just to be a little bit more paranoid, I set this function as a default value for my timestamp column, when I created a database. This is the syntax that I’m using:

CREATE TABLE myTable (

myTimestampColumn timestamp DEFAULT DATEFORMAT(DATEOB(), ‘yyyy-mm-dd HH:mm:ss’) not null
)

This is very helpful because during insertion, there’s no need to put an extra effort to manage myTimestampColumn. Everything is done automatically.

Include javascript in an external js file

This is how to include a script into an external javascript file. This is also similar to PHP include() statement.

document.write(“<script type=’text/javascript’ src=’JAVASCRIPT_URL_JS’></script>”);

Link to go back to the root of webapp in jsp

I have been thinking about the code to simply go back to the root of the webapp.

For example: URL/myapp

The solution is really easy:

<a href=”.”>Return To Home Page</a>