Tuesday, November 06, 2007

Customizable classes for objects

Thoughts on object oriented programming, classes, objects and polymorphism

I am in the middle of a project that involves code from another organization. This organization is trying to make their code as flexible as possible through configuration settings, user only classes and templates. I also maintain code for another system from another organization that provides no flexibility for customization of code. I starting thinking, did some Google searches, and didn't find anything; so I'm putting my thoughts here.

The typical class design model I see in all media is the base class containing all the base functionality then you extend that class one or more times to provide additional logic. So myFoo extends Foo. Foo contains a lot of good methods and logic but my organization needs one additional property and method; myFoo is created. Here is where I start thinking this sucks. Any class that instantiates Foo, must now instantiate myFoo instead.

If the external organization delivers those classes we changed to use myFoo, now we must go back and make those changes again.

Wouldn't it make sense to deliver a Foo that extends a baseFoo, have all the classes that use Foo just use Foo? The developing organization makes changes to the baseFoo classes and the customizing organizations make customizations to the Foo classes.

This method of class design is just as vulnerable to catastrophic changes as the widely taught method. If you change the data schema you will still need to change the data objects, business objects, presentation objects, etc. Nothing will prevent that mess for occurring or, well, being a mess. If, however, a hundred classes use Foo would it make sense to change all (or ones that need) to use myFoo?

Tuesday, October 23, 2007

Blast from the past

I came across some really old "vanity web page" crap I did back in 1998. It was just a start and never got published but, hey.

Bachelor Necessities

As a bachelor with many (too many) years of experience I feel it is my duty to document my experience somewhere. For those of you about ready to embark on the journey of bachelor life or those already on the trodden path, here are some things you might want to pick up along the way.

A Mini Fridge
This really isn't a necessity but something, for some strange mystical reason, a guy must have. Typical uses: beer. Typical placement: garage, basement, bedroom, television room - wherever you spend the most time. Estimated cost, $100.
George Foreman Grill
God bless you George "look at the lines, that's good eatin'" Foreman. This little bugger is so helpful and so easy to use any guy, no matter how dumb you are, can master one. Doesn't do a good job on steaks with bones in them but is perfect for frozen chicken breasts (don't bother thawing, just chuck'em on), burgers, fish, and just about all meats. Estimated cost, about $70.
An Outdoor Grill
You can go propane but you'll find you get the most use out of a small charcoal grill you can take with you in your car or let rust on your back porch/front step. Estimated cost, about $30.
Crock Pot
Another gift from the heavens to the bachelor. Just follow the recipes that come with the device. So easy, I was actually able to teach my dumb-ass complete waste of an ex-friend "L" how to cook. See my chili recipe. Estimated cost, about $40.
Like, duh. Just buy a good one then treat it well and it will outlast you, all the women you are intimate with, and probably every dwelling you'll ever be in (even your casket). Estimated cost, who the hell knows - I bought mine ten years ago.
Big Screen TV
Even if you are stuck in the bedroom of your parent's house, you need a big screen TV. The big screen TV represents the following: a symbol of your manliness you can share with friends at football parties, a showcase for your best DVD movies and/or your porn collection, and a constant reminder of just how in debt you really are. Estimated cost, about $3600 (gotta get a good one, man).

Chili ala' Grouch

If you read my "bachelor necessities" above you should have noticed a crock-pot as one of the items there. This is what I use because a) I'm lazy, b) I'm a guy and need the flexibility of a crock-pot to hide my cooking inadequacies.


  • Two pounds of ground chuck or ground round (i.e. raw hamburger)
  • A can of chili beans
  • A can of tomato sauce (name brand, no generic)
  • A can of tomato paste
  • A can of diced tomatoes (or cut up a bunch of tomatoes, no seeds)
  • A can of green chilies (usually found in "Mexican" section)
  • One stalk of celery
  • One onion
  • Two green peppers
  • One jalapeno pepper
  • Two or more cloves of garlic (comes in bulbs, peel them to get cloves)
  • Chili powder (spice)
  • Pepper (the kind you shake)
  • One bay leaf (another spice) or Chinese 5-spice (yes, a it's a spice too)
  • Cumin (a spice)


  1. Brown the ground beef (this means you cook the hamburger until it turns brown, I had a family member that wondered why his chili had so much blood at the top - he was adding it raw). Here is how I do it: a) throw the wad on my George Foreman Grill, b) insert the sliced cloves of garlic into the meat, c) liberally add pepper and chili powder, d) grill, e) crumble into the crock pot.
  2. While your biff is browning, cut up the veggies. Put the onion, celery, and jalapeno (and garlic) into the crock.
  3. Open the cans. Dump in the green chilies.
  4. Drain the grease from the beef (or don't, I don't care) and put it in the pot.
  5. Add the bay leaf (or a couple shakes of 5-spice), a pinch of cumin, some pepper, some chili powder.
  6. Dump in the tomato paste, then beans, then tomato sauce, then rinse cans with about a cup (measuring cup, i.e. a little bit) of water then dump into crock.
  7. Start cookin (5-7 hours on high, 10-12 hours on low).
  8. About one (high) or two (low) hours before the chili is done, stir in the green peppers. The reason I do this is because when I added the peppers at the beginning that's all I could taste in the chili - green peppers.
  9. When done cooking, serve hot and enjoy with a beer. Don't ruin with crackers or I'll shoot you.

