The power of ack

ack homepage

This is a super useful tool for searching through all of your source code. It searches recursively by default, ignores revision control directories, and aggregates/presents the search results in a very readable format. Makes software development just that much easier.

Here’s a quick example:

$ ack -C 5 –java “ProductVersioner” /usr/local/src/apache-oodt/asf-latest/trunk

“search for all code written in Java recursively under the specified directory and provide 5 lines of context… all the while ignoring all .svn, .cvs, and other irrelevant directories”



Avoiding the terminal error: xterm-color: Unknown terminal type

Using a Mac terminal to connect to a machine not supporting the xterm-color terminal type can result in tools like vi not working.

One can get the error: xterm-color: Unknown terminal type

The solution to this problem is to identify the terminal types supported on the remote machine.

In my case, it was vt100

Steps (on remote machine running Solaris):

> export TERM=vt100

> vi anyfile.txt


Packaging a jar with all dependencies using maven

To package a jar, containing all dependency class files, it is quite easy:

In your pom.xml, within the plugins section, add the following:


Call: mvn package, this will produce two jars, one with dependencies and one without.

Apache Solr – indexing text files

The problem?

Reading and following the Apache Solr documentation I didn’t understand why none of my files were being read/indexed by Solr. My files are text files, and after issuing the using cURL to try indexing one of them, I kept getting ‘Invalid character’ errors. I was perplexed.

What I tried: curl http://localhost:8983/solr/update --data-binary testfile.txt -H 'Content-type:text/xml; charset=utf-8'

What I received: Unexpected_character_1_code_49_in_prolog_expected___at_rowcol_unknownsource_11

The solution?

Solr needs to be configured to index non-XML based files, and the indexing command (curl update) needs to be slightly modified:

  1. Edit solr/conf/schema.xml
    1. On line ~450 add the following entry:
      1. <field name="body" type="text" indexed="true" stored="true" multiValued="true"/>
    2. On line ~540 add the following entry:
      1. <copyField source="body" dest="text"/>
  2. Use different cURL upload command
    1. curl "http://localhost:8983/solr/update/extract?" -F "myfile=@./testfile"
    2. refers to a unique document ID for your file

For more information, see the following guide:

Google Maps v3 API example

Google Maps v3 API came out while back, and they have some new features – the most important being no more API key!

You need 5 things for a simple HelloWorld:

  • Include the API:
    • <script type="text/javascript" src=""></script>
  • Declare a CSS style-sheet with style info about your map (don’t forget this step otherwise your map will have zero height and with and will not appear!)
    • <link type="text/css" rel="stylesheet" href="/css/styles.css"/>
    • Content: #map {
      width: 500px;
      height: 400px;
      border: 1px solid black;
  • Initialize the map
    • <script type="text/javascript">
      function initialize() {
      var myLatlng = new google.maps.LatLng(-34.397, 150.644);
      var myOptions = {
      zoom: 8,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
      var map = new google.maps.Map(document.getElementById("map"), myOptions);
  • Create the map div somewhere
    • <div id="map"></div>
  • Initialize the map
    • If you have access to <body>:
      • <body onLoad="initialize()">
    • If no access to <body>:
      • <script type="text/javascript">initialize();</script>

Ignoring multiple files or directories from SVN version control

The following are directions on how to ignore multiple local files from being revision controlled under SVN.
  1. Navigate to the directory where you want to ignore something
  2. Issue the following command:
    1. (Optional) export SVN_EDITOR=vi
    2. svn propedit svn:ignore .
    3. Add the names of the files you want to ignore within this local directory, all separated by a new line character
    4. Save the file
  3. Check to see your chosen files are being ignored
    1. svn status --no-ignore
      1. You will see an ‘I‘ next to ignored files
      2. You may see a ‘M     .‘ entry as well. This indicates your svn properties file was modified. It is important to realize that although you have locally ignored these files, this ignore action will be checked into your version control repository and those files will be ignored globally! I don’t believe there is any way around this, it is a fact of SVN.