2009-07-31

Dropbox - An excellent online backup/sync solution.

Some time ago, I stumbled upon Dropbox: an online sync and backup application for Linux, Windows, and Mac.  You install the client and it creates a directory on your machine.  All the files you put into that directory and uploaded the Amazon S3 cloud.

You can install the application on multiple computers.  When you log in to one, Dropbox connects to your account and updates any changes.

It's very convenient for keeping notes and backups that I'd like handy where ever I log in.  They also have a very nice web interface for places where I can't install the client.

It's free to sign up (for 2GB).  If you use my referral link (https://www.dropbox.com/referrals/NTgxMDE5OQ) to sign up, we'll both get an extra 250MB of storage.

NOTE: 2010-03-13, Updated Dropbox Referral Link (new web site).

2009-04-27

Cleaning up old thumbnails in Gnome.

Introduction

I take many pictures, and have been moving them around quite a bit. I noticed that the ~/.thumbnails directory (where Gnome stores thumbnails) was getting large. So, I looked into it.

Condensed Background

Gnome has a backend thumbnail management system. Imagable files are hashed (based on the file URI) and the thumbnail is kept in ~/.thumbnails in a file based on that hash. The file is a PNG file that includes some text chunks with meta data. One such meta data item, is the 'Thumb::URI' chunk, which includes the original file URI: if you md5 hash the string of that path, you'll get the file name of the thumbnail.

My Solution

Instead of just nuking all the thumbnails and letting them get recreated. I created some scripts to only delete files that no long have a corresponding real image file (e.g. the file pointed to by Thumb::URI). The main one, findbadthumbnails, looks through all PNGs in the thumbnail directory, gets their Thumb::URI chunk, then sees if the file exists. It it does not, then the path to the thumbnail PNG is output. These can then be deleted.

As a helper, I created another little script called cleanthumbs that looks at the size of the thumbnail directory, runs 'findbadthumbnails | xargs -r rm', and then checks to the size of the thumbnail directory again. If it's different then the "before" and "after" values are printed.


findbadthumbnails

#!/bin/bash
#
# $Id: findbadthumbnails 492 2009-04-26 18:59:20Z grover $
# $URL: svn://svn.kevingrover.net/play/trunk/python/pictures/findbadthumbnails $
#
# 2009-04  Kevin Grover <kevin@kevingrover.net>
#
# Find (and print the filename) of bad Gnome Thumbnails.
# A bad thumbnail is one that references a URI that does not exist.
#
# If you use a lot of removable media and you want your thumbnails to
# remain, this utility does not current support that: all thumbnails
# will be removed unless the media is mounted at the time this script
# runs.
#
# Requires:
# - exiftool (to read the Thumb::URI text chunk from the PNG files)
# - getopt (normally present)
# - find (normally present)
#
# ToDo:
# - -i,--ignore=pattern   URI pattern for paths to ignore
#                         (e.g. don't check/delete)
# - -D,--delete=pattern   URI pattern for paths to allows delete
# - -d,--dir=start_dir    Start directory for search (default ~/.thumbnails)
# - ?? -f,--findopt=opt   Option to pass to find (ex: "-atime +7")
#                         (can have have many are cumulative)
# - ?? -A,--all           Delete all thumbnails (just form completeness)

version="0.3"
prg=$(basename $0)
verbose=0

# --------------------------------------------------------------------
#  Define some helper functions
# --------------------------------------------------------------------

function usage {
  [ -n "$1" ] && echo"$1" && echo
  echo "Usage: $prg [options]"
  echo
  echo "Options:"
  echo "-0,--null           Ouput file as NULL separated (for xargs -0)"
  echo "-h,--help           This help message"
  echo "-v,--verbose        Verbose output (to stderr)"
  echo "--version           Output program version"
  echo
  echo "Example:"
  echo "          \$ $prg | xargs -r rm"
  echo
  exit 1
}

function die { echo "$prg: $2"; exit $1; }

# Default is normal echo (-0 can change it later)
function echofile { echo "$1"; }

# --------------------------------------------------------------------
#  Check that helper programs exist (just non-standard ones)
# --------------------------------------------------------------------

exiftool >/dev/null 2>&1
[ $? -ne 0 ] && die 2 "Error: you must install exiftool"

# --------------------------------------------------------------------
#  Process command line options
# --------------------------------------------------------------------

getopttmp=$(/usr/bin/getopt -o h0v --long help,verbose,null,version -n $prg -- "$@")
[ $? -ne 0 ] && exit 1
eval set -- "$getopttmp"

