Monday, September 28, 2009

First adventure in dirt biking

I get to scratch another item off my personal bucket list. I've always wanted to learn to ride a dirt bike. Last weekend a friend took me dirt biking (think 'motorcycles in the woods') out in George Washington National Forest in western Virginia near Edinsburg, VA. It was a great time. The particular set of trails was called Peters Mills Run and (maybe?) Taskers Gap. More information here: http://atvconnection.com/Resources/ATV_Trail_Guide/Mid-Atlantic-ATV-Trails.cfm

We spent a bunch of time on hard pack clay trails infused with rocks (typical VA terrain). Some of the hills were pure jumbled bunches of rocks (think baseball and soccer ball sized gravel). Some was more of a "loumey" terrain with sand/dirt mix. It had rained a lot, so there were lots of puddles and a lot of general slipperyness. I found my weak points were located in sharp turns with berms that you were supposed to use as banking for turning. I could never get it right and would wash out the front wheel and take a tumble. It even resulted in one very nice over-the-bars tumble when I washed out the front, hit the berm, and went flying.

I have to say -- it was a blast. We only went about 28 miles, but it was fun and very tiring. I road raced motorcycles briefly about 10 years ago, but hadn't been on a bike since then. This was waaay different, but very enjoyable in a completely different way. I have to admit to being a bit bashed and bruised, but generally fairly well off. The friends I went with said I did quite well for the first time out. I attribute that to a combination of previous motorcycle experience, mountain biking experience, and jet ski racing experience. It still resulted in a half dozen spectacular wipeouts, albeit at slows speeds (10-15 mph). Thankfully, the body armor works fairly well. (Note to self: make sure elbox pads are tight enough to not slide up your arm when you hit the ground, leaving big road-rash skids up your forearm.)

I was riding a 4-stroke 450cc bike that worked pretty well for me. (might have been a hond CR 450?) It was nice that it was very torquey and could easily grunt it's way out of low RPM pulls. This reduced my need to shift, which was quite helpful given the fact that I hadn't ridden a bike in 10 years and the clutch/shift/brake/turn/throttle thing was much less natural than I remember it. The clutch was cable driven and VERY stiff for my weak wrist.

On the day after, my forearm is very sore and rashed from my first fall. Otherwise, I've got a small bump on the knee and my quads are getting more sore by the moment. Overall: not to bad for my first experience.

Some notes to myself for pointers:
  • Riding standing up is the way to go. It allows the bike to move around under you and react to bumps much better
  • When standing (or sitting), keep the pegs in the arch of your foot, not balls. Not sure why, but it works. Definately keeps your calves from tiring, as well.
  • Motocross boots are heavy and have NO feel to them. (Shifter or brake) You learn to get more of a feel of whether the brake is working from the way the bike reacts.
  • NEVER react by grabbing the front brake. There's not enough traction usually, so it will most likely just wash out the front wheel. Learn to use the back brake.
  • When in doubt, give the bike blips of throttle. It behaves much better when it has a little momentum.
  • Dirt bike leaning/balance is the opposite of road bike. With a dirt bike, you lean the bike over, but stay upright on top of it. Use the back wheel to brake/throttle slide and get it pointed right, then accelerate. (Road bike you slide down inside the bike, keeping it leaning up to get more ground clearance.)
  • Most of the time, you want to keep your weight forward to avoid wheelying. Expecially going up hills.
  • The suspension's ability to go over huge rocks and bumps is amazing. Use it.
  • When sitting, get forward in the V of the saddle so you are near the center of balance. Tendency is to sit back, which means "wheelie."
  • Don't even think about going out without the right gear unless you plan on doing nothing but roads. And frankly, that might not even be wise. More armor is better when you are learning. (heavy boots, knee guards, elbow guards, chest protector, gloves)
  • It is waaay more tiring than I expected. That might have been a result of the hill climbs and rock scrambles we were doing which requires quite a bit of concentration and bouncing around.
  • Camelback is good. Drink a lot.
And finally, remember: you suck. Be humble. The mountain bites back.

Friday, September 25, 2009

Subclipse handles file renaming (refactoring) of Java classes properly

I started playing with CollabNet desktop and particularly Subclipse within Eclipse. Some things I liked.

Refactoring

Subclipse DOES handle refactoring of classes. That is, if you rename a class, it will create subversion events to delete the old class and add the new class. For example, renaming A.java to B.java shows a "Add B.java with copy-from path of A.java." This means that it preserves the version history over time.

