Some have asked why I have not posted any new software tips in quite a while. 2 reasons.
First. I've been promoted to oversee all the engineers and so that keeps me pretty busy.
Secondly, because I am working on two masters degrees at the same time.
So, I will be happy to answer questions when I have time but I don't plan on posting any new software tips for quite sometime unless I find something so amazing I just have too.
Why I haven't posted in a while
Posted by Brent Coffey at 10:09 AM 0 comments Links to this post
Compiling OpenSSL on Mac OS X Snow Leopard
Snow Leopard comes with a dated version of OpenSSL 0.9.8l and for various reasons you may want to install the latest version. Here is how I was able to install the latest version (1.0.0c as of the writing of this blog) on Snow Leopard.
NOTE: This Blog assumes you have some familiarity with the terminal, using the command line, and opening and closing applications. If you are not comfortable with any of these things then I do not suggest you try this on a production machine.
Before beginning check your current version of OpenSSL by opening a terminal and typing:
openssl version
You should get back the following if you have not updated OpenSSL since installing Snow Leopard:
OpenSSL 0.9.8l 5 Nov 2009
Assuming you don't already have 1.0.0c or later already installed, you have XCode installed from Apple, and you have administrative rights to the machine you are installing on, then you are ready to begin.
STEP 1: Download the Source Code from the OpenSSL website (http://www.openssl.org/source/).
STEP 2: Open a Terminal and navigate to the directory where you download the source code to. In my case the source code was download to ~/Downloads so I typed on the command line:
cd ~/Downloads
STEP 3: Configure the build by typing
./configure darwin64-x86_64-cc
STEP 4: Type
make
STEP 5 (Optional but fun): Test that everything was created correctly by typing
make test
STEP 6: Install the newly built OpenSSL application by typing:
sudo make install
(Type password when prompted)
STEP 7: Navigate to the directory where the old openssl is installed by typing:
cd /usr/bin
STEP 8: Rename the old openssl file to another name so that you can go back to it if you need to:
sudo mv openssl opensslOld
Posted by Brent Coffey at 7:52 AM 4 comments Links to this post
Labels: mac os x, OpenSSL, Snow Leopard
Devoxx Java Conference
My team and I are off to Belgium in two weeks for the Devoxx Conference. First time I have gone to Devoxx and Belgium! Looking forward to it, even though I despise flying.

Posted by Brent Coffey at 7:30 PM 0 comments Links to this post
Using Apache Velocity with Java Properties File
The Apache Velocity project is an amazingly useful tool which allows you to merge data with templates. Here is a quick example of how it works.
First suppose you had a "template" text file that looks like the following
$awesomeProgrammer needs to purchase a new $device.
Go ahead and save this in a file called "test.tpl." Then suppose you had a "context" or "properties" file that read like this:
#This is a comment
awesomeProgrammer=Brent Coffey
device=Mac Pro
Save this file as "test.properties." Now you want to programmatically mash together the properties file with the the template file so that the output looks like this:
Brent Coffey needs to purchase a new Mac Pro.
This is what the Apache Velocity Engine will do for you with very little code here is how it works.
Assumptions: First this example assumes you have already have a working knowledge of Java, Eclipse, jars, and classpaths. Therefore create a new project in Eclipse and add the velocity-dep-1.4.jar to the classpath. You can download the jar from the Apache Velocity web sit by clicking here.
Second note that the example I'm giving is a down and dirty example, and I would not recommend using this in production because I'm not going to handle all the try catch statements or possible errors that could arise nor is this an example of "good" OO programming. So take it for what it's worth; a plain-ole super simple example of how to use velocity to merge a properties file with template.
I wrote this code to be really self explanatory. I may come back later and explain more if it's needed or requested. Let me know.
Here is the code:
To run this example ensure that the two files you created above (test.tpl, test.properties) are in the root of the executing directory. Pass those two files to the application as command line arguments in the specified order (template first followed by properties file) and if everything is located in the correct place you should see the string: "Brent Coffey needs to purchase a new Mac Pro." printed out to the console.
Posted by Brent Coffey at 9:46 AM 0 comments Links to this post
Labels: Java, properties, velocity
Man Pages as PDF
Sometimes I want to read a man pages in a seperate window from my terminal I am working in. Instead of opening another terminal I read this handy blog on how to open a man page as a pdf. (Why I didn't think of this myself I don't know as I do simular type things for html and jpeg files all the time...oh well). The solution suggested in the blog is to "simply" type:
man -t XXXX | open -f -a /Applications/Preview.app
Where XXXX is the thing you want the man page for such as ls, ipconfig, snmpget, etc. I thought that was quite a handy tip but a bear to type. After all it's pretty simple to just type: man ls. Whereas having to type the other monstrosity of a command makes for an interesting blog but frankly less than useful utility.
So, for fear of stating the obvious, I took the blog one step further and created a script to do the work for me and to greatly simply the task. Here is the simple script, which I named manpdf:
#!/bin/bash
man -t $1 | open -f -a /Applications/Preview.app
NOTE:There are tons of ways you could make this even more useful (post those in the comments if you wish):
Save the script, as root, this script in your path, in my case I saved it to /usr/bin. Then make it executable by typing:
sudo chmod uga+x manpdf
Now you can simply type: manpdf XXXX, to open a man page for a given command.
Posted by Brent Coffey at 5:24 AM 0 comments Links to this post
GeoTagging Photos and then What to do with them
How to GeoTag Photos and What to do once they are GeoTagged
My Hardware:
1. Canon EOS Digital T2i Camera
2. Delorome PN-40 GPS
3. MacBook Pro
4. LowePro FastPack 350
My Software:
1. Mac OS X
2. GPS Babel (Free)
3. PhotoLinker ($50 recommended) or GPSPhotoLinker(Free)
4. Aperture 3
Web Sites to use GeoTagged Photos (Listed in the order I would recommend using them)
1. Panoramio.com (Easiest to use if you want your photos in Google Earth, only for scenic/landscape photography!)
2. EveryTrail.com (If you went on a trip and you are logging your journey. Can place pictures and video of your trip along with GPS Track)
3. HistoryPin (For Historical Photos of a place)
Start of Photo Shoot Step 1:
1. Ensure your Camera has the correct timeset, battery is fully charged for GPS and Camera.
2. Turn on your GPS
3. On your GPS, turn tracks on at the start of your photoshoot or trip.
4. Once satellite lock is aquired on GPS begin journey toss gps in side mesh pouch of LowePro backpack and forget about until you are done.
5. Hike and shoot photos at will.
After Photo Shoot Step 2:
1. Stop GPS Track and Save.
2. Turn off GPS.
2. Turn off Camera.
Back at your Computer Step 3:
GPS Babel
1. Copy Pictures to new folder on your computer. (Do not import to Apeture or Lightroom or anyother photo management tool yet!)
2. Open GPS Babel
3. Connect GPS to Computer
4. Turn GPS On (and ensure GPS is ready to send data to computer (differs by model)).
5. Select GPS From top pull down menu in GPS Babel
6. Ensure ONLY Tracks is checked
7. Select GPS XML from dropdown menu
8. Click on File Name and choose to save your GPS XML file in the folder you created in step 1 above.
9. Hit Apply
10. Close GPS Babel.
Photolinker
1. Load Track (GPS XML file created above). Click Tracks->Load Tracks from File...
2. Load all pictures saved above. Click Photos->Load Photos from File
4. Click on GeoTagging Console button in the lower right side.
5. Set Timezone to the timezone that the Camera is using for the pictures!!
6. Click on one picture.
7. Select all loaded photos (Ctrl+A)
8. Click Geotag X Photos button in lower right side of GeoTagging Console
9. Click Write Changed Tags
10. Exit Photolinker
Aperture
1. Open Aperture.
2. Click Import
3. Select folder where new photos were stored
4. Import Pictures as you would normally
5. Make any adjustments to your photos as you normally would using Apertures tools.
6. Once photos are imported, click on the Places button (Top Right Side) to see your photos all geotagged.
7. Go back to Split View by clicking Split View Button (Top Right Side).
8. Click File->Export->Versions...
9. Create a new folder and name it "contrib"
10. Give the photos a generic name
11. Click ok.
12. Wait for all photos to be exported (may take a while).
NOTE: You now have JPEG versions of all of you photos on your harddrive. These can now be used to upload to web sites. Aperture to the best of my knowledge does not have an export for EveryTrail, Panoramio, or HistoryPin so this is why the manual export was necessary though annoying.
Using your Photos to Benifit the World Step 4:
Panoramio.com
1. Open Browser
2. Go to www.panoramio.com
3. Create an Account
4. Upload photos in your "contrib" folder by clicking Upload link at top of page.
5. Follow Directions on site.
6. Your photos, if approved should be avaible in on google earth in a few days, though it may take up to a month. My experience has been days though.
EveryTrail.com
1. Go To www.everytrail.com
2. Create an Account
3. Upload GPS XML file you created
4. Write a few sentences about your trip.
5. Upload Photos from the "contrib" folder.
6. Follow additional directions and photos should be placed on track correctly.
HistoryPin
You get the idea...same type thing... follow web sites directions
Final Step Step 5:
1. Tell all your friends about your photos on Panoramio and EveryTrail using the twitter and facebook links on Panoramio and EveryTrail!
2. Post your pictures on your blog! ;-)
Posted by Brent Coffey at 2:01 PM 0 comments Links to this post
Labels: Aperture, gps, GPSBabel, mac os x, photography, Photolinker, Photoshop
JUnit Parameterized Test
Sometimes you want to test a method with various inputs to perhaps check to ensure the method works with all kinds of different data. I had just this issue the other day and knowing that JUnit 4 supports "Parameterized" Test I decided to use that methodology. Here is how it works.
Problem
Imagine you have a method in a class that makes a word plural by adding an "s" or an "es" to the end of the word (yes I know, silly example, but just go with me on this!).
Example if you pass in the String "dog" it should return "dogs." If you pass in the word "fish" it returns "fishes." (Because this is a simplistic example and this blog is about parameterized test, not how to make a word plural our method will only work for these two words.)
Method to Test
JUnit Test
Comments in the code tell what is being done
Thats It. When you run your JUnit test in the Eclipse IDE you should see this result:
Posted by Brent Coffey at 10:25 AM 0 comments Links to this post


