ATTENTION ALL FANS!!! THIS BLOG HAS MOVED!!!
go to: http://www.taotekaching.com

Showing posts with label sqlite. Show all posts
Showing posts with label sqlite. Show all posts

Saturday, March 07, 2009

Duplicate Files, Hash Codes, SQLite, and Me…

My wife’s been getting on my case about having a gazillion different hard drives with everything and our mothers on them all around the house.  I mean, come on everybody, she just wants her pictures in one @%$!# spot!  She also “misused” Picasa, and now has a bunch of duplicates on her laptop (she doesn’t read my blog, so I ain’t worried she’ll read that).

So, out shopping for Little Liam last weekend, and we decide to pop into Circuit City’s closing-its-doors blowout sale.  I grabbed her a 500 GB Western Digital external drive and, when we got home, proceeded immediately on a simple solution to shut her pie hole.

The result: MyPicturesConsolidator!  It is a WYSIWYG image grabber, duplicate detector, and file-copier-consolidator all in one, gorgeous package!

Ok, this program is NOT a work of art, but may contain some good stuff you can use, and it works pretty solidly, so…

mpc

How it works:

First, you select where you want any pictures it finds to get copied to:

mpc_dest

Second, select the logical drive you want to scan for pictures.  I included a Refresh Drive List button for changing between USB drives:

mpc_src

Third, click Find My Pictures!  And you’re good!

Behind the scenes:

I wanted a “list” to be maintained that kept track of files we’ve gone through.  I decided to use a SQLite database that would hold MD5 and SHA1 hashes of the pictures.  A good side effect of this is, just take it with the exe and SQLite dll to another computer along with your destination drive (or network share path, etc.), and the duplicates list maintained in the SQLite db should work golden for you.

MD5 and SHA1 generation is, for lack of a better phrase, retardedly easy via .NET.  An MD5 hash of a file, for instance, can be had in one line of code:

byte[] md5Hash = new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(System.IO.File.ReadAllBytes(filename));

The code is here.  Go ahead and take a look.  There’s some dumb things I’m doing in there that deal with my wife’s needs (i.e. Picasa uses file creation dates, ergo I try to find the earliest for her when I can, etc.).

~ZagNut

Submit this story to DotNetKicks

Monday, June 11, 2007

C#, T-SQL, and Me

This entry is really just a rant.

During these last few weeks, I have been kicking bugs' and errors' asses. Anything from downright dumb keystroke errors to more obscure "this data ain't quite right, but I'm not sure exactly what it's supposed to look like" stored procs and embedded queries, to a fierce battle with FTP and configuration files. But the last two days have made me want to drown myself in a bucket of mud and fecal matter.

I have been struggling with a stupid, simple, retarded date-time filter control for our C# admin app. There was a particular record for June 6th at 3:57pm which, whenever I adjusted the time to 3:07pm for that day, it would be filtered out. I have been ripping my farging hair out trying to fix this, to no avail.

Then, while working on some C# code, I was string formatting a datetime object. yyyyMMddHHmm...wait a minute...Went into SQL Books Online and lo and behold, DATEPART uses 'mi' for minutes filtering. I'd been so used to C# formatting, I just didn't think to...DOH!

Now, that was dumb.

What really chaps my hide is why C# datetime formatting can't use 'mi', knowing that 99.8256% of the C# developers out there will be mixing it up with some SQL, too. Little things like that might save the planet billions of hours of debugging time.

Submit this story to DotNetKicks

Sunday, May 27, 2007

Greetings, all...

So, I've been working like a mad man the last month or so. 60+ hours a week on a "project" defined as so only by a study that the project manager and execs refer to as a spec. The group I've been working with complained at a meeting that we'd be much better off on these projects if we actually had REAL specs (implying that ALL projects are coming in only as studies), to which the "project manager" replied that there was too much multitasking going on with him and the other managers to do what we were asking.

Of course, that leaves us piddly developers to basically figure out use cases, functional specifications, the data schema, and (much less) develop and troubleshoot the project, all while getting new "features" and complete changes to the project thrown at us basically every other day. Oh, and about 5 weeks to deliver what was officially to have been started in December aught six. But, that's not really multitasking, just our job.

If we hadn't used netTiers and CodeSmith, we'd have been kaput, methinks in hindsight 20/20. ZedGraph and Microsoft's Smart Client Software Factory also came in very, very, very, very handy.

Needless to say, Uncle Simon here has been a tired boy. Joey finally dragged me out of the house today to go do something (other than lie around the house, which I kinda really wanted to do). We ended up going out to Mt. Lebanon to Little Tokyo for dinner, then Jernigan's Tobacco Village for some smokes and wine. I had to admit to her that it really is nice to get out of the house every now and then. Little Tokyo would be maybe a 6.5 out of 10 for me, a 10 being Takahashi in Portland. Jernigan's was a cool place, but not like what I'd thought it would be. Again, Portland's Rich's Cigar was a fantastic spot. This was really only my first run out, though, investigating some of the city and it's surrounding area.

In my spare time lately (what little I have), I've been doing a couple of things. One is playing around with SQLite and System.Data.SQLite. I like it. I'm going to try getting the netTiers wrapper for it from the CodeSmith site soon, and my little creation I'm making should fly.

Also been reading Dreaming In Code. This is an excellent book so far. This is not a developer's book per se or something specifically for the software engineer, but rather does for software design what The Code Book did for cryptography.

I have also very recently been directed to and become enormously addicted to Puzzle Pirates. I will be playing this again tonight, like I did last night until 2:00am. I wish a very long and horrible curse on the man who introduced me to this (and you know who you are!). He has also gotten me semi-addicted to going to the Google Products page and refreshing the screen to see what the latest searches have been. I showed him the Trends from Google Labs. He immediately rushed back to his desk, put in "sporks" and I think "mullet wigs" and got Portland, OR back as the hottest city for this "trend". Little does he know, I have a titanium spork for camping!

A quick update. Next time I hope a have a link to my SQLite creation, as well as some more pictures from around here in Pittsburgh. This town's pretty cool so far.

Asta,

~simon


Powered by Qumana

Submit this story to DotNetKicks