To refactor without the subclipse plugin, I had to do the following:
  • Use "Rename" to rename the class. This fixes all the code and simply renames the existing file as the new file. (OldClass --> NewClass)
  • Do a SVN "Update" to get the old file back in the directory (OldClass.java)
  • Delete that OldClass.java file and rename the NewClass.java back to OldClass.java. SVN should show you that the file has been locally modified.
  • Do a SVN Rename to rename OldClass.java back to NewClass.java.
  • SVN "Check for Modifications" (status) should show you a "delete" of OldClass.java and a "add" of NewClass.java with a copy-from path of OldClass.java
Definately a hassle. It's nice that Subclipse makes it all work properly.

I also noticed that Subclipse and Tortoise SVN seem to "play nice" with checked out versions of code. That is, you can alternate back and forth between using Subclipse and Tortoise to operate on files.

Thursday, September 24, 2009

Great stick figure explanation of AES encryption

I really enjoyed this. It gives a great "poor man's" introduction to how encryption like AES works, how it is fast, yet how it is backed up by some really mind-blowing math.

http://www.moserware.com/2009/09/stick-figure-guide-to-advanced.html

Tuesday, September 22, 2009

HOWTO Include Subversion version identifiers in your Java source code with Eclipse

It's often useful to include version markers in your source code files, especially when it's possible they will be distributed outside the bounds of a version control system. In my case, I'm using Subversion and Eclipse to write code.

Subversion provides keyword substitution for special keywords that are managed by Subversion during checkin an checkout. (See: http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html). These include Date, HeadURL, Revision, Author, and Id (a combination of the others). You can embed these in your text files and SVN will automatically replace them with appropriate values each time. To enable this, you need to do the following:

svn propset svn:keywords "Id HeadURL Revision Author Date" foo.java

Then, you embed a keyword like "$Id" in your file and next time SVN updates your file, it will replace the $Id string with something like $Id: foo.java 148 2006-07-28 21:30:43Z sally $.

To make this easier, you might want to change the [auto-props] section of your config file to automatically set this property any time you create a new java file:

*.java: svn:keywords="
Id HeadURL Revision Author Date";svn:eol-style:native

Typically, this is embedded in a comment block. To make this easy, you can include it in your Eclipse file templates so things get pre-populated when you generate new files.

For general purpose insertion in all your Java source files, use Window > Preferences > Java > Code Style > Templates, then edit the "Files" entry and add the following to the template:

/*
*
* $$Id$$
*/

That will automatically insert the "$Id$" tag into any new source file you create.

Another reference:
http://wiki.collectionspace.org/display/collectionspace/Java+Source+Files+-+Beginning+Comments+Block+Template

For more advanced usage, you can embed a string in a variable that gets compiled into the object code and can be used to identify versions of binaries.

For Java, insert a piece of code that looks like this:

// version identifier automatically filled by svn:keywords "Id"
public static final String __class_id = "$Id$";

This will expand when the files are checked in to be representative of the version of code that was committed.

This can automatically be inserted in new classes with code templates, again. Window > Preferences > Java > Code Style > Templates > Code > Class body. (Make sure you use $$ for the dollar signs when you create the template.)

Pitfall: Make sure you have cleanly committed/updated files when you do this. Don't make the mistake of building your modified code that is checked out, then distributing it. Once you commit this code, the version number will bump up and potentially be different.


HOWTO specify default JVM arguments when using Java JAR manifest

A couple of times I've wanted to be able to specify a set of "default" JVM and program properties using the manifest file of a JAR file so that I could invoke it easily with "java -jar MyProgram." In my case, I wanted to set the JVM system property "https.proxyHost" so that all my web traffic would go through a local proxy.

Unfortunately, there doesn't appear to be a way to specify program arguments in a Java JAR manifest file.