while true; do
    case "$1" in
 -h|--help)
     usage
     ;;
 -v|--verbose)
     verbose=1
     ;;
 -0|--null)
     function echofile { echo -n "$1"; echo -ne '\0'; }
     ;;
 --version)
     echo "$prg $version"; exit 0
     ;;
 --)
     shift; break;           # Done with argument progressing
     ;;
 *)
     die 1 "Bad option: $1"  # We should never get here!
     ;;
    esac
    shift
done

[ -n "$1" ] && usage "Error: too many command line arguments"

# --------------------------------------------------------------------
#  Find the bad thumbnails
# --------------------------------------------------------------------

find ~/.thumbnails -name "*.png" | while read thumb; do
  uri=$(exiftool $thumb | awk -F' : ' '$1~/Thumb::URI/{print $2;}')
  file=$(echo $uri | sed "s@^file://@@")
  status="GOOD"
  [ -z "$file" ] && status="UNKNOWN"
  [ -n "$file" -a ! -f "$file" ] && echofile $thumb && status="BAD"
  [ $verbose -gt 0 ] && echo -e "${thumb}\t${uri}\t${file}\t${status}" >&2
done

cleanthumbs

#!/bin/bash
#
# $Id: cleanthumbs 493 2009-04-26 19:17:01Z grover $
# $URL: svn://svn.kevingrover.net/play/trunk/python/pictures/cleanthumbs $
#
# Clean bad thumbnails (with feedback of savings)
# Requires: findbadthumbnails

before=$(du -s -B1 ~/.thumbnails | awk '{print $1;}')
echo "Cleaning..."
findbadthumbnails | xargs -r rm
after=$(du -s -B1 ~/.thumbnails | awk '{print $1;}')
saved=$(($before-$after))
if [ $saved -gt 0 ]; then
   savedmsg="Before=$before; After=$after ($(($after*100/$before))%); Saved=$saved ($(($saved*100/$before))%)"
else
   savedmsg="No thumbnails deleted.  Thumbnail size = $before"
fi
echo "Done.  $savedmsg"

2008-07-19

Next batch of Bryson Pictures

It seems I can take them faster then I transfer them to the computer, upload them and create the blog.

Slideshow:



Link to the pictures:

Bryson4

Pictures of Bryson

Here are some new photos of Bryson.  Included in this batch were quite a few that I took while trying to get some to create a Passport photo for Bryson.

Slide show:



Link to the pictures:

Bryson3

For the passport photo, I used CorelDRAW (under Windows) to create a passport template, imported the photo into it and printed two images to 4x6" photo paper (using a Canon MP780).  They turned out pretty nice.

The passport took an amazingly short time to arrive: only 1 week.  I guess because we were not in a hurry!

2008-07-03

More Baby Pictures Coming

I have some MiniDV Video and more pictures to upload.  However, my hard drives crashed from heat.

I put in a new Seagate 750GB drive and installed Ubuntu 8.04 on it.  I used an Apricorn DriveWire to access the old drives (via USB -- they show up as USB disks in Ubuntu) and rescue pictures and video.  I just need to sort everything out, backup things up, and upload the new pictures and video --- once I figure out what to do with the video.

2008-06-28

LinkSys WPSM54G and Ubuntu

I have a Canon MP780 on an LinkSys WPSM54G Wireless/Wired Print Server. It works great from Windows (even scanning). It's not so easy in Ubuntu.

The LinkSys supports IPP (Internet Printing Protocol).  I found this by searching with Google.  There appears to be no reference in the LinkSys docs or (surprisingly) on the Admin page that the device itself serves.

I have my device at a fixed address.  This makes accesing it from UNIX machines easier.  You can have the device get its IP from a DHCP server (the default) when used with Windows machines because LinkSys provides a special program that finds the device. I'm not sure how it works.

When I tried to set the printer up as an Internet Printer, it wants to use the the URI:

ipp://192.168.1.50/printers

* NOTE: This did not work!
* NOTE: You should use your IP, not mine (192.168.1.50)

There's a button to search for printers.  I spend 10 minutes or so trying many different combinatations.  After failing, another Google search lead me to the URI:

http://192.168.1.50/ipp

Great.  However, that's not an option of the Internet Printer.  So, I tried 'Other' in the printer setup, and entered the http address.

Yeh, now it works again.

Heat Kills Drives

My Ubuntu 7.10 machine died. The two internal (IDE) drives failed because of heat.

I have a Fry's machine with a nice custom cover. The Plexiglas front covers the vent holes near the drives. When I added an old drive to store junk on, it was too much heat.

I replaced the drive with a large IDE and added an attached fan. I removed the old drives and will try to rescue data later.

In the mean time, I installed a fresh copy of Ubuntu 8.04.

Let the fun begin.