Variations: Tex/Mex". Replace can of chili beans, stalk of celery, and green peppers with black and/or pinto beans, a half a can of corn, a red pepper and a yellow pepper. Unlike the chili beans (which usually come in a sauce), you should drain and wash the black/pinto beans.

Dealing with Depression

If you are like me, and (according to some news sources) like over thirty percent of the population in the United States, you deal with depression on (sometimes) a daily basis. These feelings usually manifest themselves in the form of feelings of hopelessness or you might feel tired all the time.

What not to do.

Drugs are NOT the Answer.

When I say drugs I am describing anything from prescription drugs like Prozac to binge drinking. Drugs are only a temporary solution to the problem and usually make things worse. I have seen some co-workers on the drug Prozac and they are both psychos, one step away from full-out fruitcake. I have family members on different prescriptions and they aren't any better. One has been on various prescriptions for twenty (yes, 20) years. The physicians just keep giving him the line "let's try this one". These quacks have no idea what they are doing, they just continue to milk the system. One of my friends smoked marijuana (i.e. pot, reefer, weed) to escape his depression. That loser is still depressed and now half his tenth-grade brain is gone. The common thread is that all of these people are still taking drugs and they are all still just as depressed, if not more than they ever were.

Shrinks are NOT the Answer

If you a rock star or some wealthy Hollywood name, then a "shrink" might work for you. For the rest of us that need to work for a living, you might as well just stop someone on the street or sit next to someone at a fast food joint because you are likely to get the same answers. Basically you pay a "shrink" to listen and make observations but every single session boils down to a prescription (see above). They do not have the answers or if they do they are canned answers you could probably get from a box of cereal or Miss Cleo. I saw a psychiatrist once, and that was enough. There are no easy answers to anything, but there is something that can be prescribed.

Is God the answer?

Maybe… Part of the problem with religion or other social groups is that they remove your self-esteem by placing everything in someone else's hands. Instead of depending upon yourself, being responsible, and understanding your strengths and weaknesses, everything is now controlled by an external entity (i.e. God or insert religious icon here). It works for you if you can completely give yourself. For most people it works temporarily until that first bout of doubt sets in, then there is the possibility

My Solution?

Be depressed.

Seriously. Believe it or not, depression is a completely normal state of being just as happiness, sadness, ecstasy, and indifference are. It's okay to be depressed. If you are depressed, chances are good there is a reason why you are depressed. A couple of days later, you might still be depressed or you might do a one-hundred percent turn-around and be glowing with joy. It might even take a month or a year or your entire puberty. It's part of life. Depression makes happy days happier but can be overwhelming at times. Most people that "suffer" from depression have succumbed to it. Don't succumb to it. When the day is done, go over to the calendar and mark off the day because it's over.

Monday, June 25, 2007

Testing 1-2-3

I want to see how labels are handled with classic templates.

<p>I want to see how labels are handled with classic templates.<p class="blogger-labels">Labels: <a rel='tag' href="http://grouchgeek.blogspot.com/search/label/testing">testing</a></p></p>

It looks like Blogger just inserts a paragraph for you at the end and from the looks of the documentation you have no control over that. Nice...

Saturday, June 23, 2007

Crew cases, part two

Just a quick update. The painting is done on the two cases. The yellow case; well the paint job didn't quite turn out perfect and I gave up trying to get a nice smooth gloss after three coats of color and two clear coats. It looks good from a distance or on casual notice but when you get close you notice the dull spots. Oh well.

Still left to do are the Crew logo, the "Columbus Crew" on one of the 5 1/4" drive panels, and possible the LH in a circle (for Lamar Hunt). The black case is fully operational with and AMD X2 processor, 4GB ram, 500GB and 80GB x 2 RAID-0 running Ubuntu Linux 64bit 7.04 desktop. This machine will serve as a VMWare Server server development system with images on the striped array; with management, squid cache, apache, tomcat, mysql and maybe Oracle images. Fun. The yellow will be a Windows 2003 Server based development machine and swap out drive sets with Linux based server development.

Thursday, June 14, 2007

Informative links about computers

Just putting this here for my own personal reference and might build on it in the future; or have other people build on it.Power supply buyer's guide

