Google Code’s Guava

Google Code has a java library called Guava. I recently found and used a utility class in the library called Joiner. I used the Joiner class to join a list of String items to make the list one comma separated list. For example:

String[] myList = {"Item 1", "Item 2", "Item 3"};
Joiner joiner = Joiner.on(", ").skipNulls();
String result = joiner.join(myList);

The output would be: “Item 1, Item 2, Item 3″

Posted in Java, Programming | Tagged , | Leave a comment

Regular Expression

I had to solve a problem today where we moved a web application from Apache Tomcat 6 to Apache Tomcat 7. All of the applications within Tomcat 6 had to be moved to Tomcat 7. However, some of those applications had jsp pages where an html or jsp tag’s attributes might not have had at least one space between an attribute’s closing quote and the first letter of the subsequent attribute. So, I created a regular expression that can be used to find that text pattern in a file. The regular expression is \)"[a-z].

\) searches for a closing parenthesis,
” searches for a single quote
[a-z] searches for a single occurrence of an lower case letter from a through z, inclusive.

Posted in Programming, Regular Expressions | Leave a comment

What Every BODY is Saying: An Ex-FBI Agent’s Guide to Speed-Reading People

Some time ago I read Joe Navarro’s What Every BODY is Saying: An Ex-FBI Agent’s Guide to Speed-Reading People. It is a very good read and provides some interesting insight on the hows and whys of human behavior.

Posted in Read List | Tagged | Leave a comment

Python Random String Snippet

This Python snippet can be used to generate a random string.

import random
import string
string_length = 10
random_string = u''.join(random.choice(string.ascii_letters) for x in range(string_length))
print random_string

Posted in Programming, Python | Leave a comment

Disabling Apache Service on Ubuntu

To disable the Apache httpd service type the following in a terminal window.

sudo update-rc.d apache2 disable

This will disable the http daemon at boot time, but leave the Apache on the server. To enable the Apache httpd service at boot time type:

sudo update-rc.d apache2 enable

Posted in Ubuntu | Tagged , , | Leave a comment

Spring Roo Tip

I’ve been working on a Spring Roo application and needed to add a domain class used to model application users. I tried using the default Roo command for adding the User domain class “entity jpa –class ~.domain.User –testAutomatically”, but Roo does not like that method because the name “User” is a reserved word in SQL. However, you can overwrite the command and force Roo to create a User class by adding –permitReservedWords to the command (entity jpa –class ~.domain.User –permitReservedWords –testAutomatically). I’m not sure if this is the most secure way to do things, but it is an option.

Posted in Uncategorized | Tagged , , | Leave a comment

Maven Tip

Here is a maven command to list all of the jar files that project is dependent on:

mvn dependency:list

Posted in Maven, Programming | Leave a comment

Getting Current IP Address in Python

The following code example retrieves the current ip address. I know this works for Python 2.7.

import socket
ip_addr = socket.gethostbyname(socket.gethostname())

Posted in Programming, Python | Tagged | Leave a comment

Useful Unix Command

I’m a fan of cygwin. I needed a command alias for listing only directories using the ls command, so here is what I came up with:

ls -l | grep “^d”

I then added an alias to my .bashrc file like so:

alias ld=’ls -l | grep “^d”‘

Posted in Unix | 1 Comment

A New Word

Today I was working on a function to convert a map coordinate from degrees-minutes-second format (e.g., 125° 23′ 42” W) to decimal degrees (e.g., -125.395) and I came across the word Sexagesimal. It is not profanity.

Posted in Humor | Leave a comment