Search This Blog

Tuesday, December 29, 2009

How can I read to learn?

A while back, I came across something called SQ3R while I was reading Pragmatic Thinking and Learning: Refactor Your Wetware.   It is an interesting method of reading with the intent to learn.  To date, I have never applied that technique.  That, however, is about to change.  Recently, I've borrowed a buddy's book on a Java clustering technology known as Terracotta.  I'm very interested in the topic and I think I'll get a chance to apply it on some upcoming projects so I would really like to understand the material.  I'm going to attempt and apply SQ3R to the book and see if it helps me to better understand the material.  My plan is to apply the SQ3R steps to each chapter and use this blog as my "notebook".  Wish me luck.

Monday, December 28, 2009

Can I create an inexpensive home theater solution?

Over the past 24 months I've been looking for a way of organizing the family DVD collection.  Two kids and 20 years of marriage have contributed to what seems to be an ever growing DVD collection.  Every birthday or Christmas brings a new disc into the house. A DVD collection can get cumbersome pretty quick.  The volume of the physical media is one issue.  We've tried book cases as well as binders in an attempt to organize things but both solutions have one fatal flaw: The Couch Factor.  When I'm in the mood to watch Office Space I don't want to get off the couch and hunt around for the disc just so I can pop it into a player.  In a word, physical media is a pain.

Luckily, hard drives are becoming cheaper each day.  I recently picked up a 1TB external drive for $65 at Target.  Over time I've ripped our movie collection into a form that can be played over our home network.  My initial attempt was to rip the movies into an ISO file using AnyDVD for play using a Ziova CS505.  The player itself was good but the user interface was terrible.  Despite the fact is could play DVD ISOs, FLAC audio and Xvid, finding the file you wanted to play was painful.    That system showed me the potential, however,  for playing my media from anywhere in the house -- without getting off of the couch.

Months later, my son got an Xbox 360 which could play media files.  It suffered, however, from the same drawback that the Ziova did -- terrible user interface.  Much like the CS505, all it did was provide you a way of traversing the directory structure until you could click on the file you wanted to play.  Not a very friendly experience.

Fast forward a few more  months.  A co-worker turned me onto a method for modifying a classic Xbox so that it could run some media software: XBMC.  I had an Xbox lying round dying from neglect -- it got replaced by the Xbox 360 -- so I had nothing to lose.  In short, XBMC is a great solution.  Not only could it play my DVD ISOs and Xvid files, it could play lots of audio formats as well as display photos. The best part, however, was its ability to go out to the internet and find meta-data about the files.  XBMC allowed my to peruse my collection by title, rating, year, genre -- you name it.  I was in digital Nirvana.  Fast forward a few more months and I started to see warts on my beloved Xbox/XBMC solution.  DVD ISOs are fairly large, ranging anywhere from 2GB to 7GB depending on the movie.  I didn't have that kinds of drive space to spare.  I do have a 3TB NAS to store family photos, movies and any other data that can't be recreated but it wasn't near enough to store every movie we had.  Eventually, I discovered HandBrake, which is an excellent tool for transcoding video between formats, and experimented with transcoding the raw DVD ISOs into something smaller.  The ideal format to use would be H.264 because that is Apple iTouch's native video format and is becoming increasingly wide spread.  Unfortunately,  the classic Xbox is essentially a Pentium 3 and doesn't have the horsepower to properly decode H.264.  Not sure exactly what I should do, I decided to do nothing hoping the Moore's law would help things.  Thankfully, it did.

Fast forward to present day.  The folks over at LifeHacker posted an article titled Build a Silent, Standalone XBMC Media Center on The Cheap.   I followed its advice and purchased the following hardware for $240 USD:

The essence of the article is  to take a nettop box and run XMBC on it, routing everything thing through HDMI to your hi-def television.  Seemed like a good Christmas day project.

