Tuesday, March 8, 2011

LDS Tools for Android

So I wanted to start working on the LDS Tools app for Android and it was a bit of a pain to get it all setup, so here's the list of stuff that I had to do to get it to work and hopefully it will help someone else out. I did it with Ubuntu 10.10, but the same general steps should apply to any OS.

  1. Install Eclipse (sudo apt-get install eclipse)
  2. Verify that Eclipse Update repo setup correctly (instructions here) (this was actually only a problem for me in Fedora and not Ubuntu)
  3. Install Android SDK (instructions found here)
  4. Create a Virtual Device (instructions here)
  5. Checkout the code (Instructions here)
  6. Change JDK Compliance to 1.6 in Windows->Preferences->Java->Compiler
  7. Create a new Android Project in Eclipse using the checked out source
  8. Install Checkstyle (Instructions here) (I had to set it to exclude the "files not open in editor" to avoid a ton of places that didn't match the style file. Hopefully, that can be resolved as people start to write compliant code)
  9. Add the checkstyle-config-1.0.0.xml as an "External Configuration File" in the Checkstyle section of the Project Properties
  10. In the Java Code Style->Formatter section of the Project Properties, import the ldssa.codestyle.xml file and select that as the Active Profile
Automatic build is enabled by default, so let it do its thing and then you should be able to run the generated executable. For me to get the Android emulator to connect to the internet on my laptop I had to disable my ethernet connection so it would use the wireless, but other than that the compiled app ran great.

Thursday, February 11, 2010

Why didn't I think of that?

As much as I love C++, I've also thought that formatted output was a bit of a pain. Every time I have to do it, I spend tons of time looking things up and getting everything to work the way I expect. It's the only time that I long for a C feature (printf). Well, today I stumbled along this article, and I have to say that the guy is a genius. It's definitely one of those "oh ya" type of things that's almost so simple that it's stupid and makes you wonder why you didn't think of it, but is also so profound that it's amazingly powerful. I tip my hat to the wonderful beauty and power contained in this simple solution.

Friday, August 14, 2009

Changing the world...a baby step at a time

I just finished reading this excellent interview with Bjarne Stroutrup. The guy just blows my mind with how much he understands and takes in, and it just made me start thinking about some thing. He uses an amazing analogy in the interview where he points out that the amount of energy required to move a boulder across a town is far greater than to move a pebble across that town, but in the end everyone cares where the boulder is and only if the pebble ends up in someone's shoe does he whine about it.
It made me realize that for the majority of my life I have viewed "genius" and "skill" as getting something done quickly or in some clever manner, but in reality, true genius is in the slow and steady work that moves that boulder. Even in life, very little of any consequence is done in a minute, an hour, or even a day, but the things that truly matter can take a lifetime. It was just an interesting thought that helped me remember that the old adage, "slow and steady wins the race," probably has more truth than even an initial inspection lets on.
...or maybe I'm just getting old.

Wednesday, July 15, 2009

Queries for Nested Set Model

So this is just a follow up post to my Nested Set Model post to document the scheme/queries that I'm using to define my tree. I created a node with id=0 called ROOT (since it's basically just a place holder that I use to do the dirty work and won't ever show the user) and create a UNIQUE constraint on (lft, rgt) to satisfy my obsession with data integrity (and I imagine that it should help speed up the queries as well).

So here's the queries I use to grab the information in useful manners.

Grab the Whole Tree:
SELECT *
FROM bills
ORDER BY lft;
Grabs the Ancestors of a Node:
SELECT parent.*
FROM bills AS node, bills AS parent
WHERE node.lft BETWEEN parent.lft AND parent.rgt
AND node.id = ? AND parent.id <> ? (NOTE: Both ?'s are the same value)
ORDER BY node.lft;
Grabs the Descendents of a Node:
SELECT node.*
FROM bills AS node, bills AS parent
WHERE node.lft > parent.lft AND node.rgt < id =" ?">
Grab the Parent of a Node:
SELECT parent.*
FROM bills AS node, bills AS parent
WHERE node.lft BETWEEN parent.lft AND parent.rgt
AND node.id = ?
ORDER BY parent.lft DESC LIMIT 1,1
Obviously, the '?' is the ID of the node that you're interested in and you can cater the selected columns to your needs.