|
July 24, 2008 Today's travel: 38.6 mpg, 1.0 gallons, 37.6 miles, 1.1 hours.
Yesterday I finally scoped out a system that would allow me to get rid of all my stuff. This has been a recurring problem for me for many years.
"Why not just throw it out?" you might ask. As part of my the obsessive traits of my personality I have a very hard time throwing anything out, even things I have absolutely no use for, on the thought that someone, somewhere, somehow, will have had a use for it and I just doomed it to a useless existence.
Electronics and cables are by far the worst example of this, and since they are everywhere in my basement, it throws up a mental wall against further clutter-relief until I can solve this problem.
So my goal has been to create a system that's so trivially simple to put stuff into, gives everyone in the world the opportunity to lay claim to something that would otherwise get trashed or recycled, and most importantly get it out of the house in some fixed time frame.
So in order to fight this anticipated regret, I had to get these items up on the web for everyone to see.
Every time I set up some framework on the computer to help me catalog the stuff I want to get rid of, ideas wind up attaching themselves to it. Much like a bill making its way through Congress, I look at the scratched out framework for a little garage sale system and think to myself, with just a few more lines, I could make this a comprehensive home inventory system.
Suddenly a system designed to get individual boxes of crap out of my basement becomes something that needs to scale to the size of all the items in my entire house. Those dozen lines of code turn into a few more classes to handle the vagaries of every type of object that I could possibly want to catalog, and double checking to make sure no item ever leaves the system after it leaves, and another set of interfaces for people to request items...
The realization strikes as the time spent and to-do list grows. I don't have time for a big software project like this right now. Another ambitious software project lies abandoned in the corner, and my basement is still filled with clutter.
Obviously, I needed something to break this cycle. Something so immune to additions and so easy to get off to a running start on the first night that I'd be stuck using it in spite of myself.
So using lessons learned from previous iterations and attempts over the last few years, I narrowed down to the following simple requirements:
- At least one but no more than three photos of each item, a title, a description, a disposal method, and a disposal date
- Data entry had to be so painless that it took only a few more keystrokes to complete than the actual entry of the item into the system, including the pictures.
Along the way, the data stored picked up:
- A pickup method, and the name of the person or entity the item was given to.
- A price.
- An ID number (this is just good design practice).
So the first thing I did was take the main table of an old structure and modify a few columns:
CREATE TABLE `newocpd_items` (
`id` int(10) unsigned NOT NULL auto_increment,
`title` tinytext NOT NULL,
`pic1` tinytext NOT NULL,
`pic2` tinytext NOT NULL,
`pic3` tinytext NOT NULL,
`description` text,
`method` int(10) unsigned NOT NULL default '0',
`destination` int(10) unsigned NOT NULL default '0',
`disposal` datetime NOT NULL default '0000-00-00 00:00:00',
`price` int(10) unsigned NOT NULL default '0',
`givento` tinytext NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=69 DEFAULT CHARSET=utf8;
That was simple enough, now for the back-end user interface. Normally I would go for a web interface but there's a latency and UI issue there that makes it easy to be a perfectionist and hard to just belt out new records.
The first thing I'm going to do is take the one to three pictures of whatever item it is I'm going to list. The picture won't get tied to the record except as a filename, so we don't need to upload anything individually. A little latency is fine so we can even wait until an entire new batch is up there and then join the pictures to it.
Then the second thing I'm going to do is input the filename of the photo I took. For simplicity, I'm only ever going to use the one camera that saves images as IMG_xxxx.JPG onto the camera card. That gives me the opportunity to enter in the four numbers.
Perl on the command line comes in handy here. I run the entire program in a do-while loop that ends if the content of title is ever empty, and a small function called promptUser that I picked up from DevDaily Interactive that grabs a value from stdin and includes the possibility of a default.
do {
$pic1 = &promptUser("picid1");
$pic2 = &promptUser("picid2");
$pic3 = &promptUser("picid3");
$title = &promptUser("title");
$description = &promptUser("Description");
$pickup = &promptUser("method p/pd/d", "2");
$destination = &promptUser("destination, r/t/d", "1");
$daysgone = &promptUser("days to leave", "14");
$price = &promptUser("price", "0");
if ($title ne '') {
$sth->execute($title, $pic1, $pic2, $pic3, $description,
$pickup, $destination, $daysgone, $price)
or die "Can't execute SQL statement : $dbh->errstr";
print "Inserted.\n";
}
} while ($title ne '');
The $sth object is a pre-compiled SQL insert statement that just requires a new set of variables. This is an example of a useless optimization for something that will be running in a loop at at user speed, but good programming practice nonetheless.
Now I set my camera to display the full information of each picture that I take for the full ten seconds after I take it. That way I can snap a photo of something, note the filename its being saved to, and immediately type that in at the prompt. If I take another two, they can follow.
Then I tap the rest of the information as prompted, most of which is just hitting enter for the defaults, and the item is in the database. I don't even have to hit a submit button. As I hit enter after the last data item, the script saves the whole set.
At the end of a long list of items, I can upload all the photos to the server and run a short shell script:
#!/bin/bash
export CONVERT=/usr/local/bin/convert
export OPTIONS='-quality 95 +profile "*"'
export SIZE=640x
export SMSIZE=75x
mkdir out
for image in `ls *.JPG| awk 'BEGIN {FS="."} {print $1}'`
do
echo $image
$CONVERT $OPTIONS -resize $SIZE $image.JPG out/$image-A.JPG
$CONVERT $OPTIONS -resize $SMSIZE $image.JPG out/$image-B.JPG
done
Now I have a list of thumbnail sized pictures and a 640x (usually 480) pixel picture to display as a link in the pages. Now I upload them into a directory, and direct users to a brutally simple 29 line PHP script that queries the database for anything not already given away and not past its expiration date and throws it up along with an ID number and an invitation to e-mail me if anyone wants it.
So what's the end product of all this? Well, one of two things is going to happen. Either a dozen people will e-mail me over the course of the next 14 days and ask for some of the items on my list, or not. In the case that they do, I'll distribute what I can to good hands. In the case that nobody steps up for something in 14 days, I can feel pretty confident that if my friends--quite possibly the geekiest and most artistic people on Earth--have no use for these items, they are junk pure and simple. Then I will merrily drop off what's left over at the county recycling center every week or so with a smile and no regrets.
A lot of effort for something that could be solved more simply? Sure. But I figure if I can save a handful of things from going to the dump every week, it's worth a little of my time. Plus it was a fun experiment in the extreme programming practices of coding and designing as simply as possible, and throwing out those random ideas that fall under the category of "You Ain't Gonna Need It."
In the end I was happy with the simplicity of the process, something facilitated by the fact that with my e-mail inbox down to zero messages I could write off hundreds of lines of "item request" code that the end user would have to interact with and replace it with a simple line at the top of the page that reads: If you're interested in anything on this list, e-mail rob@vees.net.
Evening weigh-in: 130.5 lbs.
2 Comments | #6673
Unless noted, all content on epistolary.org is © Copyright 1999-2008 to Rob Carlson with all rights reserved. All information is verified when possible, cited as appropriate and applied in the real world at your own risk.
Send all feedback to rob@vees.net.
|
teresa wrote:
umm.. your fancy code thing is nice and all, but 1. i did gloss over at some of the code, so maybe all the info is there but where is the link? 2. have you heard of freecycle? http://www.freecycle.org/ you blog is popular and all, but depending on how many responses you get you may also want to post your list there..
Posted on 2008-07-25 06:47:32
elissa wrote:
omg this is the geekiest blog post i have ever seen!!! and so of course i love it! i could catalog your junk collection first according to the LCCN classification system!
Posted on 2008-07-26 22:40:47