Monday, January 31, 2011

Send to Kindle Extension to Chrome Browser

About a month ago I switched over to Google Chrome for web browsing, and I'm very happy I did. And recently a friend made me aware of the "Send to Kindle" Chrome extension. I wasn't sure how much I'd use this extension, but I installed it anyway. I find I use it a lot. It makes sending an article on the web to the Kindle a snap, and I miss it when the only option to view an article in its entirety is PDF which the extension won't send automatically to the Kindle.

But why would I want to read anything on the Kindle that I can read in my web browser? First of all, I very often want to read things of interest later. Sending the article to my Kindle lets me read it when I'm relaxing in the evening or at other convenient times. Second, the Kindle is great for reading period. It's not a great web browser, it's not a phone, but it's just great for reading. As I read it's so easy to look up unfamiliar words and add to my vocabulary. It's easy to add notes. And for longer articles, it keeps my place so I can pick up right where I left off. With my busy schedule that's important. And it keeps things "in my queue." When I read them, I either save them to some collection if they are that good or delete them and they're gone. My reading is efficient and organized.

cygwin shutdown command

cygwin (http://www.cygwin.com/) is a treasure trove of handy utilities for Windows machines -- especially useful for those of us who prefer the Unix/Linux systems but still have to use Windows. The "shutdown" command is particularly handy. My home PC is running Linux, but I "remote desktop" using the "rdesktop" into my wife's Windows machine all the time. Sometimes when I'm done I want to shut the remote machine down. That's easy with the cygwin "shutdown" command: "shutdown -s -f now" and it's on its way to shutdown without my having to walk over to it, get its attention, request a shutdown, confirm that I really really do want to shut it down, and finally start the process.

Saturday, January 22, 2011

a2pdf: Convert ASCII to PDF

I was looking for an easy way to convert text files to PDF, and a2pdf is pretty cool. I did discover one issue with multi-page documents on an HPUX server: if --nofooter or --nopage-numbers are given on the command line and exception is raised. I found that if I allow the footer with a page number, it works file. I've reported this to the developer, and if I get a response, I'll post it here. It's a pretty awesome application. See also: http://perl.jonallen.info/projects/a2pdf

Chase Bank Android Application

I tried the Chase Bank Android Application. Their mobile banking web site had always worked well. The app looks nice, but it has two issues as far as I'm concerned:

  1. Every time you switch back to the app it wants you to log in again. So, if you take 2 seconds to switch over to text messaging, password management, anything, you'll be asked to log in again. That's not very practical as far as I'm concerned.
  2. The only reason I was curious about this app was for check deposits. But the app would not recognize the dollar amount on the handwritten check,
I probably won't get much use out of this app for now at least.

Sunday, January 16, 2011

Simple Wealth/Inevitable Wealth Book

This is definitely not a technical how-to, but the book I'm writing about is absolutely a how-to book. And I do highly recommend a book that my accountant recommended (whom I also highly recommend: Jason Marsden, CPA): Simple Wealth/Inevitable Wealth by Nick Murray. This is one of those books that as I read it I find myself wishing I'd known this stuff a long time ago. However, had I read this book a long time ago, would I have been ready to learn from it? Possibly not, but the time for me has come. Mr. Murray brings this subject down to earth, makes a good case for mutual funds, but never really attempts to say it's his way or the highway. I like that. And I'm the type of person who has to know "why" before I believe it. Murray tells me why. And he explains things in such a way as to make everything very understandable. If you get the book, get the latest edition you can. It's not that important, because the principles won't change over time, but even so.

I also like the funds that my CPA recommended. They've done very well. I was impressed by the history of the company and their funds dating back to the great depression: American Funds. Mr. Marsden was right on to recommend this company, and the mix of funds he recommended for me have done very well. However, as Mr. Murray writes, the particular fund itself is less important. Nevertheless mine have done well in the past few months. But also as Murray points out: it's the long term not the short term that matters.

Friday, January 14, 2011

Saving a PDF file in Google Chrome: Work Around

There are times when it seems that I cannot save a PDF file that I'm viewing in Chrome. Sometimes the option just isn't there. I'm finding however that if I right click on the document I'm viewing and select "Open Frame in New Window," once the new window is open I can right click on the document and use "Save As." I've use this several times already to save my pdf. And it saves me going back to Firefox, and that's a good thing.

Tuesday, January 4, 2011

Ruby Find: The Pleasure of Ruby

I was a Perl enthusiast years ago when I could hardly convince anyone at my company to do Perl. They were using C and many of them were darn good at it. A number of years after I left they were bringing Perl experts in to train the staff. Perl had finally gained acceptance. But over the years I grew tired of Perl's cobbled in object orientation, it's penchant for making last minute runtime decisions about what it thought I intended my code to do, and just how easy it really was to write obfuscated Perl without really trying.

A few years ago I discovered the pleasures of Ruby (along with Ruby on Rails) and most recently I've been getting to know JRuby which lets me make Java easy by adding the power of Ruby. Why is Ruby so cool? Number one in my book is its rich set of libraries. Perl used to claim that it made difficult things possible, but Ruby very often makes difficult things easy. Take a simple recursive "find" for example: traversing various directories until you've got all of them listed along with all their content listed. It's not trivial, and there are lots of samples out there of how to do it. But why not do it the easy way. Life's too short, just use Ruby Find.The documentation for this Ruby module is sparse simply because there's not much to it. It's easy!

The other day I used two calls to find to very quickly compare mounted volumes of content and found another tidbit that was worth its weight in gold at the time: "lstat()" Now most any unix or linux programmer knows about stat(). It's been around a very long time. I used it years ago in C code. Back then it returned a structure with all sorts of tidbits about some file or directory or link or whatever. Things like the last modified date, file size, etc. Perl and Ruby have continued to offer its equivalent. The purpose of my code was to see if any file or directory on a target "mirrored" system had changed to a symbolic link on the source system or vice version. Without thinking I used "stat()" But as I was checking my results I noticed that "stat()" was returning statistics on the object the symbolic link was linked too. That's not what I wanted at all. Immediately my mind began thinking how to work around this annoyance when I discovered lstat() and found that the Ruby folks had anticipated my problem. That method does not follow the link, it returns statistics on the link, and that's exactly what I wanted. In particular I wanted to know the file system type. I wanted to compare the file system types on the two file systems and see if they were different.

That's the pleasure of Ruby: again and again I find I can be more productive and have more fun because the Ruby folks have anticipated my needs.

And there are few things better than ActiveRecord, but you won't find that documentation simple or easy. That object does way too much. But in the end it makes accessing database records a snap.

Here's my compare() method in which I use Ruby's Find module:


class Array
  # convert a hash to an array ...
  def to_h
    Hash[*enum_with_index.to_a.flatten]
  end
end

require 'find'

 def compare
    whoami = "compare"
    debug.debug(whoami,__LINE__,"Source: \"#{self.source}\"")
    debug.debug(whoami,__LINE__,"Target : \"#{self.target}\"")


    my_source = get_contents(self.source)


    my_target = get_contents(self.target)


    my_source.keys.sort.each do |path|
      if path and path.strip != ""
        if my_target.has_key?(path) # The source path is found in the target


          source_path = File.join(self.source,path)
          target_path  = File.join(self.target,path)
          if File.exists?(target_path) # The target path still exists. It's possible we already removed it if it's down in some directory


            # Note the use of "lstat()" which does not follow the last link, instead it stats the link itself, which is what we want!
            source_type = File.lstat(source_path).ftype
            target_type = File.lstat(target_path).ftype


            unless source_type == target_type
              debug.debug(whoami,__LINE__,"(path,source_type,target_type) = (#{path},#{source_type},#{target_type})")


              if self.remove
                if target_path =~ /^media\// # Special sanity check
                  debug.debug(whoami,__LINE__,"Removing: \"#{target_path}\"")
                  begin
                    File.delete(target_path)
                  rescue Errno::EISDIR
                    system("rm -r -f '#{target_path}'")
                  end
                else
                  throw "Too dangerous to remove: '#{target_path}'"
                end
              end
            end
          end
        end
      end
    end
    debug.debug(whoami,__LINE__,"Done")
  end



  private


  # Get the contents for a directory ...
  def get_contents(dir)
    list = Array.new
    Find.find(dir) do |path|
      if File.readable?(path) # If it's not readable, just skip it, example" ~/.gvfs
        list << path[dir.length .. path.length] # We only want the relative path, not the full path, so we get rid of the parent directory name
      end
    end
    return list.to_h
  end



KDE 4: Grouping/Ungrouping Programs in the Panel

I used to be rather annoyed that my various Wine programs or Java programs where all lumped together under one tab on the control panel. Then I happened to notice that if I right click on the group and choose "Do not allow this program to be grouped," I no longer saw Quickbooks lumped in with IE 7 or Freeplane lumped with Netbeans. That was easy, and it's just as easy to undo that by right clicking and choosing "Allow this program to be grouped."

I will say that grouping can be handy when there are so many programs running at once. Bu when all the Java programs are lumped together or all the Wine ones, it's a pain. But it's easily solved in KDE.

Freemind and Freeplane

I used to create all sorts of various documents that were nothing more than lists usually in outline form. Then a friend told me about Freemind -- "mind mapping" software. I tried it and liked it. I used it for years. Then I found Freeplane and liked it even better. Freeplane is a "fork" of the Freemind project and maintains file compatibility with the original Freeplane. So it was easy for me to just start using it.

The bottom line is that Freemind and Freeplane have enabled me to easily keep listed notes (usually how to's) in mind-map form. Each node is a topic and each sub node elaborates on that topic with any number of sub nodes on top of that. This is as incredibly useful as it is simple. For example:


  • Windows
    • Canon Printer Ink Type
      • Start->Printers
      • Right click on the printer and choose properties
      • Then the maintenance tab
      • Then the view printer status button
      • Then the ink details tab
    • Windows 2008
      • add/remove programs
        • control panel->programs and features
      • single click to open files and folders
        • My Computer->Open
        • Pull down "Organize" tab->Folder and Search Options, and right in front of you from the general tab, select single click
      • change your login picture
        • control panel->user accounts, choose the account, change the picture (or start and click on your icon right there)
You get the picture, except what you see is this outline in mind-map mode. I'll not try to reproduce the look and feel here. And I've found this format wonderfully practical and useful.

Amazon Kindle: E-mailing Documents to the Kindle

I got an Amazon Kindle from Santa this year. I'd been reading Kindle books for months on my Droid Eris smart phone. I wasn't sure I'd like the real deal, but I really do. One of the features of the Kindle is that you can e-mail documents to your Kindle. Your Kindle is assigned an e-mail address, <something>@kindle.com, and if you e-mail documents to that address they will be downloaded to your Kindle. OK. May be useful some day I thought. But now I find myself finding techie and other articles on the web, printing them to PDF, and e-mailing them to my kindle with the subject "convert." That asks Amazon to convert the document to a full-fledged Kindle format. Without conversion the Kindle can browse a PDF. But I rather like the Kindle format. And I'm finding I'd rather read this stuff at my leisure on my Kindle than on the web. Further I can create collections of the ones that are worth saving. It's kind of like subscribing to magazines that aren't yet available on the Kindle. I can optionally zip up a group of documents and just attach the zip file. Amazon will sort it out and convert each one of the zipped up files.

Be aware that if you use this feature, the e-mail you send from must be listed with Amazon. Log into your Amazon account, navigate to the page where you manage your Kindle, and add the e-mail address(es) or Amazon will dump your submission into the bit bucket.