The AR1600 is an Atom based processor with dual cores and 1GB of memory.  It comes pre-installed with Windows XP and some Acer bloatware.  Wanting to squeeze out as much computing power as possible, I imaged the drive and proceeded to install version 9.10 of Xubuntu, code named Karmic Koala.  Xubuntu is a variant of Ubuntu Linux targeted for lower end machines -- like ones with only 1 GB of RAM.   The install went off without a hitch and I activated the native Nvidia driver to give the video sub-system a little boost.  Using the directions at the XBMC site, I was easily able to install XBMC 9.11, code named Camelot.

Getting the  remote control, however, took a bit more digging.  As it turns out, you have to pull up Synaptic and install the lirc package.  At the end of the install, it will bring up a selection dialog where you can select a remote control and a transmitter.  For the remote control, tell it is a Microsoft Windows MCE controller and select None for the transmitter. That should be all you need to do in order to navigate XBMC via your remote control.

The one final piece to the puzzle was how to make this into a turnkey system: turn the power on and the system automatically launches XBMC.  The XBMC directions tell you exactly how to do that.  It walks you through enabling automatic login into the system and how to select XBMC from the session menu.  Unfortunately, the session menu did not have the XBMC selection as the instructions indicated.  I'm guessing that this is because we're running Xubuntu, which doesn't use Gnome as its window manager using the lighterweight Xfce instead.  To solve this problem, I simply copied /usr/share/applications/xbmc.desktop to /etc/xdg/autostart/.  This causes XBMC to be started right after you automatically log into the system.  I got the idea from this blog post.

Connect the nettop to your high def tv via an HDMI cable and you are good to go.  I've got a enough computing power that I'm free to use whatever codecs I wish to store the movies as.  My current preference is to use the high profile H.264 selection in HandBrake.  This setting creates a video file that is playable on XBMC, Xbox 360 and iPod iTouch.  I would speculate that it would work on a PS3 as well, but I do not own one and cannot say for certain.  I'm hoping that this will be the solution I use for years to come.  I plan on sticking another stick of RAM into the unit and bring it up to 2GB, which should help performance a bit.  I still have one final problem to solve, however.  My TV is a couple years old and only has two HDMI ports.  As you probably have guessed, both ports are currently in use: one for the Comcast box and one for the Xbox 360.  I've got to do a little research to see if there is a way get more ports into the tv, such as something similar to a USB hub.  If you know of something, please drop me note.

Thursday, December 24, 2009

How can I manage all of my internet accounts and passwords?

I'm a computer jockey and spend most of my waking hours parked in front of a laptop or some internet enabled mobile device.  I've come to rely on the internet and all of its wonderful services.  Some of these services, such as GMail, require me to log in before I can use them.  The credentials for the services I use everyday are burned into my brain never to be forgotten.  For things that I use only a couple of times a year, such as my brokerage account, are a different matter.  It seems like I'm always forgetting either my username or password.  Heck, sometimes I even forget the URL for the site I need.  I'm a fan of the Security Now podcast and have come to appreciate the security aspect of the internet.  The days of plastering my monitor with Post It notes  are over.  How can I manage all my internet accounts in a safe and convenient manner?

My solution is to combine two technologies together to create a nice solution.  I use Linux and Windows machines so I need a solution that works in both environments.  As luck would have it, somebody has already scratched that itch.  Enter KeePass Password Safe.  As the name implies, it is a digital safe to store all of your important account information.  It is an open source product that runs on a variety of platforms.  Essentially, it keeps track of URLs, usernames and passwords for your various accounts.  The data is stored safely in encrypted file and it even comes with a nice password generator.  The other nice thing is that the program is self-contained meaning that you can run it without having to actually install it.  If you wanted to, you could run it from a USB thumb drive giving you access to your account information even if you are using a public computer in your local library.