Monday, June 11, 2007

No more FOX in the mornings

I am no longer going to wake up on the weekends to watch FOX and Friends on weekend mornings. This weekend on Bulls and Bears there were two blondes, one arguing and spouting off one-sided political vomit about another worthless blonde that deserves zero publicity. Ann Coulter discussing Paris Hilton. Good lord. One annoying stick figure she-male talking about a talentless socialite stick-figure.

That's it. No more.

I almost tuned out when they took Juliet Huddy off but then there was Kiran Chetry to look at but now Kiran is with CNN replaced by Gretchen Carlson and now Page Hopkins. I like Page but she's no Juliet or Kiran.

Ann Coulter discussing Paris Hilton was the last straw, though. Two days later and my stomach is still sore and unable to accept anything stronger than pudding or yogurt. (And I do realize that discussing this is actually "publicity" for both but if some lowly blog like this one is "publicity" then that actually makes me feel a little better about the rest of the world that thinks both need to be forever hidden from the public eye in a jail or sealed in lucite or carbonite or something).

Wednesday, June 06, 2007

Keeping CPUs busy

I guess I either don't understand the finer points of computer performance or don't understand why some people don't understand what I consider to be simple knowledge about computer performance.

"The CPUs on the server are running at high utilization, 60 to 80 percent"

Okay. So?

Are you paging (swapping) heavily? No. Is the disk I/O rate normal, low or very heavy? It's about normal. Is there a looping or run-away process or service? No.

Then what is the problem? (this isn't happening with my current employer, by the way)

It seems to me that if you aren't paging then you are not using all of your server's memory, else you would be swapping and that could be bad. If there are no looping processes then the software and operating system are functioning normally. If the disk (or network) I/O are normal then the software is reading and writing data like it should be. Again, what is the problem because it sounds to me like the CPUs are doing what they are supposed to be doing, utilizing themselves and if your I/O rates aren't through the roof then you are probably getting a portion of the CPU utilization through application buffer and cache hits (a really good thing, by the way). You don't spend a dump-truck full of money on a bunch of processors just to have them sit there at 10 percent utilization most of the time; you want them doing work! Throw more memory at them to boost cache and buffer hit rates or if that doesn't seem to help (which sometimes it doesn't; there is a sweet spot when doing read caching just because you can only cover so much especially when data is scattered on disk) maybe consider moving temporary spaces to memory (or covering them heavily).

The point is: you want your server processors to be busy if there is work to be done. Maybe I'm wrong or just don't understand things correctly but it seems like putting a motorcycle engine on a scooter; if you're never going to have the thing above 2 miles per hour then why all the horsepower? I see the same thing on the workstation. If all you are going to be doing is surfing the Internet, typing memos and using central application software do you really need a 2.8Ghz P4 sitting there doing nothing? I got in an argument with a pro-Firefox guy recently. He said Opera can use over 160 MB of memory. So? Is any other application using it? No. Then what harm? I'd rather have Opera intelligently caching as much as possible while there is no effect on other applications. "Well it shouldn't use that much!" Sigh.

IBM has a technology called Capacity on Demand (CoD) "so companies don't have to pay for computing resources until they use them." They have on/off and reserve processing that can be activated in increments of time (like a day) for end-of-period processing or for sporadic work loads. The company I work for has already had some fun with it. There are other aspects of CoD and it is a decent idea but I have to believe that IBM isn't in it just to keep customers happy; they are making their money.

Tuesday, June 05, 2007

Subliminal ideas

Ever been on hold with some company, usually a tech support line or any other cost center that earns them zero cash, and listened to that grainy music? Ever wish when you had a caller on the line that just talks and talks and talks and talks and talks forever about nothing and just wants to vent or occupy your time? Ever wish you could put that person on hold, press a button and have something subliminal play within the music while they were on hold? I think I'm onto something here.

Lets say I'm some cable company where ninety percent of calls are people saying the cable is out even though you have a message up front saying so. When this person actually gets through they could have on-hold music that subliminally repeats "hey lard-ass, the cable will be back shortly why don't you go for a walk or ride a bike for a while?" Maybe the on-hold subliminals for a sales line would be something like "buy this product and you sure to be getting oral pleasure from your spouse or spousal life acquaintance".

Of course, the applications are endless. And they don't necessarily have to be devious, do they? How about a calm, reassuring "your mind is calm, your life is happiness" while on hold? Maybe not at a hospital or funeral home but you get the idea.

Friday, June 01, 2007

Rally's orange cream shake

