Wednesday, April 27, 2011

Overdrive for Android: Mobile Library

Mobile ebooks have been around for a while but are gaining popularity with the proliferation of tablets and smart devices.  Depending on where you live, your local library may have different selections, options or may not use Overdrive at all.  
For example, my library card works in two library systems: One system has many more titles than the other, and only one system offers audio books.


Installation
My library's website wasn't particularly clear on how to get ebooks on my Android device.  Here's how I did it:

  1. Locate OverDrive Media Console in the Android marketplace and install it
  2. In OverDrive Media Console, tap the phone's menu button
  3. Tap the Get Books icon in OverDrive
  4. Tap Add a Website.  Search for your library branch and tap the star next to it to add it to your favorites (the "Get Books" list in OverDrive parlance).
  5. Tap your location, login and browse!



Finding media
You may find it easier to browse content on a desktop/laptop/netbook, especially if you use a mobile device.  See your library's website for details.
For both of my libraries, the non-mobile web interface had a limited list of subject categories to search by default (e.g., no Technology or Science).  I found more categories by clicking "Browse by Subject".
As a taxpayer for (and, hopefully, charitable contributor to) your local library system, feel free to contact a librarian for further assistance.


Kindle coming soon?
Currently the Kindle (hardware and apps) is not supported by OverDrive.  Looks like this is changing this year.

Thursday, April 14, 2011

Using JMX to dynamically change application properties

http://java.sun.com/developer/technicalArticles/J2SE/jmx.html


I had an application that reads some non-standard debug settings from a properties file at startup -- when one wanted to change the settings the application server needed to be restarted.  In a production environment, restarting the application server is not an option.  I implemented JMX on the logging class so that JConsole can be used to modify the settings.


The class in question is a singleton so I created a helper class since the MBean interface methods cannot be static.  The singleton instantiates the agent with its static load() method.

Wednesday, April 13, 2011

Changing Mozilla profile location

My C:/ drive was running out of space so I wanted to relocate my local Thunderbird messages to D:/.  Almost as simple as copy/paste:
http://kb.mozillazine.org/Thunderbird_:_FAQs_:_Changing_Profile_Folder_Location

Tuesday, March 8, 2011

Cygwin clear command: Ctrl+L

Since I keep forgetting it, I'm posting it: Ctrl+L replaces the clear command when you're using Cygwin.


http://hafizpariabi.blogspot.com/2008/02/no-clear-command-in-cygwin-default.html for more (including alternatives like installing ncurses).

Monday, March 7, 2011

Ruby in Practice: Regular expressions

Helpful Ruby regular expression cheat sheet
http://www.tutorialspoint.com/ruby/ruby_regular_expressions.htm
Manipulating file contents with regular expressions in Ruby
http://snippets.dzone.com/posts/show/2595


I don't often need to work with regular expressions -- and when I do I usually use regex search and replace in Eclipse or Notepad++.  Today, however, I had a requirement that was harder to address with search and replace.  A great opportunity to try my new Ruby skills.
I needed to take something like this:

...
   <outer>
      <message-driven id="GreenPepper_sub_1" initialState="running" />
      <message-driven id="Habanero_sub_1" initialState="running" />  
      <message-driven id="Avacado_sub_1" initialState="running" />
...
and replace it with this:

...
   <outer>
      <message-driven id="GreenPepper_sub_1" initialState="running" />
      <message-driven id="GreenPepper_sub_2" initialState="running" />
      <message-driven id="GreenPepper_sub_3" initialState="running" />
      <message-driven id="Habanero_sub_1" initialState="running" />   
      <message-driven id="Habanero_sub_2" initialState="running" />   
      <message-driven id="Habanero_sub_3" initialState="running" />   
      <message-driven id="Avacado_sub_1" initialState="running" />
      <message-driven id="Avacado_sub_2" initialState="running" />
      <message-driven id="Avacado_sub_3" initialState="running" />
..

There were three other differently-formatted files which required a similar change -- in all several hundred lines making manual cut and paste an uninviting task (especially considering the number of typos I was likely to make with so many changes).  Basically, take a line with "_sub_1" and add a few duplicate lines afterward replacing "_sub_<n>"with "_sub_<n>" where <n> is 2 or 3.
As with most one-off utility scripts I didn't want to spend two hours doing one hour's worth of work, so I didn't super-optimize the script, but it worked great.  You can see that some of the files had lines with "channel 1" which required a similar change.  This one script worked great for all files:


# script to add extra lines to rib-*-adapters-resources.properties
#                          and rib-*-adapters.xml
# for multi-channel

def replace_in_file(filename="D://rib//file4.txt", match="tafr_1")
  File.open(filename, "r") {|f| lines = f.readlines
    lines.each {|line|
      puts line
      if line =~ /#{match}/
        replace line, match
      end
    }
  }
end

def replace(line, match)
  (2..3).each {|i|
    tempLine = line.to_s.gsub(match, match[0..match.index("_1")]+"#{i}")
    tempLine = tempLine.to_s.gsub("channel 1", "channel #{i}")
    puts tempLine
  }
end

Saturday, February 26, 2011

Windows XP won't recognize CD in drive

Windows fails to recognize a CD that has been placed in the drive.  The drive spins for a bit, but nothing appears for the CD drive in Windows Explorer.  Zune software will also not show that a CD is in the drive.


I run this to fix it:
http://support.microsoft.com/mats/cd_dvd_drive_problems/en-us

Sunday, January 30, 2011

Tether the Samsung Captivate running Gingerbread (2.3)

Using the Gingerbread Ultimate ROM I was able to get my phone to serve as a wireless access point for my Windows XP laptop and to provide connectivity via tethering.
I was impressed with the ease of use and pretty pleased with the speeds.  I didn't have to do anything special to get this work.  Just followed the instructions in the Android 2.3 manual for the Nexus S.  One hiccup: I did have to restart my laptop after untethering before I could get the connection back.  Note: I'm getting HSPA instead of 3G most of the time.  


Here are the speedtest.net stats:
Captivate as Wireless AP (phone connected to network HSPA but not WiFi)
download: 2.06 mbps
upload: 0.58 mbps
ping: 346
Captivate on WiFi tethered to PC

download: 9.06 mbps
upload: 2.46 mbps
ping: 43
Captivate on HSPA tethered to PC
download: 3.16 mbps
upload: 1.20 mbps
ping: 159