To get around it, the solution is to use properties. I found a useful post here (http://www.velocityreviews.com/forums/t129370-vm-arguments-in-manifest.html) that suggests doing something like this:

static {
System.setProperty("https.proxyHost", proxyHost)
}

This solution actually worked quite well. I ended up writing a "JVMProxyHelper.setProxy(host,port)" routine that I simply invoked from the main() of the program I was running. If I get really fancy, I'll go back and make it read the property out of a file and register it that way, but this works for my quick need.

HOWTO Create Ant build.xml file from Eclipse Java project

I searched around and couldn't find an easy answer for this, but accidentally found it in Eclipse while doing something else. Basically, I created a simple Java program in Eclipse. I wanted to be able to build the program from the command line with ant, but didn't want to hand create the build.xml file when I knew that Eclipse should be able to generate a basic one for me. I kept looking in the "Project" menu and "New" menu for a way to do it.

Answer: It's in the "Export" menu. If you do Export > General > Ant build file, everything works fine.

Beware: it automatically over-writes any build.xml file that may exist with no warning. Don't make modifications unless you figure out a way to preserve them when things change.

Similar task: if you want to produce a runnable JAR file from your project, you can use Export > Java > Runnable Jar to do so. This can also create a custom Ant build file that automatically packs all the Jar stuff you need. NOTE that one of the things this does is re-pack any dependent Jar files you have into one big jar so you can run it with "java -jar."

If you have additional rules in the file that you would like to include in the generated build.xml, you can make Eclipse automatically import these files.

In the same directory, create "build-custom.xml" with the following lines:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse.ant.import?>
<project default="all" name="Create runnable JARs for everything">
<target name="all" depends="build">
... more stuff ...
</target>
</project>

Then export the build.xml file from Eclipse. It will now include a line
<import file="build-custom.xml">
near the beginning. All rules you define in your custom XML file will appear
as part of the build.xml file. You could now execute "ant all" to invoke your "all" rule from the main command line.

NOTE: I think your filename must start with the word "build....xml" in order for Eclipse to find it.

Monday, September 21, 2009

Using Alfresco 3.2 "Share" capabilities

I recently install Alfresco 3.2 Community on a VMware image on my machine to play with it. For information on how I did that, see my other post.

I had some questions about how, exactly, I might use the 'share' capabilities. These basically emulate a lot of the capabilities that Microsoft Sharepoint provides. I believe, in fact, that Alfresco actually presents a Sharepoint protocol interface that can be used by other sharepoint clients.

Questions:


Questions:

  • Q: How do I get to WebDAV path of files in Document library?
  • A: http://192.168.177.131:8080/alfresco/webdav/Sites/firstsite which is the same technique used for all other Alfresco WebDAV access.
  • Is there a way to directly edit document library files
  • Is there a way to share files between “Share” and “Alfresco” hierarchy?
  • o A: “Alfresco” main site sees the content of the “sites” hierarchy as files data, but I don't think the "Share" sites have a good view of the containing Alfresco instance
  • o Operations on the items seems to be limited. I don't seem to be able to create "rules" on documents within a "site" document library, but I'm not sure I ever was.
  • o Can Embed a “widget” or treat as a “site” ?
  • o Tried with a “web view” applet, but that requires you to login and doesn’t really connect to much.

  • - How would we create a main company site, then show highlights of other sites for projects
  • - How do we create template share sites to create new projects?
  • - Is there a quick way to “monitor” for changes in a site? (e.g. email)

  • Q: Is there a way to create an “intro page” for a site?
  • o A: yes. “Customize Dashboard” to move around widgets.

Setting up Alfresco 3.2 Community in a Linux VM

I've used Alfresco a bunch in the past at work to maintain documents. We're thinking of upgrading from the (very) old 2.2 release to the (much) newer 3.2 release. This is what I did to get started.

I set this up in a VMware image of a Ubuntu Workstation 9.04 (512 MB RAM, 25GB disk). For information on this, see my other blog post.

To get started with Alfresco, I did the following:
- Download Sun jdk 1.6 se, install, move to /usr/local/java
- Sudo apt-get install mysql-server
** Ask for a new root PW. Set one.
- Download alfresco 3.2 community from http://www.alfresco.org
- Sudo ./Alfresco-....-install
o Chose /opt/alfresco as installation location
o Asks for root pw of mysql;
o Creates ‘alfresco’ database in mysql
o Ask for where Open Office is installed. I fed it /usr/lib/openoffice after locating it on my disk.
o Start Alfresco
- . cd /opt/alfresco
- . ./alf_start.sh
- (wait)
- http://localhost:8080/alfresco

This produces and “up and running” version of alfresco. (NOTE: The NAT interface between my host OS and guest Linux OS is 192.168.177.x. Host is .1 and guest is .177, hence the interfaces below.)
- http://192.168.177.131:8080/alfresco allows access from my external machine
- Shows "guest" account view by default
- Login: admin (default PW)
- Created user for rmills
- Tested login and upload of a document.

Alternate Interface: Alfresco Share
  • http://192.168.177.131:8080/share
  • Login: rmills or admin
  • Create a site (Collaboration Site)
  • Name: FirstSite
  • URL: firstsite
  • Public


Friday, September 18, 2009

Setting up an easy VMware Linux machine

I spent a few minutes playing around with VMware to get a linux virtual machine set up on my PC. It was actually fairly easy:

  • Download and install latest VMware Player from www.vmware.com (reboot)
  • Download a Ubuntu 9.04 Desktop virtual machine from the "Appliance > Operating Systems" section of the VM Ware site
  • Unpack the VM image
  • Double click on the virtual machine and VMware player starts up.
Magic. Easy.

Now I have a VM running linux on my machine that I can play with. It seems to be auto configured with NAT networking, so I can use SMB to access shared drives on my host PC to transfer files back and forth. It can also reach the internet with a web browser, etc.