Before I'm going to change back to a healthy diet of greens, proteins, fiber, plenty of water, etc. I was going to go for one last "heart-attack-in-a-sack". For those of you who don't know me personally that would be a Rally's Big Buford sandwich, fries and a soft drink. Instead of the combo meal I skipped the soft drink and got one of those orange cream shakes they have been advertising. Here is the deal:
  1. doesn't taste a thing like oranges; imagine drinking liquid candy valentine hearts (the ones with I LUV U and other dumb sayings on them), that is what it tastes like
  2. it is creamy (and foamy) but that's because it is a shake; I don't detect a dairy cream taste at all
  3. it is a shake
I'm killing the taste of the thing with the Buford but that shake is going to put up a fight for control of my stomach acids for the next five hours during which my belly will probably sound like an angry flock of geese.

Saturday, May 26, 2007

Crew cases, part one

One of my summertime projects is to modify two computer cases to bear a likeness to the Columbus Crew soccer team's home and away jerseys. I already had the black case and components so there wasn't much effort involved there. The yellow case, however, needs to be painted; transforming it from beige to yellow.

Safety first, always paint in a well-ventilated area with proper protection.

The beige case has already been wet-sanded with 600 grit sandpaper and had it's primer coat.

Here is the case after the first coat of yellow.

I've already done part of the black case. To the left of it is the guts of the yellow case.

What's left to do? I need to create a mask or stencil so I can spray paint "Columbus Crew" in Copperplate font on one of the removable drive panels. I need to find two Crew logo stickers, about an inch high, to put above that. On the other side of the logo I'd like to do the Lamar Hunt (LH) patch. I'd also like MLS logo stickers for the bottom.

Monday, May 21, 2007

Oracle instant client, Ubuntu, and ORA-12154

I've been pulling my f'ing hair out for a couple hours trying to figure out why I couldn't connect to our Oracle databases from an installation of Oracle's instant client for Linux on Ubuntu 7.04 (although this should apply to other installations). No matter what environment variables I set or where I placed tnsnames.ora I would always get a ORA-12154 could not resolve service name error. Here was the problem (thanks to Rajesh Jayaprakash's Linux tricks and how to's): the tnsnames.ora and the sqlnet.ora files were created on Windows and had the extra carriage returns in them. Removing the carriage returns solved the problem.

How f'ing stupid. For those that want quick installation instructions assuming you have the installation files on the root of a mounted CDROM:

sudo -s
mkdir /opt/oracle
cd /opt/oracle
unzip /media/cdrom/instanclient-basic- (etc.version.blah.blah)
unzip /media/cdrom/instanclient-sdk- (etc.version.blah.blah)
unzip /media/cdrom/instanclient-sqlplus- (etc.version.blah.blah) optional
ln -s instantclient_10_2 client
cd client
ln -s libclntsh.so.10.1 libclntsh.so
ln -s libocci.so.10.1 libocci.so
tr -d '\r' < /media/cdrom/tnsnames.ora > /etc/tnsnames.ora
tr -d '\r' < /media/cdrom/sqlnet.ora > /etc/sqlnet.ora

To use SQLplus from a shell you need to add the ORACLE_HOME=/opt/oracle variable and add /opt/oracle/client to variable LD_LIBRARY_PATH to the /etc/bash.bashrc (for example).

Wednesday, May 09, 2007

eBay, spoofs and spam

For the first time in probably over five years I decided to make some purchases off of eBay. I am in the process of building my "Fortress of Nerditude" in the basement and wanted a small wide screen LCD to serve as secondary PC display, TV, DVD screen, etc. A while ago I was looking at Dell LCD displays and since Dell no longer sells them I found some reasonably priced on eBay. So I make a bid for one but I'm outbid. Then came the flood of spoof mail and SPAM. On that single item alone I have received 17 (and counting) bogus mail messages from people claiming to the be the "seller" offering a second chance to buy the item or mail addresses to use to buy the product directly from them. This was the first time I had encountered this phenomenon but it infuriated me. Most were designed to look like authentic messages from eBay and all seem to be generated by the same program (all contain similar spelling errors). Some attempts were pathetic, in broken English. What is sad about all this is this was only one bid from a user ID that has never bid on anything else. What kind of message is eBay sending by allowing people who use the eBay system to send this crap? (I read they were changing the bidding system to hopefully eliminate this). I have a thick skin and a little tolerance for this crap but how could I recommend the eBay experience to family if getting assaulted by spoofs and spam is the result?

It's been a long time

How does that Boston song go? Oh well. It has been a long time since I've used the therapeutic power of writing to help me through life. It's not like my life has been boring and uneventful. Last month my girlfriend of almost four years (close to six if you count online and times I drove up to see her) left me to return home. She filled up a 24 foot moving truck, a couple cars and a van with stuff and headed north with her son and dog. After one weekend of feeling miserable I reversed my attitude and was determined to stay positive through the whole situation. I started looking for people and started contacting friends that I had either lost track of or simply just didn't talk to much. My search found someone who is now moved in with me and renting one of the bedrooms of my house. I have started the sizable cleanup effort inside the house and have a couple of the rooms ready to repaint. I have plans for my deck off to the homeowners association and hope to start real work on that soon.

