Skip to content



A Cool Java Map builder

Build up java maps as literals with this builder

Optimizing intellij idea performance

See 10 Tips to Increase IntelliJ IDEA Performance

VIM rails plugin - switching buffers

Using the VIM rails plugin, and want to switch between the last 2 buffers in VIM?  Its Ctrl + 6. Found this in this pdf by Reza Jelveh on Rails development in Vim.

Vim project plugin : Switching between the buffer and the project pane

Ctrl+W twice switches between the project pane and the file editing buffer when using the VIM project plugin . Found this after lots of Google searching from Ariyas blog post about using the project plugin.

Setting SVN ignore on a directory recursively

Example: SVN ignore all the .swp files in the current directory and all sub-directories:

svn propset -R svn:ignore ‘*.swp’ .

Installing Oracle XE on Ubuntu

Here are a few helpful articles
http://www.markcarter.me.uk/computing/linux/oracle.htm
http://www.oracle.com/technology/tech/linux/install/xe-on-kubuntu.html

I installed Oracle XE on a Virtual Machine. I did come up with 2 issues -
1. The VM had 512Mb of RAM and oracle needed more. Had to increase the swap space. This page gives instructions on doing this on ubuntu.
2. The VM was on an internal network, and could be accessed by its IP but not its hostname. This made the post-install oracle configuration tasks to fail (found this out through oracle’s install logs). So even if Oracle XE was installed, you could neither access it through sqlplus or through its web-based admin interface. We fixed this by changing the VM’s hostname to localhost, then un-intsalling and re-installing oracle XE.

And then don’t forget to run

/etc/init.d/oracle-xe configure

after the installation!

Changing the default gVim/MacVim color scheme

To change the default color scheme to say koehler (making it look a bit like textmate), add the following to your .vimrc file

:colorscheme koehler

Save and restart your MacVim / gVim. And that should be it.

(You can easily access the .vimrc file by going to Edit>Startup settings from your menu)

Parsing CSV files with ruby FasterCSV : An example

Need to parse csv files in ruby, skipping the first row (usually some header)?. Use FasterCSV. (Yes, its faster). Install it

$ sudo gem install fastercsv

Here is one solution

#!/usr/bin/ruby -w

require 'rubygems'
require 'faster_csv'

#put everything in an array
array_of_arrays = FasterCSV.read("some_file.csv") 

# remove headers
array_of_arrays.slice!(0) 

array_of_arrays.each{|row|
  puts row
}

Another solution is

#!/usr/bin/ruby -w

require 'rubygems'
require 'faster_csv'

# setting the headers option to true or :first_row gets rid of the headers
FasterCSV.foreach('some_file.csv', :headers => :first_row) {|row|
    puts row
}

Mockito vs EasyMock - Mockito wins

I would definitely recommend Mockito over EasyMock (and ofcourse, over JMock).  I was initially hesitant of using Mockito on my project, but when I did, I found it a lot easier to use and with a lot less noise in test setup compared to EasyMock.

Using Dbdeploy with Ant, an example

Here is an example of using dbdeploy in an  ant build file:

<taskdef name="dbdeploy" classname="net.sf.dbdeploy.AntTarget"
classpathref="lib.dir"/>

<target name="build" depends="create-build-directory"
description="Compile main source tree java files">
    <echoproperties prefix="jdbc" />
    <echoproperties prefix="smn" />
    <javac destdir="${smn.build.dir}" source="1.5" target="1.5"
debug="true" deprecation="false" optimize="false" failonerror="true">
        <src path="${smn.src.dir}"/>
        <classpath refid="master-classpath"/>
    </javac>

    <dbdeploy
driver="${jdbc.driverClassName}"
url="${jdbc.url}"
userid="${jdbc.username}"
password="${jdbc.password}"
dir="${smn.base.dir}\db\deltas"
outputfile="${smn.base.dir}\db-deploy-output\all-deltas.sql"
dbms="mysql"
undoOutputfile="${smn.base.dir}\db-deploy-output\undo-all-deltas.sql"
    />
    <sql driver="${jdbc.driverClassName}" password="${jdbc.password}"
url="${jdbc.url}" userid="${jdbc.username}"
src="${smn.base.dir}\db-deploy-output\all-deltas.sql"
print="true" classpathref="lib.dir" />
</target>
  1. Note: dbdeploy does not run your change scripts, you have to run the script it outputs with an sql task
  2. If you get errors like 
    > taskdef class net.sf.dbdeploy.AntTarget cannot be found

    it means that the dbdeploy.jar is not in your classpath.