One of the lessons I've learned from Security Now is that multi-factor authentication is preferred over single-factor authentication.  Single-factor is the type of authentication we are most familiar with -- all you have to do is provide a password that matches with a user name and you are in.  In multi-factor authentication, you need a password and something else -- a combination of something you know (password) and something you have (a special security dongle, for example).  Trying to be as security conscious as reasonable I want to use a multi-factor solution.   KeePass supports this by requiring both a passphrase and key file.  So, to unlock KeePass I need three components: the KeePass encrypted data file, the key file and a passphrase.  My solution is to store the data file inside a Dropbox folder that can be seen by all of my machines.  I keep the key file on a USB thumbdrive that I always carry around with me and, of course, store the passphrase in my head.  As long as I have my thumbdrive and a Dropbox enabled machine, I can pull up my account information.  There is a problem, however, I need to solve: what happens if the thumbdrive fails and I can't access the key file?  In short, I'm screwed.  I'm terrible at backing up my data so I'll have to ponder this for a while.  Having lots of copies of the key file seems to defeat its purpose so I'll have to come up with something clever.

Can I mix Terracotta with custom classloaders?

Today's challenge is going to be an interesting one.  As I often do, I'm attempting to mix a couple ideas together to see if something really interesting comes out.  Here's the context: I'm looking at Terracotta Distributed Shared Object technology for a project I'm working on.  It is a really slick way for distributing objects between JVMs without having to implement any custom infrastructure classes -- POJOs all the way, baby.  The application will be using Spring to manage object instances as well as supporting Hibernate access.  The part of the project I'm working on is headless so I would like to use a bootstrap classloader to help keep the installation process simple.  I would also like to use the TDSO infrastructure to share a few key objects.  Mixing the two ideas, however,  is proving to be a challenge.  As you may have guessed, part of Terracotta's magic is done via classloading which means you have play by their rules.  In my case, I'm creating a brand new loader for my application and not using any Terracotta classes.  Specifically, I'm creating a new URLClassLoader and populating it with the JARs and directories I need to run my application.  When I use the launcher in conjunction with TDSO, I get the following error:

"java.lang.IllegalStateException: This classloader instance has not been registered (loader class:java.net.URLClassLoader)."

A bit of Googling turns up a few discussions that suggest either writing a Terracotta Integration Module (TIM) or casting my loader to a NamedClassLoader and calling the __tc_setClassLoaderName method might solve my problem.  Writing a TIM seems like a lot of work but that is what was done for other environments that use custom classloaders, such as Tomcat and Jetty.  I put in some reflection code just to see if the __tc_setClassLoaderName was even available and, as expected, it was not.  I'm guessing because I never told TDSO to share the URLClassLoader so it didn't work any of its byte code manipulation magic.  This is going to be a tough nut to crack but I'm not ready to give up just yet.

Can I update my blog from my cell phone?

From phone.

The above message was sent from my cell phone -- honest.  Google has rigged up Blogger so that I can quickly send an SMS or e-mail message and it magically appears in my blog.  Very slick.  All you have to do is register your phone, by sending Google an SMS message, and you are good to go.  I don't anticipate using this feature but you never know if it might come in handy.  Who knows?  Maybe I'll be in the woods and spot Big Foot?

Wednesday, December 23, 2009

How can I use Google to host my domain?

Gina Trapani has written an excellent set of articles that explains a Google service that can help small business and organizations set up a shared office infrastructure.  What do I mean?  Lets say, for example, that you have a business idea for creating a community for people who love to collect comic books.  In a surge of excitement, you pop over to GoDaddy.com and grab comicbookhaven.com.  Now what?  You know you want to share this idea with various people to see if the notion can gain some traction.  That means e-mails, meetings, wikis, public facing web sites, etc.  It turns out that Google has something called Google Apps that allows you to hide some of its cloud-based office suite behind your domain.  For example, instead of the usual joe@gmail.com you can use joe@comicbookhaven.com.  The pedestrian calendar.google.com becomes calendar.comicbookhaven.com.  You get the idea.  The list of Google services you can rename in this manner continues to grow and currently includes:

  • e-mail
  • calendar
  • chat
  • docs
  • sites