Wednesday, February 28, 2007

Taquitos and a depressing area

I decided to cash in some of my Discover cash back bonus to get some money off a purchase at Staples, using to get a UPS battery backup for the family server so I can move the existing one to my xPC mini that doesn't have one but I think I'll leave it where it is and put the big, new UPS on my power workstation and move its UPS to the xPC. Yeah, got it. I was hungry and knew there was nothing but scraps at home so I decided to get some drive-thru.

There used to be two Taco Bell stores within a hundred yards of each other when I used to live off the southern end of Hamilton road. Eventually they closed one of the stores, leaving the one next to the Ohio BMV building open. It's in a horrible location; there is really only one way in and one way out and it is cramped. I tried one of those new grilled steak taquitos; nothing spectacular. You really can't taste the carne asada steak, just the cheese and you are encouraged to dip the things in guacamole, sour cream or salsa; three overpowering tastes. Hey it's only fast food, right? One hundred and ten fat calories later I'm sitting here wondering how dark and dreary that part of town has become.

I think the Service Merchandise was the first to go a long time ago, then the Phar-mor after that. Anybody remember Service Merchandise and how you walked around with those clipboards and when you wanted something you wrote down the catalog number then let someone process you then went to exit to get your purchases off the conveyor belt? Fun. That whole section is just dead now; pitch dark. The Good Year center is also closed. It used to be a great place to get tires until the screwed up an oil change; two extra quarts of oil in the crank case and a missing transmission fluid dipstick. More fun. Well, it's dead too. The compact disk store I used to buy all my metal music at is gone. What was the name? Twenty clicks on their card got you a free CD, which was awesome until I found stores on The Ohio State University's campus area. I could always get my music there cheaper and at a downright bargain if I waited for the used discs to roll in. I think there is a Toys R' Us back there. I used to go to Media Play for blank tapes and crap but I'm not sure if it is still there. The BWC building is shut down. The adult bookstore and a strip club are still there. Both AMC theaters are closed. The Big Bear and Central Hardware stores are long gone along with most of the shops in the immediate area. The tuxedo rental place when I got a tux for my friend Terry's wedding is gone along with the golf shop and photo store.

On the bright side, the Olive Garden still does well and there is an Ocean "something" restaurant close to it. Pizza Hut still seems open even though I admit to never having gone there. Papa Johns seems to do okay in the building that used to be a Rally's and a long time ago a Ritzy's that I worked at for a one day special event.

Of course, there is Eastland Mall. Lazarus turned into Macy's then shut down and Macy's took over Kaufmann's almost immediately after it was built. The food court has been rebuilt which is a good thing. I have purchased leather jackets from the same store under three different names. Now that store is gone.

I'm shocked at the change in the area I used to call home. It's just dirty, dark, dreary and depressing to look at.

Tuesday, February 20, 2007

Spam flood, again

Did anybody else get almost triple the amount of unsolicited emails overnight? I usually get a couple hundred but this morning I had just over a thousand waiting for me in my oldest mail account's bulk folder.

Seriously, though; why hasn't someone done something about this? Most messages I am getting appear to be from an eight year old list (i.e. great mortgage rates for the apartment I lived in eight years ago) so you figure someone would have found the ass-bag responsible for spreading that list and fed them to crocodiles somewhere. If you scan through most of your bulk mail message there isn't one damn legitimate business in there. Even if only half of the message are fraudulent, in the above case there were over 500 individual instances of attempted fraud.

Wednesday, February 14, 2007

Surviving the clear death

What started out as the "white death" promised by the weather nerds turned out to be just as bad in most places as they originally predicted. Instead of the "white" death things are more of a "clear death" due to the volume of crystal clear ice covering everything. Thankfully we were lucky and (knock on wood) have yet to lose power. After taking out the trash this morning I decided to take some photos of the neighborhood. I live outside the city and here are some shots of the ice and snow; some of them are quite pretty to look at.

The dog didn't like ice and sleet last night. Get me out of here! Poor thing had to wait for the early morning to go potty.

Tuesday, February 13, 2007

Surviving the white death

Yeah the weather was pretty bad today. It took about eighty-five minutes to get to work today only to get to spend a couple of hours of quality time with the one or two that made it in only to be sent back home again. I work downtown and live on the southeast side of Columbus (Ohio) and the local weather nerds (and nerd-ettes) were saying 4"-8" of snow plus sleet and freezing rain.

