2010-03-21

Installing Mythbuntu backend on Virtualbox virtual machine running on Mac OS X

This is just a rough outline of steps, not a how to!

Install Sun Virtualbox on Mac.

Download ISO of Mythbuntu

Create new Linux virtual machine in Virtualbox. I used 8 GB as the disk size (figuring I would store recordings on an external drive) and 500 MB RAM (no particular reason.

Change settings on the virtual machine's Details list:

  • Click on Storage then under the CD-ROM entry browse to and select the Mythbuntu ISO.
  • Click on Network and then select bridged as the network type instead of NAT (I actually did this after the Mythbuntu install was finished so I am not sure if there would be problems selecting it intitally).
Boot up the virtual machine and go through the Mythbuntu basic install process. I chose to install both a frontend and a backend even though I am not planning to watch recordings on the virtual machine; I did this because I believe some settings are only accessible through the frontend. Other than that I think I just accepted all the defaults.

When it got to the part of the process when the Mythbuntu backend setup program ran I escaped out of it to get to the desktop because I wanted to make some changes to the system before I set up the backend.

Set the virtual machine to use a static IP address:
  • Right click on the network manager icon on the right side of the virtual machine menu bar and selecting edit connections.
  • Select Auto eth0 under Wired
  • Click Edit
  • Select IPv4 Settings
  • Enter values in all fields; Apply button will grey out unless all required fields are completed.
  • Click Apply
Set up the virtual machine to use an external hard drive (for storing recordings).
  • Shut down virtual machine.
  • Go to Details list for VM and click on Shared Folders
  • Browse to external drive and designate it as a shared folder.
  • Install VirtualBox Guest additions on the VM by:
  • Restart VM
  • Click on the Window for the VM to make it active, and then on the Mac menubar click on Devices and then select Install Guest Additions (if the VirtualBox program window is the active window you can't see the Devices menu). This causes a virtual CD to be mounted to the VM.
  • Follow the instructions How to install VirtualBox Guest Additions in Ubuntu with the following changes: run the installer by using "sudo ./VBoxLinuxAdditions-x86.run" otherwise you will get command not found.
  • Reboot VM.
  • Test mounting external hard drive by making mount point and then running this:
  • sudo mount -t vboxsf SharedFolderName \MountPointPath where SharedFolderName is the name you gave to the shared folder in VirtualBox and \MountPointPath is the path to the mount point you created.
  • However, if you mount the shared folder this way it will be mounted as owner root, group root and read only.
  • Dismounting the shared folder and setting the ownership and permissions on the mount point doesn't work to change this because the next time you mount the shared folder the ownership, group, and permissions will revert.
  • This is the mount command that finally made it possible to write to the shared folder: sudo mount -t vboxsf -o uid=andy,gid=users SharedFolderName /MountPointPath/
  • Once I got that working I added it to the /etc/fstab file so that the shared folder would mount on boot by using sudo nano /etc/fstab to open the fstab file in a text editor and then adding this to the bottom of the file SharedFolderName /MountPointPath vboxsf gid=105,uid=103
  • The uid and gid are for the user mythtv and the group mythtv. I tried mounting it with uid=1000 and gid=1000 but mythbackend was not able to write recording files to it, so I just made mythtv the owner of the mount.
Once I got the shared folder working properly I finally ran Myth Backend Setup (Applications -> System -> Myth Backend Setup). Here are the fields that I set differently than the default:
  • General-Host Address Backup Setup-Local Backend-IP Address = static IP address of VM
  • General-Host Address Backup Setup-Local Backend-Security Pin = 0000
  • General-Host Address Backend Setup-Master Backend-IP Address = same
  • General-Locale Settings-Channel frequency table = us-cable (selected)
  • Capture Card Setup-Card type = HDHomeRun DTV tuner box (selected)
  • Capture Card Setup-Available Devices = 1019A9DB-0 (selected)
  • On Input Connections I scanned channels using Cable High.
  • After the channel scan was done and I added all the ATSC channels I used the Channel Editor to manually fill in the XMLTV ID field for each high def channel. For some reason SchedulesDirect.org doesn't link up to the high def channels correctly, so I just fill in the XMLid values for the broadcast versions of the channels, which I looked up on SchedulesDirect.org
  • Then I went to the Storage Groups section, clicked on default, and then filled in the mount point of my shared folder as the default storage location.
Unfortunately, the shared folder approach was too slow, and when I tried to play back recordings stored on the shared folder the video keep halting and stuttering. So it was on to plan b.

I shut down the VM and then in VirtualBox I disconnected the shared folder from the VM by clicking on Details - Shared Folders and then removing the shared folder.

Next in VirtualBox I created a new virtual disk on my external hard drive and made it as big as I could. I picked expandable, instead of fixed, because when I tried fixed it said it would take 20 hours to format the virtual disk!

Then in VirtualBox I attached the new virtual disk to my VM and then started the VM up. From there I used regular linux commands to partition and format the new virtual disk, and then I added it to the /etc/fstab file so it would mount on boot to the same mount point as I had previously used for the shared folder (and obviously I removed the old /etc/fstab entry for the shared folder while I was in there.

Then I did a sudo mount -a to mount the new virtual drive and tested it by recording a show in MythTV, and everything worked great.


    mjpg-streamer documentation

    The documentation for mjpg-streamer is kind of scattered about.  I have dumped it all here for my own convenience.

    Usage introduction

    This example shows how to invoke mjpg-streamer from the command line

    export LD_LIBRARY_PATH="$(pwd)"
    ./mjpg_streamer -o "output_http.so -w ./www"

    pwd echos the current path you are working at, the backticks open a subshell to execute the command pwd first the exported variable name configures ldopen() to search a certain folder for *.so modules

    export LD_LIBRARY_PATH=`pwd`

    This is the minimum command line to start mjpg-streamer with webpages for the input-plugin default parameters are used

    ./mjpg_streamer -o "output_http.so -w `pwd`/www"

    To query help for the core:
    ./mjpg_streamer --help

    To query help for the input-plugin "input_uvc.so":
    ./mjpg_streamer --input "input_uvc.so --help"

    To query help for the output-plugin "output_file.so":

    ./mjpg_streamer --output "output_file.so --help"

    To query help for the output-plugin "output_http.so":
    ./mjpg_streamer --output "output_http.so --help"

    To specify a certain device, framerage and resolution for the input plugin:

     ./mjpg_streamer -i "input_uvc.so -d /dev/video2 -r 320x240 -f 10"

    To start both, the http-output-plugin and write to files every 15 second:

    mkdir pics
    ./mjpg_streamer -o "output_http.so -w `pwd`/www" -o "output_file.so -f pics -d 15000"

    To protect the webserver with a username and password (!! can easily get sniffed and decoded, it is just base64 encoded !!)

    ./mjpg-streamer -o "output_http.so -w ./www -c UsErNaMe:SeCrEt"

    If you want to track down errors, use this simple testpicture plugin as input source. To use the testpicture input plugin instead of a webcam or folder:

    ./mjpg_streamer -i "./input_testpicture.so -r 320x240 -d 500" -o "./output_http.so -w www"

    Usage: mjpg_streamer

    mjpg_streamer
      -i | input "<inputplugin.so> [parameters]"
      -o | output "<outputplugin.so> [parameters]"
     [-h | help ]........: display this help
     [-v | version ].....: display version information
     [-b | background]...: fork to the background, daemon mode

    Note: If you start mjpg-streamer in the background use this to stop it:
    kill -9 `pidof mjpg_streamer`

    Example #1:
     To open an UVC webcam "/dev/video1" and stream it via HTTP:
      mjpg_streamer -i "input_uvc.so d /dev/video1" -o "output_http.so"

    Example #2:
     To open an UVC webcam and stream via HTTP port 8090:
      mjpg_streamer -i "input_uvc.so" -o "output_http.so -p 8090"

    Example #3:
     To get help for a certain input plugin:
    mjpg_streamer -i "input_uvc.so help"

    In case the modules (=plugins) can not be found:
     * Set the default search path for the modules with:
       export LD_LIBRARY_PATH=/path/to/plugins,
     * or put the plugins into the "/lib/" or "/usr/lib" folder,
     * or instead of just providing the plugin file name, use a complete
       path and filename:
       mjpg_streamer i "/path/to/modules/input_uvc.so"

    Parameters for input_uvc.so

    This is the output from:
      #mjpg_streamer --input "input_uvc.so --help"

    The following parameters can be passed to this plugin:

     [-d | --device ].......: video device to open (your camera)
     [-r | --resolution ]...: the resolution of the video device,
                              can be one of the following strings:
                              QSIF QCIF CGA QVGA CIF VGA
                              SVGA XGA SXGA
                              or a custom value like the following
                              example: 640x480
     [-f | --fps ]..........: frames per second
     [-y | --yuv ]..........: enable YUYV format and disable MJPEG mode
     [-q | --quality ]......: JPEG compression quality in percent
                              (activates YUYV format, disables MJPEG)
     [-m | --minimum_size ].: drop frames smaller then this limit, useful
                              if the webcam produces small-sized garbage frames
                              may happen under low light conditions
     [-n | --no_dynctrl ]...: do not initalize dynctrls of Linux-UVC driver
     [-l | --led ]..........: switch the LED "on", "off", let it "blink" or leave
                              it up to the driver using the value "auto


    NSLU2 + Debian Lenny + wireless + webcam

    My webcam is a HP KQ246AA 8.0MP Deluxe Webcam
    First I installed Debian on my NSLU2 following this guide:

    http://www.cyrius.com/debian/nslu2/install.html

    Then I connected my HP Webcam (purchased because it is supposed to be UVC compatible) and ran dmesg | tail and it looked like it was recognized.

    I tried installing mjpg-streamer using aptitude, but it said there was no package by the name in the repositories.

    I then downloaded the tar.gz file from the mjpp-streamer sourceforge site:

    http://sourceforge.net/projects/mjpg-streamer/files/

    I had no idea what to do with it, so I double-clicked on it on my Mac OS X desktop, which uncompressed it to a directory.  Inside that directory was a file called README which had the following instructions:

    To compile and start the tool:
    tar xzvf mjpg-streamer.tgz
    cd mjpg-streamer
    make clean all
    export LD_LIBRARY_PATH=.
    ./mjpg_streamer -o "output_http.so -w ./www"
    So I used Macfusion to connect my Macbook to the NSLU2 as root and copied the tar.gz file over to the NSLU2.  Then I ran the tar xzvf command, which created a directory called mjpg-streamer-r63.  I went into that directory and ran make clean all, but that gave me a command not found error.

    So I used aptitude to install the make package, and tried again.  This time it ran for a bit and then gave me an error that gcc wasn't found.  So I used aptitude to install the gcc package, and tried again.

    This time I got a bunch of errors related to jpeg_utils. Looking at the README file I saw this:
    "In case of error: the input plugin "input_uvc.so" depends on libjpeg, make sure it is installed."
    So I tried aptitude install libjpeg, but that gave me an error saying there was no such package, but listed the names of some packages with similar names.  I took a chance and installed libjpeg-dev, figuring that sounded the most promising. Aptitude then said it was installing a different package with 62 in the name.

    After the 62 variation of libjpg was installed I ran "make clean all" again and it seemed to finish without any fatal errors, but lots of warnings.

    However when I tried to run it I got this error:
    ./mjpg_streamer -o "output_http.so -w ./www"
    MJPG Streamer Version.: 2.0
     i: Using V4L2 device.: /dev/video0
     i: Desired Resolution: 640 x 480
     i: Frames Per Second.: 5
     i: Format............: MJPEG
     o: www-folder-path...: ./www/
     o: HTTP TCP port.....: 8080
     o: username:password.: disabled
     o: commands..........: enabled
    Unable to start capture: Cannot allocate memory
     i: Error grabbing frames
    I figured this meant there wasn't enough memory so I went to this web page I had found about Debian on the NSLU2:

    http://www.sunspot.co.uk/Projects/SWEEX/slug/notes/Debian_notes.html

    And tried his recommendation:
    "If you are not using IPv6, you can prevent the module from being automatically loaded by adding the line
    blacklist ipv6
    to /etc/modprobe.d/blacklist."
    And then rebooted using "shutdown -r now"

    Then by running the export command again, and going into the mjpg-streamer directory I was able to get it to work; pointing firefox at port 8080 of the IP address of the NSLU2 worked.

    Then I decided to try and install mjpg-streamer in the system itself so I wouldn't have to run it from the folder where I made it, and have to run the export library thing every time.  But I had no idea where to put the files.  So I downloaded the Ubuntu deb package from the mjpg-streamer Sourceforge site, and ran dpkg-deb -c (I think) to get a list of the tree structure of the files, and then I copied the files from my install folder to those folders on my system (I had to make one new folder /usr/www).

    Then I was able to run the program from any prompt just using mjpeg-streamer without any ./ etc. but it kept giving me unable to start capture: Cannot allocate memory errors and exiting.  Interestingly, I was still able to run it from the install folder putting ./ before the name, at least once, but then even that didn't work. So back to trying to open up more memory.

    I went through the ideas listed here:

    http://www.cyrius.com/debian/nslu2/reducing-memory.html

    I couldn't find any libdevmapper1.02 in /etc/init.d so I couldn't do that idea.

    Then I started reviewing kernel modules shown by lsmod.  The first one, evdev, appeared to just be used for managing input devices for X.org, so I went to the blacklist file:
    nano /etc/modprobe.d/blacklist
    and added "blacklist evdev"  (no quotes) to the end of the file and rebooted. evdev no longer appears when I run lsmod.

    Next I tried blacklisting both usbhid and hid modules since they seem to be for mouses. Slug still boots.

    It seems that the ixp4xx_beeper module is for making the NSLU2 beep. I guess I won't blacklist it yet.

    Then I moved on to reducing the services (daemons?) loaded when the system starts.  This page mentioned a package called rcconf to change the services loaded.  It is apparently a utility that shows you what is loaded and allows you to specify what gets loaded and what doesn't.  So I installed it using aptitude.

    Using rcconf I turned off the following:
    • exim4 (apparently for handling email)
    • mountnfs.sh (I am guessing its for the NFS file system)
    • nfs-common (same guess)

    After all that, now I am able to run mjpg-streamer from any command prompt:
    mjpg_streamer -o "output_http.so -w /usr/www"
    Note that all the mjpg_streamer commands below are for the way I manually installed it on my system.  To get them to work on a machine where mjpg_streamer wasn't manually installed you will have to modify the command to match the syntax in the original instructions.

    Next issue: the streamer stops working if you end the terminal session where you launched it.  So time to try this idea from this web page:

    "there is an option in mjpg-streamer to launch it in background, use it as a daemon:
    [-b | --background]...: fork to the background, daemon mode"
    So this lets me keep using the ttyS0 terminal -
    mjpg_streamer -i "input_uvc.so -r 960x720" -b -o "output_http.so -p 8080 -w /webcam_www"
    Note:- to make mjpg-streamer exit cleanly, use -
    kill -9 `pidof mjpg_streamer`"
    It works! After I launched mjpg-streamer with the -b option it continues running after closing the SSH terminal session.
    kill -9 `pidof mjpg_streamer`

    Seems to shut it down successfully.

    Now to explore options. Here is the output from mjpg_streamer --help
    Usage: mjpg_streamer
      -i | --input " [parameters]"
      -o | --output " [parameters]"
     [-h | --help ]........: display this help
     [-v | --version ].....: display version information
     [-b | --background]...: fork to the background, daemon mode
    -----------------------------------------------------------------------
    Example #1:
     To open an UVC webcam "/dev/video1" and stream it via HTTP:
      mjpg_streamer -i "input_uvc.so -d /dev/video1" -o "output_http.so"
    -----------------------------------------------------------------------
    Example #2:
     To open an UVC webcam and stream via HTTP port 8090:
      mjpg_streamer -i "input_uvc.so" -o "output_http.so -p 8090"
    -----------------------------------------------------------------------
    Example #3:
     To get help for a certain input plugin:
      mjpg_streamer -i "input_uvc.so --help"
    -----------------------------------------------------------------------
    In case the modules (=plugins) can not be found:
     * Set the default search path for the modules with:
       export LD_LIBRARY_PATH=/path/to/plugins,
     * or put the plugins into the "/lib/" or "/usr/lib" folder,
     * or instead of just providing the plugin file name, use a complete
       path and filename:
       mjpg_streamer -i "/path/to/modules/input_uvc.so"
    I am having a heck of a time finding any documentation on the syntax.  I found this forum post:

    mjpg_streamer -i "input_uvc.so -r 320x240 -f 6" -o "output_http.so -p 8080"  -b

    Which I modified to:

    mjpg_streamer -i "input_uvc.so -r 320x240 -f 6" -o "output_http.so -w /usr/www" -b

    That seemed to work to reduce the resolution, but how to increase it?

    After looking at the webcam specs I tried:

    mjpg_streamer -i "input_uvc.so -r 800x600 -f 20" -o "output_http.so -w /usr/www" -b

    But it still gave me a 640x480 image. I am giving up in trying to get a higher resolution for now.

    On to wireless.  I have a Belkin USB wifi adapter that uses the rt73usb driver which is built into Debian Lenny.

    I followed the directions here on how to set up a rt73 wireless device on Debian Lenny:


    http://wiki.debian.org/WiFi/rt73

    Everything seemed to go smoothly.

    I had a lot of troubles getting the wifi to connect to my network, but I think most of it was because I was trying to use the wrong wpa2 password (i.e. psk).  After I used the right wpa psk it worked using the following /etc/network/interfaces file:

    auto wlan0
    iface wlan0 inet dhcp
            wpa-ssid Chacala
            wpa-psk mywirelesspassword

    That is, I was able to get it working while the ethernet cable was also plugged in.   I could connect SSH to the IP address assigned to the wireless connection while the ethernet cable was plugged in, but once I unplugged ethernet the wireless connection dropped.  I did some googling and discovered this hint on this page:

    "If everything looks like it's working, don't just unplug your ethernet. use "ifconfig eth0 down" beforehand, otherwise you'll loose both connections."

    Once I followed that hint the wireless link stayed alive after I disconnected the ethernet.

    So next I tried rebooting with ethernet unplugged and just the wifi adapter.  The Slug appeared to boot, and the LED on the wireless was flashing, but I couldn't ping or SSH to the Slug.  So I connected the ethernet cable again, but I still wasn't able to ping or SSH to the Slug.  So I rebooted with both the wifi adapter and ethernet connected, and after reboot I was able to ping and ssh to both wifi and ethernet IP addresses.

    Next I tried a hint from this page:

    "Actually there's a strange behavior of networkingon NSLU, when i boot without the ethernet cable plugged, in the wlan interface is also not working.
    When i replug the ethernet cable, the wireless network also comes up. When i ifconfig eth0 down and unplug the ethernet cable the wlan does still work.
    Strange, after some meditation on the interfaces file I noticed the commented line # The primary network interface and had the idea to just change the sections for the interfaces, so lets wlan0 be my primary interface and eth0 an additional one."

    i.e. he swapped the order of eth0 and wlan0 in /etc/network/interfaces to have wlan0 come first.  I changed the order in my interfaces file and rebooted.

    It worked! After reboot I was able to connect to the Slug through the wireless connection with no ethernet cable attached.  Here is the final /etc/network/interfaces file that worked:

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto wlan0
    iface wlan0 inet dhcp
            wpa-ssid mywirelessnetworkname
            wpa-psk mywirelesspassword

    allow-hotplug eth0
    iface eth0 inet dhcp

    Now onto having the camera and the USB wireless adapter connected at the same time using a hub.

    I shut down the Slug, and then connected both the webcam and the wireless adapter using a cheap USB hub I had purchased from Walmart years ago on a trip.

    After reboot I was able to connect to the Slug via wireless

    Next I tried running the camera:

    mjpg_streamer -o "output_http.so -w /usr/www

    It works! I now have a wireless webcam.

    Poking around looking for something else, I discovered that the following command will list all of the supported modes of the webcam:

    lsusb -v

    Looking at this it seems that the only streaming mode higher than 640 x 480 is 1280 x 1024, which I haven't tried before, so I tried it:

    mjpg_streamer -i "input_uvc.so -f 1 -r 1280x1024" -o "output_http.so -w /usr/www"
     And here is what I got:

    MJPG Streamer Version.: 2.0
     i: Using V4L2 device.: /dev/video0
     i: Desired Resolution: 1280 x 1024
     i: Frames Per Second.: 1
     i: Format............: MJPEG
     o: www-folder-path...: /usr/www/
     o: HTTP TCP port.....: 8080
     o: username:password.: disabled
     o: commands..........: enabled
    Unable to start capture: Cannot allocate memory
     i: Error grabbing frames
    The good news is that it didn't reject the resolution saying it wasn't found.  The bad news is the memory error. On to troubleshooting the memory error.  dmesg shows a log of error messages, starting off with:
    mjpg_streamer: page allocation failure
    [42951766.100000] mjpg_streamer: page allocation failure. order:5, mode:0x1
    After a lot of googling it seems that this is some flavor of running out of memory, and one possible solution is to set overcommit to 2. Apparently you do that by running this command:
    echo 2 > /proc/sys/vm/overcommit_memory
    So I did. But I still got the Cannot allocate memory error when I tried to launch the streamer! Even after rebooting.

    Then I decided to try blacklisting the audio modules from the kernel:

    nano /etc/modprobe.d/blacklist

    And then added the following line to the bottom of the file
    blacklist snd_usb_audio
    After I rebooted I checked lsmod and it looked like all the sound modules that had previously been loading were no longer loading, and free showed about 6 MB free memory with no use of swap. But still get a memory error trying to run mjpg-streamer!

    Then I had a brainstorm.  Free showed no swap being used the first time I ran it after boot, but it should more swap being used, and more memory free, after I tried and failed to run mjpg-streamer, so maybe it would run now that some programs had been moved to swap?  So I tried again, and success! The Slug is now streaming 1280 x 1024 at the rate of 1 frame per second!  Here is the command I used to get the high resolution streaming:
    mjpg_streamer -i "input_uvc.so -f 1 -r 1280x1024" -o "output_http.so -w /usr/www"
     The new USB 2.0 hub I ordered (Belkin USB 2.0 4-Port Ultra Mini Hub F5U407  Belkin USB 2.0 4-Port Ultra Mini Hub F5U407) arrived from Amazon.  I bought this because it was under $10 and had good ratings on Amazon.  I plugged it in, hooked the webcam and the wifi dongle up to it and rebooted.  I hung on the first reboot, so I rebooted with nothing connected and then added the new USB hub by itself, then the webcam, and then the wifi dongle, and things worked that time.

    The picture quality from the webcam seems much better with the USB 2.0 hub.  I suspect the webcam automatically detects when it is hooked up to a 1.1 hub earlier and jacks up the compression on the video stream to compensate.

    Next up: reduce wear on flash drive. I bookmarked some pages about this in the Firefox NSLU2 folder.

    2010-02-16

    Notes on using Google Maps to show hiking trails

    I have been working on using Google Maps to show the routes of various hiking trails in my area. It can be done, but it's not very straightforward. Here are cursory notes on what I learned in the process (i.e. this is not a detailed how-to).

    Initially I used Google "My Maps." Here are the characteristics of Google "My Maps" relevant to mapping hiking tails:

    • Google "My Maps" displays the length of a path when you click on it, which is good for showing people how long a trail is.
    • You can upload a GPX track to it by the roundabout method of importing the GPX track into Google Earth and then exporting it from Google Earth as a KML file, which you can then import into Google My Maps. Or you can use the GPS Visualizer web site to convert GPX files to KML files: http://www.gpsvisualizer.com/
    • Unfortunately Google My Maps has a limit on the number of placemarks and lines it will display at one time. If you add exceed this number of items Google My Maps will automatically bump some of your items to a second page so that it is impossible to see everything at once.
    • Another unfortunate characteristics of Google My Maps is that it apparently has a limit on the number of points that can be in a single line. If you exceed this limit Google My Maps will split the track into two lines of the same color. I searched for a long time and couldn't find any work around. See: http://www.google.com/support/forum/p/maps/thread?tid=7d6964088b224b32&hl=en
    There is a workaround to avoid having your placemarks/lines broken up into multiple pages if you have a lot of them. This workaround also gets around long tracks being broken up into multiple lines. You can display a KML file using Google Maps by entering the http address of the KML file in the search box of Google Maps. When a KML file is displayed this way there is apparently no limit on the number of items that can be displayed (or at least the limit is higher). Also, when you display a KML on Google Maps using this method your long tracks/lines will not be broken up into separate lines.

    If you don't want to upload a KML file to a web server to display it you can also display all the items of a Google "My Maps" map that has too many items to fit on one page using this trick. Just right click on the View in Google Earth link in My Maps to get the http address of the KML file, and then enter that in the search field in regular Google Maps. I have seen forum postings that some people have had problems with this, so posting a KML file to a web server may be the most reliable approach.

    I decided to go with uploading my KML file to a web server and then searching for its URL in Google Maps. Once I that I faced the choice of whether to continue to use Google My Maps to edit my KML and then export the KML file, or to use Google Earth to edit the KML. Although both Google Earth and Google My Maps are awkward to work with if you have a lot items, I decided to go with Google Earth.

    The problem with using Google Maps to render a KML file is that you don't get distance measurements on the length of lines. I decided to work around that by uploading my KML to Google My Maps and then clicking on tracks/lines there to find out the distance. There is also this hand web site that will tell you the length of a Google Earth track/line: http://www.emaltd.net/google/gec/utilities/index.asp?l=en

    2009-11-29

    How to download KML data from Google My Maps

    I had put a lot of time into a particular custom map under Google "My Maps" and I wanted to make an offline backup of the data. I clicked on the "View in Google Earth" button when viewing my Google "My Maps" map and it downloaded a KML file which I could open in Google Earth. However, when I opened the KML file in a text editor I saw that it didn't contain any actual map data but instead just had a http URL pointing back to Google Maps. After some experimentation I discovered that I could download the actual map data by taking the URL from inside the downloaded KML file and changing each instance of "&amp;" into plain old & and then pasting the edited URL into my browser address bar. This returned a real KML file with real data.

    Incidentally, you can display a KML file on Google Maps by uploading the KML file to any webserver and then putting the http address of the file in the Google Maps search box and hitting enter. Google maps will then display the KML file placemarkers and paths on Google Maps.

    2009-09-11

    How to convert Microsoft Word documents to clean HTML

    I often want to take a MS Word document that someone has sent me and convert it to HTML so that I can distribute it to others via the web rather than emailing it around to people. MS Word has built-in HTML conversion, but the resulting HTML is so ugly, confusing, and bloated, that it is very hard to work with if I want to do edits or tweak formatting.

    Here is my current favorite method for converting Microsoft Word documents to clean HTML using Gmail:

    1. I email the document to my Gmail account.
    2. When I view the email in Gmail there is a "View as HTML" link provided for the attachment, which I click to see the Word document displayed in my web browser.
    3. At the next screen click the View link in the upper left, which brings up a menu of viewing options. Choose Plain HTML.
    4. Then with the document showing in my browser I go to view page source (Firefox for Mac = View -> Page Source) on my browser, which shows me the underlying HTML, which I block and copy into a new file in a test editor.
    The HTML produced by Gmail is very old school (it doesn't use CSS and probably half the tags it uses are deprecated), but it is very compact, clean, and consitent, so you can quickly convert it to more modern HTML using search and replace.

    2009-07-30

    Transact SQL for including concatenated text fields in WHERE clause

    I am working with a database on an SQL Server that carries forward a legacy table structure where the description field for a Purchase Order line item is spread across multiple text columns in the table.  In other words, instead of having one 250 character text field for the item description it has a total of 7 text fields of (I think) about 25 characters each.  I have a web application where users can search for purchase orders using the description fields.  My original solution was to check for the user's search term across each of the seven text fields using OR clauses.  However, this meant that a user's search term would not be found if it happened to straddle the border between two of the seven fields.

    To solve this problem I tried concatenating all of the description fields and then testing the concatenated string using LIKE, but that resulted in some POs not being inlcuded in the results when they should have been.  I finally puzzled out that what was happening was that database treated empty description fields as null and Transact SQL gives a null value for the whole concatenation if you try to concatenate a number of valid string values with one null value.  In other words if you concatenate Field1 + Field2 + Field3, and the first two fields have text in them, but Field3 does not, then Transact SQL will give you a null result.  So the solution was to use ISNULL to convert null description fields to zero length strings when concatenating them for the WHERE clause, so that one null value doesn't ruin the whole concatenation, like so:

    WHERE Field_1 + ISNULL(Field_2,"") + ISNULL(Field_3,"") + ISNULL(Field_3,"") LIKE %search-term%

    2009-06-16

    Easy Find is a great free alternative to Spotlight for finding files

    I usually give my files long and meaningful names, so to find stuff I just need a tool that will quickly and easily let me do a wildcard search on just file names.  I tried a few times, but I was never able to figure out how to do that kind of search using Spotlight.  I finally came across a free application called Easy Find from Devon Technologies that is optimized for the kind of searching I need.  Its pretty bare bones, but it does exactly what I want to be able to do.

    2009-06-12

    Applescript to give a primative command line interface to MS Word 2008

    One of the things I hate about MS Word is having to use the mouse to click through menus to do simple things. Of course you can create keyboard shortcuts for stuff, but I find it hard to remember really complicated keyboard combos. What I prefer is the old XyWrite approach, which is to hit a command key, then enter a two or three letter code for an action, and then hit enter to have it execute.

    Back when I was using Word 2000 for Windows I found a simple solution: Create a keyboard shortcut for the Run Macro command (Ctrl-M), and then write macros with 2-3 character names. For example: I wrote a macro to accept all revisions in a document, then named it 'aa' (for accept all). Then to accept all revisions all I had to do was hit Ctrl-M, type aa, hit enter, and boom, all the revisions were accepted.

    When I switched to Mac OS X and Word 2008 for Mac I couldn't find any obvious way to recreate this functionality, so I suffered through clicking through menus for a lot of commands. However, one day I just reached my limit with click-click-click-click and decided to find a solution using Applescript. Here is what I ended up with:

    -- Open a dialog box for user input
    set var_input to display dialog "Word command: " default answer ""
    -- For some reason you need to do this to get the user input into a string variable
    set var_input to (text returned of var_input) as string
    -- Applescript apparently doesn't have SELECT CASE statements so use If Else to take different
    -- actions based on user input
    if var_input = "st" then
        -- Convert selected text to strikethrough font
        tell application "Microsoft Word"
            set strike through of font object of selection to true
        end tell
    else if var_input = "aa" then
        -- Accept all changes in the document
        tell application "Microsoft Word"
            accept all revisions active document
        end tell
    else if var_input = "kt" then
        -- Toggle keep text together (so text doesn't break over page break)
        tell application "Microsoft Word"
            tell selection
                if ((keep with next of paragraph 1 as boolean) is false) then
                    set keep with next of every paragraph to true
                else
                    set keep with next of every paragraph to false
                end if
            end tell
        end tell
    else if var_input = "uc" then
        -- Convert the selected text to all UPPERCASE
        tell application "Microsoft Word"
            set case of characters of selection to upper case
        end tell
    end if
    What this does is open up a dialog box where you can type in a string of characters, and then based on what you entered it tells MS Word to do some command or other.

    Then I saved the Applescript in the folder:
    Users/myusername/Documents/Microsoft User Data/Word Script Menu Items

    With the name:
    Command Line\cM.scpt

    Although its not at all obvious, the \cM.scpt at the end creates a Ctrl-M as a keyboard shortcut for the Applescript. For more on naming Applescripts in this folder so they have keyboard shortcuts see:

    http://www.entourage.mvps.org/script/add_shortcuts.html

    Its for Entourage, but the script naming conventions appear to be the same.

    2009-06-04

    How to make keyboard shortcuts for Accept Revision and Next Revision in Microsoft Word 2008 for Mac

    I find the native interface for working with tracked changes in MS Word 2008 to be unbearably clumsy. You have to turn on the Reviewing toolbar and then click an icon to get to the next tracked change, then click another icon to accept the change, and then repeat, which gets to be quite a clickapalooza with a long document with lots of changes.

    I prefer to hit one keyboard shortcut to move to the next tracked change, then hit another keyboard shortcut to accept the change. For some reason Microsoft didn't bother to include these keyboard shortcuts. To set them up:

    • Choose View -> Customize Toolbars and Menus
    • Click the Keyboard button
    • In the Categories box select Tools
    • In the Commands box select AcceptChangesSelected
    • Click in the box for "Press new keyboard shortcut" and then hit your preferred key combo. Be sure not to use a combo that is already assigned to something because it just won't work.
    • Click the Assign button.
    To make a keyboard shortcut to jump to the next tracked change just repeat, but this time select NextChangeOrComment in the Commands box.

    I also like to have a keyboard shortcut for toggling track changes off and on. For that select ToolsRevisionMarksToggle in the Commands box.

    2009-05-26

    Batch file with ampersand in its name won't run under Windows Task Scheduler

    I wrote a batch file to run a simple script and then tried to schedule it using the Task Scheduler in Windows Server 2003, but for some reason it just wouldn't run a scheduled, even though I could run it with no problem by double-clicking on the batch file name.

    After banging my head against the wall for a while, I finally tried taking the ampersand out of the name of the batch file, and suddenly Task Scheduler was able to run it.

    2009-05-22

    Copying all the files that match a certain pattern in a directory structure over to a single directory

    For a long time I have wanted to collect all the files matching a certain pattern (Inv*.pdf) from a directory structure and copy them all to a single directory.

    A Windows utility, xxcopy, has a command line switch to do exactly this.

    I also found a forum discussion on how to do it in both Windows and *nix. And another one just about Windows.

    With xxcopy the command line syntax to do what I wanted is:

    xxcopy d:\contract\inv*.pdf d:\procurement\invoices\ /SG /BI

    The /SG switch tells it to recursively (i.e. including from subdirectories) copy all of the files matching the wildcard pattern to the single target directory (i.e. without recreating the subdirectories under the target).

    The /BI switch only copies files that either do not exist in the target directory or are newer versions of existing files.




    How to use Windows Task Scheduler to copy files from a server in another domain

    My problem was that I wanted to do a nightly transfer of files froma Windows machine in another domain to my Windows Server 2003 machine.The script to do the file transfer was easy, but I couldn't find a wayto keep the remote server mapped as a network drive. If I mapped thedrive through the GUI and clicked "Reconnect at Logon" it wouldn'treconnect after the server rebooted. Possible part of what made itdifficult was that the remote server was in a different domain and Ihad a different credentials on the remote server.

    I figured out a way to permanently map a network drive to the remote server in a different domain, but then I discovered that batch files run using the Task Scheduler do not see any mapped network drives. Apparently network drives are only mapped to drive letters for real interactive sessions, and a user's network drives are not mapped when you run run a Task Scheduler job as that user.

    After poking around a bit I found that the solution was to enter my credentials for the remote server in the Stored User Names and Passwords (Start button -> Control Panel -> Stored User Names and Passwords) utility on the local server. Apparently if you do that, whenever the local machine tries to access a resource on the remote machine Windows automatically uses the stored credentials to log into the remote machine.

    So, once I entered my credentials to the remote machine in Stored User Names and Passwords I then mapped a drive letter to that machine in the first line of the batch file like so:

    net use n: \\servername\volumename /persistent:no

    And then used that drive letter for the copy command in the batch file.

    UPDATE 2009-09-04. Somehow my entries in Stored User Names and Passwords on a Windows Server 2003 machine vanished overnight. When I went into the Stored User Names and Passwords GUI application from the Control Panel and re-entered my credentials using the format "\\10.10.10.1\sharename" for the server name the stored credentials wouldn't work when I tried to access shares on remote servers. I then opened a DOS prompt and tried this:

    net use \\10.10.10.1\sharename /savecred

    which resulted in prompts for me to enter my user name and password, which I did. After that new entries showed up in the Stored User Names and Passwords panel access through the Control Panel, and the stored credentials worked when I tried connecting to remote servers. I did notice that the new entries created through the/savecred method used just 10.10.10.1 as the server name, with no slashes and no share name, so maybe that was the problem all along.

    2009-05-20

    How to permanently map a network drive to a machine on another domain in Windows Server 2003

    After a lot of trial and error trying different combinations of switches on the net use command, here is the network drive mapping method that resulted in a drive mapped to a remote machine in a different domain using different credentials that will survive a reboot of the local machine.

    At a command prompt I ran:
    net use h: \\server\folder /savecred /persistent:yes

    I was then prompted to enter my username and password for the remote server, which I did. The drive was then successfully mapped, and the drive was still mapped after the machine was rebooted.

    2009-05-06

    How to create a Mac OS X keyboard shortcut to print to PDF

    I was getting sick and tired of having to go to the mouse to click the PDF button from the Mac OS X print dialog every time I print a web page to PDF (which is really the only "printing" I do anymore). I googled around and found this awesome tutorial about how to set up a keyboard shortcut for this that I never would have figured out on my own in a million years:

    Keyboard Shortcut for “Save as PDF…” in OS X at macsparky.com

    This only gotcha I ran into is that you have to enter "Save as PDF..." with "as" in all lowercase in order for it to work. Entering "Save As PDF..." doesn't work.

    2009-03-16

    Backing up Google calendar using wget for Mac OS X

    Back when I was on Windows I used wget to download the iCal file of my Google calendar as part of my nightly backup.  I am finally getting around to adding it to my Mac backup script.

    First step; Does Mac OS X have wget built in? Doesn't appear to.

    I found wget for Mac OS X Leopard on Quentin Stafford-Fraser's blog and followed the installation instructions in the readme file.

    The readme file says you will need to add the folder where you put wget to the PATH, so I googled and found these instructions on how to do that:

    • Create the file /etc/paths.d/wget like this: sudo touch /etc/paths.d/wget
    • Edit the file: sudo nano /etc/paths.d/wget
    • Put the path inside the file: /usr/local/bin

    Then I looked up the http address of my Google Calendar iCal file by going to Calendar Settings and clicking on the iCal button in the Private Address area near the bottom.

    Then I went to Wget manual at gnu.org and figured out the syntax for what I wanted to do:

    wget -P /Users/myusername/Documents/Google_Calendar_Backups http://www.google.com/calendar/ical/mygoogleusername@gmail.com/private-randomlettersandnumbers/basic.ics

    And then I tested it in a bash script, and when I verified it worked I added it to my regular nightly backup bash script.

    2009-02-25

    Finally found a way to create a browseable archive of Thunderbird folders

    For literally years I have been looking for a way to create an archive of a Thunderbird folder that is easy to access without having to import it back into Thunderbird.  In other words, I want to be able to share a whole email with someone without having to print each email, etc.  I finally found a Thunderbird Add-on that allows me to highlight all the emails in a folder and then with one click output all of the emails as individual HTML files along with an index html file which lists the Subject, To, From, and Date for each email and has a link to each individual email file.


    ImportExportTools (MboxImport enhanced)

    I have probably spent a total of 10-15 hours over the years looking for ways to do this, so it is quite a relief to find something that appears to work!

    2009-01-09

    Where Cisco VPN Client for Mac hides profiles

    My connection profile (pcf file) for my Cisco VPN Client somehow got corrupted (it magically lost my group authentication password) so I had to copy over a backup copy of my profile.  It took me a while to puzzle out where the profiles are stored on a Mac, but its:

    /etc/CiscoSystemsVPNClient/Profiles

    2008-12-22

    Configuring my new Macbook White

    Why a Macbook?

    I decided to indulge myself and get a laptop, and of course it had to be an Macbook. In practical terms Windows is really just fine, and there is more and better opensource software for Windows, but after years of working with, and being frustrated by, the awkwardness and goofiness of Microsoft and Windows, not to mention the mysteries of viruses, worms, trojans and bears, oh my, there is so much bad history between me and Windows that I just can't bring myself to buy another Windows computer ever again.  The trust has been broken, and even if Windows produced a flawless OS that spontaneously made breakfast for me every morning I would still have an atavistic reluctance to give it a try.

    For me, Mac OS X just feels solid and well designed. Kind of like the difference  between American made cars and Japanese cars back in the 80s and 90s (less so today).  One feels just kind of clobbered together with lots of stuff you have to work around or learn to live with, and the other feels like a well oiled machine. Even though there are lots of practical inconveniences to using a Mac (I still haven't found a file manager I like as much as Salamander for Windows, or a text editor as good as Notepad+), most everything is so well designed and solid feeling that I am willing to forgive its shortcomings.  With Windows there is so many years of negative history between us that every little thing that goes wrong reminds me of 10 other stupid battles I fought with Microsoft over the decades and I end up seething even if its really not that big a deal in practical terms.

    Why Macbook White instead of a new Macbook?

    I chose a 2.4 Ghz 2.0 Gig RAM Macbook White, instead of one of the new Macbooks, because it seemed like more bang for the buck when I was comparing the various sales on Black Friday. Sure the new Macbook is sexier, but I just couldn't bring myself to pay about $200 more for a slightly less powerful machine, especially given the super glossy screen on the new Macbook (which looks brighter, but is a real pain if you have any light sources behind you).

    Tricking it out

    In any event, this post is really about what I did to configure my new Macbook White. There is nothing I enjoy more than customizing and tricking out a new computer so its just the way I want.  I am like those guys who spend every weekend working on their hobby hotrod that they never actually get around to driving much. Whenever my wife complains about my computer obsession I tell her she should be greatful that she doesn't have to deal with a perpetually partially disassembled Camero in the carport.

    The first thing I did after getting to the desktop was let it do all the Mac software updates.

    Set up link to my home file server Samba Share

    Mac OS X automatically detected my home Samba fileserver.  To make it easier to access regularly I opened it up on Finder and then dragged the top level folder of the fileserver over to the bottom of the Places list on the Finder Sidebar.  Now its just one click to get to my documents on the fileserver.

    In order to have the fileserver mounted automatically when I boot up I went to System Preferences -> Accounts -> Login Items, clicked the plus sign underneath the list, navigated my way to the top level documents folder on my Samba server in the File Open dialog, and hit Add, then checked the box next to the entry for it on the list of items to open automatically on log in.

    Installed Firefox and copied over my existing Firefox profile

    I fired up Safari, went to the Firefox site, and then downloaded and installed Firefox, since thats the browser I am used to.

    I copied my Firefox profile from my regular personal computer over to my file server, then copied it from there to the Firefox profile directory on the Macbook (/Users/andy/Library/Application Support/Firefox/Profiles/xhikl3o34.default) while Firefox was shutdown, of course, and then restarted Firefox.  This gave me an exact duplicate of my existing Firefox configuration from my old computer.

    Fixed the problem where you can't reliably tab between form controls in Firefox on Mac OS X

    After I installed Firefox I noticed that I could no longer tab between controls on a form on a web page.  For example, I couldn't hit the tab key and get to the submit button on one form I used a lot.  I did some googling and found this post about it:

    Tabbing problems in Firefox in Mac OS X

    Following a tip in the comments on this page, I opened up about:config in Firefox, then right clicked on the list and selected New > Integer from the context menu, then gave accessibility.tabfocus as the name of the new Preference and gave 3 as the value.  Then I restarted Firefox and I could tab between controls on forms like I was used to.

    Trimmed down and moved the Dock to the right hand side

    I like an uncluttered desktop, so I got rid of almost all of the default application icons on the Dock by simply dragging them away from the Dock and letting go.  I left the icons for Finder and iTunes.  Then I used Finder to navigate to /users/Andy/Applications and dragged Firefox, Terminal, and System Preferences over to the Dock since those are the programs I use the most frequently.

    It seems crazy to me to have the Dock on the bottom of the screen on a widescreen monitor on a laptop, since there is lots of horizontal real estate but vertical real estate is limited.  So I went to System Preferences -> Dock then chose Right for Position on Screen, set the Size on the small end of the scale, and set Magnification to Max. This gives me a non-3d Dock on the right hand side of the screen that doesn't take up much space. Its not as pretty, but I hate having a narrow sliver of webpage showing because 20% of the vertical space of the desktop is taken up by the Dock.

    Installed Quicksilver

    I hate using a mouse to navigate through tree structures, and I hate peering at long lists to find things in folders, so I am always on the lookout for tools that will let me jump to what I want by typing a few characters of the name.  A while ago Lifehacker turned my on to Quicksilver which does this for opening applications for the Mac (it does a lot more that I haven't begun to explore).  So I went to the Quicksilver homepage:

    http://www.blacktree.com/

    I downloaded the latest beta of Quicksilver, and then installed it. Then to make it load on startup I went into System Preferences -> Accounts -> Login Items, hit the plus sign under the list, navigated to Quicksilver in /Users/Andy/Applications, cliked Add, then checked the box for the new Quicksilver entry on the startup list.  Now, to open an application I just hit Control-Spacebar to invoke Quicksilver, start typing some of the applications name, and then hit enter when it has selected the right app (usually only takes 2-3 keystrokes).

    Tweaked Finder

    Finder is the thing I like least about Mac OS X, but I have worked out a number of tweaks that make it more to my liking.

    I like to have the full path of the current directory showing in the title bar of Finder, so I opened up a terminal and ran this:

    defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
    killall Finder

    Also, I enabled the Path Bar at the bottom of the Finder window by going Finder > View > Show Path Bar.  The Path Bar at the bottom allows you to jump to anywhere in the current path.

    For some reason I hate being told a file's date is "today" or "yesterday" so I turned that off by going Finder > View > Show View Options, which pops up a dialog where you can select what stuff Finder shows about files, and unchecked the "use relative dates" option. While I was in there I checked the "Calculate all sizes" option so Finder will show me the sizes of folders. Then I clicked "Use as defaults" to make these options apply to all folders.

    Installed muCommander for two pane file manager

    There are two things I want to be able to do when managing files that Finder doesn't do: (1) allow me to jump to a particular file name by any fragment of the name (not just the beginning), and (2) copy files from one folder to another with one keystroke instead of a lot of clicking and mousing.  I have looked around a lot, and the only file manager I have been able to find that does both on Mac OS X is the opensource muCommander. I was initially resistant to trying it because its Java based, and when you first fire it up it doesn't look very sexy, but its performance is actually pretty snappy. Another advantage from me is that it uses a lot of the Norton Commander style keyboard shortcuts that I am used to (F7 to make folder, F5 to copy, Enter to open a file, etc).

    Here is the feature I like the most about muCommander. If I am in a folder with dozens of files I can just start typing some characters I think are in the file name somewhere. The letters I type show up at the bottom of the muCommander window with a little red exclamation point icon if they are not found, and a green check mark icon if they are found.  If the characters are found in a filename it jumps to the first instance, and if you then hit the up or down arrows it jumps to the previous or next instances.  I am not sure why every file manager doesn't have a feature like this.  Certainly trying to find a string of characters in a file name in a particular directory is a bit of a clickapalooza in Finder.

    Set the system date format to ISO 8601

    I have this thing for using ISO 8601 date format exclusively, so next stop was System Preferences -> Formats to change all the date formats.  I selected Custom for Region, then clicked customize, then went through Short, Medium, Long, and Full formats and changed them all to read 2008-11-23 by dragging and dropping the date elements.

    Put the date on the Menubar

    I like to have the full date (ISO 8601 of course) showing on the Menubar, so I followed this Lifehacker post by Gina showing how to do it:

    Mac Tip: Display the Date on the Menubar

    It looks complicated, but its really pretty easy. After I did that, I right clicked on the clock on the Menubar and selected 24 hour time, and now it says "Fri 2008-12-05 13:33" on my menubar.

    Installed TinkerTool and tweaked font smoothing options

    I don't like the default font smoothing choices on Mac OS X, especially when I have a non-Apple external monitor attached.  So I downloaded and installed TinkerTool which allows you to set font smoothing so that it is turned off for fonts under a certain size (with no cap on the cut-off size you set).  I set the font-smoothing size at 14 pt.

    Installed and configured Synergy for running multiple computers with one keyboard and mouse

    When I am at work (which is a shed off my carport) I like to have my personal computer sitting next to my work computer for my calendar, personal email, this blog, etc., and I like to control both my work computer and my personal computer with one keyboard and mouse.  A while ago I discovered this amazing opensource program called Synergy2 that works on Windows, Mac, and Linux and allows you to control any number of computers with one keyboard and mouse. Once you have it installed and configured properly on all your computers the mouse and keyboard seamlessly shift from one computer to the next when you move the cursor off the edge of one monitor in the direction of the next computer.  You can even block and copy text (not files I don't think) between the different computer desktops.  After using it for a while you almost forget that you are dealing with multiple computers; It all just seems like one big desktop.  In any event here are the Synergy2 links:

    Synergy2 home page (with Windows and Linux downloads)

    SynergyKM home page (Synergy for Mac)

    Configuring Synergy can be very very confusing, so I am not going to cover it here, but you can use google to find help.  Once its configured it works so flawlessly I almost forget its there, so its worth struggling through the confusing configuration proces. Right now, while I am configuring my Macbook, I am temporarily using Synergy to control a Windows 2000 machine (2 monitors), and Mac Mini, and the Macbook, with one keyboard and trackball connected to the Windows machine.

    Set up easy access to file systems on remote computers over SSH using MacFUSE and Macfusion

    I have an Xubuntu server running on an old laptop that functions as a file server, home web server, and  print server.  I like to be able to transfer files to and from it (outside of the Samba share) quickly and easily, so I downloaded the two opensource tools necessary to mount other computer's filesystems over SSH: MacFUSE and Macfusion.

    Before I proceeded with installing and configuring these programs I wanted to tell my Macbook the names of all the computers on my home network so that I would be able to work with them by name instead of IP address.  I couldn't find a way to do it without using the terminal.  So I fired up the Terminal and opened up the hosts file using the nano editor:

    cd /
    cd etc
    sudo nano hosts

    Then I just appended the names and IP addresses of all my various machines to the file, hit Ctrl-O to save it, and then Ctrl-X to exit.

    MacFUSE is a Google project that provides other programs a way to mount non-native filesystems on a Mac. I don't think it can do anything by itself. Once you download it and install it you need to install some other program that has been written to work with a particular filesystem.

    Macfusion is a program that uses MacFUSE to mount filesystems over SSH, and it is really slick.  I  downloaded it from the site, unzipped the app, dragged the app over to the Applications folder, and then ran it.  It said that its agent wasn't running and asked if I wanted to run it, and there was a checkbox to have the agent run at log in.   I said yes and yes and then ran Macfusion again from the Applications folder.  This brought up a cryptic blank dialog box with only a plus sign and gear icon buttons on the bottom. To add my home server I clicked the plus button, selected SSHFS (SSH filesystem), which brought up a dialog where I entered the name (see above) of the machine I wanted to connect to in both the top unlabelled box and the hosts box, and entered my password for that machine in the password field and hit enter. Then I was back at the original dialog, but now there was an entry for the machine I had just entered, with a Mount and Edit button.  I clicked Mount, but I got an error.  I suspected that the problem was that MacFUSE might not really function until after a reboot, so I just restarted the Macbook, then opened up Macfusion from Applications and tried again, and this time it mounted the SSHFS mount without problems.

    But where was the mount? Macfusion just tells you the remote machine's filesystem has been mounted.  It doesn't tell you how the heck to find the mount.  It doesn't show up on your desktop, it doesn't show up on the Sidebar in Finder. Where in the world is it?

    I knew from trial and error on my Mac Mini that Macfusion mounts the remote filesystem under /Volumes, but its not obvious how to get to /Volumes on Finder in its default configuration (at least I could never find a way).  What I did discover is that if you open Finder, go to Preferences -> Sidebar, then check the box for "Computer" in the Devices section, you will get a new entry under Devices in the Finder Sidebar with your machine's name. If you then click on your machine's name, you will see a folder that lists Macintosh HD, Network, and then your Macfusion SSHFS mount (and any other mounts you have going).

    Once you can find your SSHFS mount point you can navigate the remote computer's filesystem using Finder, and work with its files, pretty much just the same as any other file on the Mac.  I find this really handy when I am working on PHP code on my home web server.  Just mount the web server using MacFusion, then navigate to the web root on the server and open the file using a text editor and get to work.

    I did one last Macfusion tweak.  I started it up again using Quicksilver (it doesn't show up in the Dock by default), then went to Preferences and checked the box for starting the Macfusion menu item when I log in.  This puts a little icon on the Menubar for Macfusion (one you reboot), which makes mounting a remote machine's file system as easy as clicking on the Menubar icon, choosing Favorites and then clicking the name of the machine. Pretty slick.

    Tweaked Terminal

    Since I use the Terminal a lot I took some time to customize it since I hate the microscopic font size and appearance it uses by default.  I started up Terminal, went to Preferences, and then on the Startup tab I selected open new window with settings Homebrew. Then I went to the Settings tab and customized the font, and font size for Homebrew to my tastes. The only thing that was a little cryptic was how to make the Terminal window opaque instead of the semi-transparent default.  I discovered that if you select the Window tab under the Settings tab, and then click on the little square of color just under the Background label it brings up a dialog where you can set opacity.

    Installed Plain Clip and set hot key combo to remove formatting from the clipboard

    99% of the time when I copy some text from one application to another I just want the words and not the formatting.  For some odd reason the default copy and paste behavior (in both Windows and Mac) is to include the formatting.  I set up a keyboard shortcut to strip the formatting off of whatevers in the clipboard by:
    • Downloading and installing Plain Clip in the Applications folder.
    • Running it once from the Applications folder to get over the "This program was downloaded from the internet" warning.
    • Clicked on my Quicksilver Menubar icon, then selected Triggers to open up the keyboard shortcut configuration pane.
    • Hit the plus sign at the bottom of the pane to add a new trigger.
    • In the Command dialog I selected Plain Clip as the Item (first box) and Open as the Action (second box) and clicked Save.
    • Then I clicked on the Trigger field to open the Trigger dialog, and then hit my preferred key combo in the Hot Key box and then closed the pane.
    • Then to test I copied some formatted text from a web page into another application, confirmed that it was including formatting by default, then hit by defined keyboard shortcut and pasted again and confirmed that the formatting had been stripped out.
    Installed VMWare Fusion and Windows XP

    I have a Microsoft Access application I wrote way back in 1997 that I still use from time-to-time, plus I have a scanner that I never figured out how to get working with Mac OS X, so I purchased VMWare Fusion 2.0 from Amazon.com and a Windows XP Home OEM install disk from Newegg.com and then installed VMWare Fusion and created a Windows XP virtual machine using the install disk from Newegg.com.

    Stopped by www.opensourcemac.org for the rest of the basic applications I use

    www.opensourcemac.org is a great place to find all of the major opensource applications for the Mac.  What follows are the ones I downloaded and installed from this site.

    Applications: Smultron for text editing

    I do some PHP coding and edit various text files while messing around with my Linux machines, so I need a decent text editor (free or opensource of course).  I have tried various ones out there, and right now I am using Smultron and have been pretty happy with it so far. Its not as good as the best freeware Windows editors, but its the one for Mac that I like the best. One really nice feature is that you can choose Open Hidden from the File menu and then get a file open dialog that shows all the hidden files and directories on the Mac, which is very convenient when you are tweaking the Mac.

    Applications: Installed VLC media player

    A while ago I wanted to be able to start playing an internet radio stream on my Mac Mini just by going to a bookmark of the stream in Firefox.  I couldn't figure out how to get iTunes to automatically start playing the stream when I opened it in Firefox, but it worked out of the box with VLC. So, I downloaded and installed VLC on my Macbook, went to the site of my local PBS station and clicked the link to play the stream, VLC opened (after clicking through some one time only warnings about software downloaded from the internet) and the radio started playing. Nice.

    Applications: Installed Burn for burning CDs and DVDs

    Burn worked great for me the few times I used it on my Mac Mini so I added it to my Macbook.

    Applications: Installed NeoOffice for word processing and spreadsheets

    NeoOffice is OpenOffice optimized for Mac OS X.  It takes a while to load, but once its running it has worked well for me for spreadsheets and occasional Word documents.

    2008-12-17

    Accessing a Truecrypt encrypted external drive that uses the ext3 filesystem from Mac OS X

    As covered in another post, I have a laptop home file server set up that stores its files on two external drives that are encrypted using Truecrypt and which use the ext3 filesystem. One of my goals of that project was to be able to grab one of the external drives and be able to read it from another computer (i.e. so I am not hosed if the laptop dies).

    I was pretty confident that I could meet my goal by just firing up an old laptop that has Xubuntu installed, so I didn't even test that. However, I wanted to be able to read my encrypted external drives using my new Macbook.

    After lots of googling I couldn't find any program that would allow mounting an ext3 filesystem directly on Mac OS X. Maybe its out there, but I couldn't find it. So, it was on to plan B, which was to install a VMware Fusion Xubuntu virtual machine on my Macbook and use that.

    I fired up VMware Fusion and went to File > New and then followed the wizard for setting up a new virtual machine. I already had the ISO file for Xubuntu 8.04 desktop, so I told it to use that instead of a CD. I went with the quick install option (I think that was the name) and everything went very smoothly with setting up the virtual machine.

    After I got to the Xubuntu desktop I did a system update to bring it up to date, then I downloaded the Truecrypt installer for Ubuntu from the Truecrypt website, unarchived it, and then ran the installer script which worked without any hitches.

    Then I logged onto my home file server using SSH and dismounted one of the encrypted drives using truecrypt -d /media/truecrypt2, then disconnected its USB cable, then its power, moved it over to my Macbook, plugged it into power, and then plugged in the USB cable. At that point Mac OS X gave me a dialog about not being able to mount the drive and I clicked the ignore button. Then I went to the Xubuntu virtual machine window and clicked the little USB icon on the bottom to connect the external drive to the virtual machine.

    Then I fired up a terminal in the Xubuntu virtual machine and checked /dev for the external drive by running ls sd*. I saw there was an sdb and sdb1, and I guessed that that was the external drive, so I then ran truecrypt /dev/sdb1 /media/truecrypt1 to mount it and entered the password for the drive at the prompt

    I then went to the Xubuntu file manager and navigated to /media/truecrypt1 and verified that I could open files on the external drive.