Very convenient and, best of all, its free -- at least until you grow to beyond 50 people.  After that, you have to start paying.  As you add people to your Google Apps based domain, everything in the domain is shared with others within the group -- contact lists, documents, calendars, etc.  This makes it convenient because you can skip the step of sending out an e-mail invite so that you can share something -- it is already taken care of for you.

I've been using Google Apps for a short time now and I like it.  It was fairly painless to set up -- which is even less painful if you go through one of Google's partners, such as GoDaddy, when you buy your domain.  I think it makes sense to set up a domain even for families.  It is easier to get grandpa Joe's email working if everybody is using the same tools.  I encourage you to take a peek at Google Apps.  Who knows, maybe you'll come up with the next Twitter and tell the tale to your friends and family about how you started out with nothing but an idea and a domain name?

Tuesday, December 22, 2009

What would Google do?

I've been reading Jeff Jarvis' book "What Would Google Do?" and I must say that thus far I'm impressed.  The writing has a bit of humor to it and plenty of "I never thought of it that way" moments.  I suspect anybody who reads it will change their view of business models in the new digital economy.   Load it up on your favorite e-book reader or listen to it in audio book format. 

Friday, December 18, 2009

How can I manage my Java program's classpath?

I ran into an interesting article that shows a solution to the problem of running incompatible classes within a single JVM. The idea is to keep the launching application's classpath small and clean and then use a custom classloader to load the application's various pieces. Using separate classloaders is exactly how most Java EE containers keep applications from seeing each other's classes. I think this technique, couple with a command socket is a great way to launch an application. It is very possible to use multiple loaders to run variants of the same application within the JVM and not have to rely on OSGi or Java EE and the associated complexity.  The technique is fairly simple to implement and helps to avoid those pesky ClassNotFound exceptions.

How can I control a headless Java program?

I ran into an interesting idea and will describe it here. The problem is that you have a headless, server type process running and you need a clean way to administer it. One idea is to create main() that starts a thread that actually runs the program. The main thread opens a socket and waits for commands. You can then send a "stop" command which halts the application thread and exits the main thread. I can see this tactic being a great way to start a non-web based Spring application. The application thread does the normal Spring context instantiation, making sure to have Spring register its shutdown hook, while the main thread just waits for a command. Since the command thread isn't going to be under load you don't have to pay any special attention to the listening code, such as using NIO or socket frameworks.

Thursday, December 10, 2009

How do I access a shared folder in Virtual Box under an Ubuntu guest?

I use Virtual Box everyday and love it. One of its nice features is the ability to expose the host's file system to the guest OS. When running an Ubuntu Linux guest, however, you need to make a few hand tweaks to get the shared folder to automatically mount.

First, we need to test that we can mount the folder by hand. Examine the shared folder settings of your VM to find the name of the share. Mine has the very original name of share. Create a directory that will be used as the mount point for the shared folder. I created ~/vbox. Finally, mount the shared folder to the Ubuntu file system using the following command:

sudo mount -t vboxsf share ~/vbox

Do an ls of ~/vbox to verify that your shared files exist. If you do an ls of the mount directory, you'll notice that it is owned by root which could be a problem if you try to write to that folder. We need to fix that. Unmount the share using sudo umount ~/vbox/ so we can make some adjustments. Remount the shared folder using a slightly different set of options: sudo mount -t vboxsf -o uid=1000,gid=1000 shared ~/vbox. In this variant, I specified my account's user and group ids. Now the directory is mounted with the proper permissions.

I want this done automatically each time I boot up, so I placed the following in my /etc/rc.local file:

mount -t vboxsf -o uid=1000,gid=1000 RKurr /home/rkurr/vbox/

I have to use the fully qualified path to the mount point because the root user will be running the command and ~ will not expand correctly.