The drive home was treacherous but only due to stupidity on the part of other drivers. SR-33 south had one side plowed and those of us using it were going a steady 40 miles per hour with plenty of distance between us. I kid you not, I was passed on the left, in the unplowed portion, by some dumb-ass doing about fifty while talking on his cell phone. He had handicapped tags so I'm assuming the handicap was a mental one. Seriously, is it really worth risking your life and the life of others just to get those couple extra feet (which ended up as zero feet because I pulled into the same shopping center behind the idiot). I was also passed by one of those double-trailer trucks fish-tailing back and forth as it plowed through the slush and sleet, sending chunks of snow and ice into the air to crash against the windshield. There were two dimwits following the trucker in their SUV with no more than a car length between them. Sometimes I wonder how we survive.

The dog hates the ice. He loves playing in the snow but tends to panic and get frustrated when he breaks through the ice and sinks up to his neck in the snow beneath.

Just looking at the ice outside I cannot help but remember the ice storm we got before Christmas in 2004. This year's storm is similar in regards to what is dropping where. The volumes of snow are up north and the ice is down south. In 2004 we lost power and had to fleet to my parent's house until the power came back late night around 11pm or so. There have already been power outages in neighborhoods very close to us that were serviced by our power company. I'm hoping that the power survives the night and doesn't die on us in the middle of the night. I'm sure the noise of all the UPS battery back-up alarms going off will wake us. I think I'm going to turn the heat up a little bit just in case; the extra cost now might buy an extra couple of hours of heat if the power does go.

Thursday, February 08, 2007

Psycho SQL

Back in the old days on an AS/400 with DB2/400, we didn't have the luxury of a CASE statement or IF or DECODE and performance was at a premium when attacking a gigantic detail table. We needed a way to provide real time performance on huge tables summarizing values by quarter without the benefit of a temporary work table or sub-queries. The AS/400 did not have "if-logic" but it had MIN(value1,value2), MAX(value1,value2) and absolute value (ABS(value)) so I cheated and used those functions with some math to produce the result set.

The goal for each quarterly column was to reduce the month (m in examples below) down to a zero or a one (false and true) then multiply that times the quantity and amount being totalled (value). Zero (false) when multiplied would produce a zero and therefore not add anything to the SUM. One (true) when multipled would produce the same number and be added to the SUM.

SELECT grouping_code
, SUM(value*(1-MIN(MAX(m-3,0),1)))
, SUM(value*(1-MIN(MAX(ABS(m-5)-1,0),1)))
, SUM(value*(1-MIN(MAX(ABS(mm-8)-1,0),1)))
, SUM(value*(1-MIN(MAX(ABS(mm-11)-1,0),1)))
FROM large_freakin_detail_table
WHERE criteria = 'whattheywerelookingfor'
GROUP BY grouping_code

So you are probably wondering what the blue heck all that SUM MIN MAX ABS crap is doing. Sometimes it is best to look at results. Assume the left-most column is the month (1 through 12) and see how that number is transformed into a true (1) or false (0) through the magic of math.


m-3 MAX MIN 1-r
1 -2 0 0 1
2 -1 0 0 1
3 0 0 0 1
4 1 1 1 0
5 2 2 1 0
6 3 3 1 0
7 4 4 1 0
8 5 5 1 0
9 6 6 1 0
10 7 7 1 0
11 8 8 1 0
12 9 9 1 0

The first quarter is simple: subtract 3 (March) then take the highest of that value or zero. The 0 is higher than -2, -1 and 0, but not higher than 1, 2, etc. Now we have a zero in months 1, 2 and 3 (1st quarter). By looking for the lowest value between 1 and the last result you will get a 1 for 1 or more but the zeroes will stay 0. Subtract the result from 1 (0 = 1, 1 = 0) and now you have the true/false value to multiply against an amount to either zero it or not before adding it to the SUM. Tricky, eh?


# m-5 ABS r-1 MAX MIN 1-r
1 -4 4 3 3 1 0
2 -3 3 2 2 1 0
3 -2 2 1 1 1 0
4 -1 1 0 0 0 1
5 0 0 -1 0 0 1
6 1 1 0 0 0 1
7 2 2 1 1 1 0
8 3 3 2 2 1 0
9 4 4 3 3 1 0
10 5 5 4 4 1 0
11 6 6 5 5 1 0
12 7 7 6 6 1 0

The remaining quarters are more difficult but by using the absolute value (the positive value) you can eventually get the number you are looking for.


# m-8 ABS r-1 MAX MIN 1-r
1 -7 7 6 6 1 0
2 -6 6 5 5 1 0
3 -5 5 4 4 1 0
4 -4 4 3 3 1 0
5 -3 3 2 2 1 0
6 -2 2 1 1 1 0
7 -1 1 0 0 0 1
8 0 0 -1 0 0 1
9 1 1 0 0 0 1
10 2 2 1 1 1 0
11 3 3 2 2 1 0
12 4 4 3 3 1 0

