Tim Burns' Personal Weblog Flavored with Math, Java, and Oracle
 
Friday, May 28, 2004 [*]
 

Making the Most of Computer Disasters

Wednesday night I was awoken to a horrible beeping noise. We were having a thunderstorm. I stumbled around the house trying to figure out if it was outside or in, if it was a fire alarm or some odd little insect. I heard the 17 year cicadas were coming, but I didn't think it would sound like this. As consciousness came around, I determined that the noise was coming from upstairs. I went up there and discovered that a power supply was having a bad night too. I shut it off and went back to bed.

The next morning I went to check out my little power supply. Sure enough, the fuse had tripped and I reset it. I switched it back on, and there was a pop and a flash inside my computer and it didn't come back on afterward. Oh shit - there goes my day off (I had today off from work). I noodled about why it happened. Yup, like a moron, I had the computer directly on the carpet and it probably just gained a little too much static from the lightning.

The up side of a computer disaster is I get to build a brand new rip roaring 256 MB video card, 2.6 Ghz process, serial ATA super fast hard drive, 1GB of memory, DVD burner, and Windows XP computer. The down side is that I have to install all my tools and get my home apps to start working again.

I'm a die-hard Cygwin fan. The younger guys I work with tease me about the ancient Unix tools I use. I use Perl, Xemacs, and Cygwin, and find them exceptionally useful for the small project I do at home. So I had to install the tools and get my home workstation back in order.

The only uses I have for a home computer are photos and music. The photos problem is critical, because this is memorial day weekend and I have to get the old photos off my camera and onto a storage location so I can take new photos. On my old system, I was using Canon's photo software, but it would get into a funk and start crashing everytime I downloaded a new picture until I rebooted, so I decided to use a flash card reader and write my own download software. Of course, I wrote it in Perl.

Perl is a funny language, and if you start hacking in it, you can see why people either hate it, or love it. I love it for small home stuff, but I it has some problems. I tried to use the ActivePerl distribution, but it basically sucked, so I went back to the Cygwin version. I was surprised that it didn't include the Time::CTime package (I had to hunt around for a long time to find it so I put one here). The biggest problem with Perl is that its distributions are poorly organized and the tools to deal with this problem like the Perl Package Manager don't work.

Anyways, I got my computer running. It rocks. I wrote my code. It probably sucks, but gets the photos off my camera and onto my rockin SATA hard drive. So now I'm happy. Here is the code.

    #!/usr/bin/perl
    require strict;
    
    use File::Find;
    use File::Copy;
    use Time::CTime;
    
    &copyFilesFromCardReader("g:/DCIM", "d:/tburns/My Pictures");
    
    sub copyFilesFromCardReader {
      my ($cardReaderDir, $myPictures) = @_;
    
      find( sub {
    	  ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
    	   $atime,$mtime,$ctime,$blksize,$blocks)
    	    = stat($File::Find::name);
    	  my $targetDir = $myPictures . "/" . 
    	    strftime("%Y%m%d", localtime($mtime));
    
    	  if ( ! -e $targetDir ) {
    	    mkdir( $targetDir );
    	  }
    
    	  if ( $File::Find::name =~ m/.JPG$/i ) {
    	    print $File::Find::name . "-->" . $targetDir . "\n";
    	    copy( $File::Find::name, $targetDir );
    	  }
    	  
    	}, $cardReaderDir );	  
    }
    
    
 
Comments [2]
 
xml    Blogroll Me!

Personal

Rhode Island is Famous For You

Discovering My Own Backyard

At Least Databases Don't Fly Away

Southwestern Baby Shower Menu

Morning of the Wolf

Autumn lingers in New England

Foraging and Shopping

 

Math, Java, and Oracle

Regular Expressions and Unit Tests
Data Cubing Tools and the Oracle 10g Mess
Tracking Errors with JavaMail
The SVD, Benchmarking and Optimization
The Problem with Software Engineers
Fun with Optimization
Anything new under the sun?
Really Simple Tomcat, Really
J2EE with Free Software
 

Technology

New Computer and Perl CTime
 

Mushrooms

Coprinus Plicatilis
 

The Daily Chronic

 

References

BioInformatics

BioTech

Epicurious

Statistics

 

Archive

2004
 June 02 05
 May 05 06 10 11 12 15 20 24 25 28 29
 April 01 04 07 09 11 16 17 18 20 22 24 25 27 29
 March 02 15 21 22 24 27
 February 13
 January 04 16 19 29
2003
 December 06 12
 November 02 23 29
 October 07 11 12 16 18 21 24 26
 September 04 09 10 12 14 28
 August 05 08 13 17 18 25 29
 July
 June
2002
2001
 

Photos

Morning of the Wolf
Phantom Farms
Providence
Baby Shower
Camden, Maine
 

Wiki

Creative Commons License
This work is licensed under a Creative Commons License