This query used one sweep through the gigantic table and one sort for the group by. Grouping on month would have added an additional sort so that was not an option.

Wednesday, February 07, 2007

Form input validation: selective service

I while ago I attempted to locate any information on the selective service number and means of simple validation of selective service numbers collected through the Internet. The answer I received from Public and Intergovernmental Affairs at the Selective Service System was:

The first two digits of a man's Registration Number, who was born January 1, 1960, or later, will be his year of birth (such as 78, 80, 84, etc.), followed by a dash and eight other digits, making ten digits total. These last remaining eight digits are just random numbers (84-XXXXXXX-X).

Like the social security number there are no check digits hidden in the number (so, no code). To do client-side Javascript validation the appropriate regular expression would be: /^(\d{2})-?(\d{7})-?(\d)$/; or /^\d{2}-?\d{7}-?\d$/; if you didn't feel like saving components in an array.

I just love going through old mail messages :D

Useful terminology

  1. Intaxication: Euphoria at getting a tax refund, which lasts until you realize it was your money to start with.
  2. Reintarnation: Coming back to life as a hillbilly.
  3. Bozone (n.): The substance surrounding stupid people that stops bright ideas from penetrating. The bozone layer, unfortunately, shows little sign of breaking down in the near future.
  4. Foreploy: Any misrepresentation about yourself for the purpose of getting laid.
  5. Cashtration (n.): The act of buying a house, which renders the subject financially impotent for an indefinite period.
  6. Giraffiti: Vandalism spray-painted very, very high.
  7. Sarchasm: The gulf between the author of sarcastic wit and theperson who doesn't get it.
  8. Inoculatte: To take coffee intravenously when you are running late.
  9. Hipatitis: Terminal coolness.
  10. Osteopornosis: A degenerate disease. (This one got extra credit.)
  11. Karmageddon: It's like, when everybody is sending off all these really bad vibes, right? And then, like, the Earth explodes and it's like a serious bummer.
  12. Decafalon (n.): The grueling event of getting through the day consuming only things that are good for you.
  13. Glibido: All talk and no action.
  14. Dopeler effect: The tendency of stupid ideas to seem smarter when they come at you rapidly.
  15. Arachnoleptic fit (n.): The frantic dance performed just after you've accidentally walked through a spider web.
  16. Beelzebug (n.): Satan in the form of a mosquito that gets intoyour bedroom at three in the morning and cannot be cast out.
  17. Caterpallor (n.): The color you turn after finding half a grub in the fruit you're eating.
  18. Ignoranus: A person who's both stupid and an asshole.

Tuesday, February 06, 2007

George Carlin's new rules for 2007

  1. Stop giving me that pop-up ad for classmates.com! There's a reason you don't talk to people for 25 years. Because you don't particularly like them! Besides, I already know what the captain of the football team is doing these days -- mowing my lawn.
  2. Don't eat anything that's served to you out a window unless you're a seagull. People are acting all shocked that a human finger was found in a bowl of Wendy's chili. Hey, it cost less than a dollar. What did you expect it to contain? Lobster?
  3. Stop saying that teenage boys who have sex with their hot, blonde teachers are permanently damaged. I have a better description for these kids: "Lucky bastards."
  4. If you need to shave and you still collect baseball cards, you're a dope. If you're a kid, the cards are keepsakes of your idols. If you're a grown man, they're pictures of men.
  5. Ladies, leave your eyebrows alone. Here's how much men care about your eyebrows: Do you have two of them? Okay, we're done.
  6. There's no such thing as flavored water. There's a whole aisle of this crap at the supermarket, water, but without that watery taste. Sorry, but flavored water is called a soft drink. You want flavored water? Pour some scotch over ice and let it melt. That's your flavored water.
  7. Stop screwing with old people. Target is introducing a redesigned pill bottle that's square, with a bigger label. And the top is now the bottom. And by the time grandpa figures out how to open it, his ass will be in the morgue. Congratulations, Target, you just solved the Social Security crisis.
  8. The more complicated the Starbucks order, the bigger the asshole. If you walk into a Starbucks and order a "decaf grande, half-soy, half-low fat, iced vanilla, double-shot, gingerbread cappuccino, extra dry, light ice, with one Sweet-n'-Low, and one NutraSweet," ooh, you're a huge asshole.
  9. I'm not the cashier! By the time I look up from sliding my card, entering my PIN number, pressing "Enter," verifying the amount, deciding, no, I don't want cash back, and pressing "Enter" again, the kid who is supposed to be ringing me up is standing there eating my Almond Joy.
  10. Just because your tattoo has Chinese characters in it doesn't make you spiritual. It's right above the crack of your ass. And it translates to "beef with broccoli." The last time you did anything spiritual, you were praying to God you weren't pregnant. You're not spiritual. You're just high.
  11. Competitive eating isn't a sport. It's one of the seven deadly sins. ESPN recently televised the U.S. Open of Competitive Eating, because watching those athletes at the poker table was just too damned exciting. What's next, competitive farting? Oh wait. They're already doing that. It's called "The Howard Stern Show."
  12. I don't need a bigger mega M&Ms. If I'm extra hungry for M&Ms, I'll go nuts and eat two.
  13. If you're going to insist on making movies based on crappy, old television shows, then you have to give everyone in the Cineplex a remote so we can see what's playing on the other screens. Let's remember the reason something was a television show in the first place is that the idea wasn't good enough to be a movie.
  14. No more gift registries. You know, it used to be just for weddings. Now it's for babies and new homes and graduations from rehab. Picking out the stuff you want and having other people buyit for you isn't gift giving, it's the white people version of looting.
  15. And this one is long overdue: No more bathroom attendants. After I zip up, some guy is offering me a towel and a mint like I just had sex with George Michael. I can't even tell if he's supposed to be there, or just some freak with a fetish. I don't want to be on your web cam, dude. I just want to wash my hands.
  16. When I ask how old your toddler is, I don't need to hear "27 months." "He's two" will do just fine. He's not a cheese. And I didn't really care in the first place.
  17. If you ever hope to be a credible adult and want a job that pays better than minimum wage, then for God's sake don't pierce or tattoo every available piece of flesh. If so, then plan your future around saying, "Do you want fries with that?"

Monday, January 29, 2007

Squealing clothes dryer

Try to imagine the most annoying, shrill, squeak you can imagine (something other than the wife or girlfriend nagging you about something) and imagine that happening occasionally, on and off, every time you run the clothes dryer. According to askmehelpdesk.com this is a common problem in a series of dryers and can be traced to a bad rear drum bearing. Here is where I deal out some praise and some criticism.

First of all I would like to thank "applguy" in the advice forums. His instructions were completely accurate and easy to follow down to the color of certain items and where "four hands are better than two". I had the dryer fixed in less than an hour and I consider the task pretty easy.

I purchased the Kenmore washer and dryer set from Sears and they deserve some criticism. I purchased a bearing kit from them through their online service (alternative was a phone call). The steel ball plate was not identical to the old one and the parts envelope was burnt at the bottom and all parts except two screws were missing. That's some fine Q/A there folks. How someone missed a burnt parts envelope is beyond me. I had to use the ball bearing and the hardware from the original unit. The bearing bracket unit inside the dryer was barely lubricated and the lubricant they used had turned to rubber. No wonder the thing was ground and squealing.

While I had the dryer opened up I made sure to vacuum out all the lint and crud inside and wipe down some areas. Thankfully, the machine is now quiet again.

Wednesday, January 17, 2007

Addicted to hand sanitizer

Help. I find myself applying moisturizing (with vitamin E) hand sanitizer to my hands every 15 to 30 minutes while in my office at work. It is starting to freak me out a little bit.

Tuesday, January 02, 2007

A few "Grouchy Gripes"

Just a few things that annoy me about the web today...

Web 2.0 expandable sections

I like Google Mail and all that fun stuff but a lot of things about the "next version" of the web are just annoying. One of the things I find most annoying are the "expandable sections"; where you have to click the little plus sign next to or directly on a link to expand and make visible a block of text and/or images. Nowhere is this more annoying than in "frequently asked questions" and technical support pages. I swear if I have to click on another "do you support this feature?" link just to see a "no" open up underneath it I will scream.

Portals just to have portals

A government agency recently changed their perfectly working set of static HTML pages into a hideous, moderately functional, PHP driven "portal" (and yes it has a thing to click on to hide the portal, see above, grrr). Why? Now all of our bookmarks to key pages do not work. Why spent a crap-load of development time on static content? The content of some pages hasn't changed in nine years! The "portal" offers virtually no functionality beyond what was there before.

AJAX bloat

This technology is starting to get out of hand. I see more and more of it cropping up in places where it shouldn't be used. One application I use frequently used AJAX to dynamically build a button bar for editing. I looked at the code (which was working flawlessly without AJAX) and by using AJAX to load button images and insert them as objects into the document object there was a savings of 11K; yup, a whopping 11 kilobytes of transmission. Of course, now there is a mess of JavaScript to do all of this and it causes a memory leak in Opera (the browser I use). If it works perfectly without AJAX then why change everything and risk alienating a minority? Also, one of the things I don't think all these AJAX people realize is that they piss off the "lowest common denominators" out there. There are people with crummy laptops and old computers that cannot handle a lot of this new stuff. There are moms and dads out there with older Pentium computers that cannot justify an upgrade. Meanwhile, the "web gurus" of the world keep adding stuff to something that functioned just perfectly before it.