Archive for February, 2009

My baby is the size of a what?

There’s a lot of mystery about pregnancy, especially for the expectant father.  I can’t feel the baby growing.  I won’t feel it kick, or turn (not necessarily a bad thing, I suppose).  And owed to Wifey being somewhat opaque, I have no idea what baby Wifey looks like!

Pregnancy Web sites do their best to help both Wifey and I relate the growth and development of our baby to things on the outside.  We’re using BabyCenter.com.  (I haven’t been looking at it very often.  Strike one.) You may have read my disdain for the kumquat reference in Week 10.

Unfortunately, Week 11 isn’t much better: future little Wifey is now the size of a fig.

A fig?

Now, I may have been exaggerating when I complained about the kumquat reference.  (In fact, Wifey was kind enough to remind me that she’s prepared kumquats for me in the past.  Strike two.)  But in all honesty, I have absolutely never met a fig that didn’t come dried from a bag. Period.

Much to my surprise (strike three, dummy), the Web site we’ve been following has a photo slideshow of the progression.  Each object used to relate the size of our baby is juxtaposed with a US quarter dollar, which is just the help I needed.  Much to Wifey’s chagrin, week 37’s frame of reference is a small watermelon.  (And if that doesn’t make you grab your own tummy and groan, week 38 is a pumpkin: just in time for Fall.)

So, this post was supposed to be about relating the size of the baby to computer parts.  But now that I have a photographic reference, coming up with 38 relationships between microchips and fetuses seems like a waste of time.   Entertaining to geeks everywhere, but not really any more useful that what the Baby Center has to offer.

OK, OK.  Just one.

At week 15, she’s as big as my iPhone.  There.  I said it.

Time to retreat back to my cave.

Wifey: You’ve never had a real fig before?

Me: No.

Wifey: Never?

Me: No, really.

Wifey: You know, you can get them at Costco, sometimes.  You’ll have to try one.  They’re so sweet!

Me: Is this something I can get when we’re in Mexico?

Wifey: I don’t know.  Figs are something you get in the Fall.

Something tells me that by the time I get around to having a real fig, I’ll be wishing it was a pumpkin.

Day 74 – Addressing the “sickies”

Throwing up sucks.

Guys experience this kind of suffering for one of three reasons

  • We’re ill, as in infected or diseased
  • We’ve had too much to drink
  • We’ve been kicked where… well, you know

A guy vomiting because his body is in the throws of a hormonal shift?  Not likely. Unless, of course, the guy is actually a pregnant lady who looks like a man.  What a strange and wonderful world we live in.

This past Sunday marked the turning of the 10th week.  We are ten weeks pregnant.  I am feeling no ill-effects, except a little sleep deprivation and some pain in my abdomen (struck somewhere between the Thai and the crunches).  Our baby “is barely the size of a kumquat.”

(Thank goodness one of us knows what that means – “about the size of a grape” made so much more sense to me on week 9.  I’ll stick with “slightly bigger than a grape” until someone shows me an actual kumquat.)

But I digress.  For Wifey, the passing of the tenth week marks the 4th week of digestive misery.  Clearly, my tummy ache, one-hundred-percent self-inflicted, is no means by which to develop empathy for her condition.  If I were throwing up all the time, I’d throw back a shot of Pepto, or get myself to the doctor, or stop eating.  Unfortunately, not only would none of these “solutions” lead to a net increase in Wifey’s comfort level, none of them are reasonable treatments for her body-turn-incubator.

To date, we have tried

  • Ginger root tea – spicy and bitter (even with honey), initially soothing, but ineffective overall
  • Gingerale – good ol’ Canada Dry, not exactly good for her, but great at soothing the upper phases of the digestive tract
  • Doble Fibra – “Double Fiber,” a brand of toast, made in Mexico, sold in Wal-Mart – has been the “before you get out of bed” primer for the last two and a half weeks, accompanied by a glass of juice
  • Tums – for heartburn
  • Maalox – for heartburn, after we grew tired of the chalky-nasty Tums experience
  • Walking – helps to motivate the lower phases of the digestive tract, but doesn’t do much for the nausea; incidentally, in the depth of February, Wal-Mart is a great place to walk

Today we tried saltines.

Believe it or not, saltines are the most effective treatment: minimal volume (four crackers was enough – five is a serving, which means it can be eaten anytime, even when not hungry), and they provide immediate relief.

Now, we must take into consideration that the effectiveness of this treament may also be getting a boost from Wifey being so near to the end of the first-trimester.  Also, no one should be popping saltines on a regular basis.  If you’re planning on giving this one a shot, make sure to balance the sodium intake with plenty of water.

Still, we’re not taking her ease for granted.  Our toolkit remains full of all the other treatments, and we’ll be doing lots more walking in the months to come.

Trust me: at this phase, empathy is impossible.

Need a great way to show her you care?  I’ve got three words for you guys: clean the house.

Static class awareness coming to PHP 5

From time to time, I go digging through the PHP documentation on PHP.net hoping to discover that the PHP commiters have added better (read: more standardized) support for static properties.  PHP’s implementation of object-oriented programming is good, if a little incomplete and inconsistent with other good object-oriented languages (like Java, for instance – no pun intended).

PHP’s handling of static properties in one such shortcoming.  Typically, properties and methods defined statically are bound to the class definition, and are accessed using a class’ name instead of an instance of it.  For example, a static property named foo of class Bar is accessed Bar::$foo.  Similarly, a static method named world of class Hello is accessed  Hello::world();  PHP incorporates these ideas in a natural fashion.

It is in subclassing that PHP falls all over itself.

Let’s say I want to create a static property named foo on a class Bar. The class definition would look something like this

class Bar {
    static $foo = 'value';
}
copy code

Now, let’s say I want to create a subclass of Bar called BarSubclass.  Typically, if I wanted to provide a new value for the static property foo, I would simply override it in my subclass’ definition like this

class BarSubclass extends Bar {
    static $foo = 'new_value';
}
copy code

One would then expect the following results

echo Bar::$foo; // "value"
echo BarSubclass::$foo; // "new_value"
echo (Bar::$foo != BarSubclass::$foo); // "1" (for true)
copy code

Unfortunately, in PHP land, one gets the following output instead

echo Bar::$foo; // "value"
echo BarSubclass::$foo; // "value"
echo (Bar::$foo != BarSubclass::$foo); // "" (nothing - for false)
copy code

The reasoning behind this doesn’t really matter to me.  I’m sure it has something to do with PHP’s inventors interpreting the word “static” to mean not only “belonging to the class,” but also “not overridable.”

This evening I received a glimmer of hope.  On February 13 someone updated the PHP docs, and in those docs is a new method: get_called_class().  This method, callable only from within the bodies of class methods, returns the name of the class in which the function is being invoked.  The function can discern the name of the class in which it is being called, even if the method is statically defined.  This means that at long last, I can define static methods that correctly identify the class in which they are being called.

Why is this important?

A great feature for an ORM library (like scottlib) would be a static get method through which callers could load indexed instances of objects by their primary key values, e.g.

$obj = MyObject::get(42);
copy code

Until get_called_class(), this was impossible because the definition of the get method existed only at the highest level of the class hierarchy, and there, would be unaware of any subclass that might want to produce an instance of itself instead of the supreme parent.

The only drawback here is that we probably won’t be seeing this functionality in our hosting any time soon.  The feature is planned for version 5.3.0.  PHP is presently in version 5.2.8 (my Mac came with version 5.2.6).  In the meantime I’ll be adding static loaders and method calls to scottlib, each with an extra parameter for the class name.  Once PHP 5.3.0 hits production, the extra parameter will be phased out in favor of get_called_class().

Hold onto your keyboards – PHP is about to get a whole lot cooler.

Gmail filters: NOT from

Lately I’ve been using the Gmail Labs “Multiple Inboxes” feature.  This is really useful because it lets me turn my Gmail inbox into a heads-up-display for different kinds of e-mail.  For now, I’m using this for only two things: separating out unread from read, and separating out the influx of conservative commentary (forwarded to me by a friend from Chicago, go figure).  At the bottom then is my regular inbox.

The problem with this has been that the stuff from Chicago, when unread, shows up in all three places.  What I wanted to do was separate unread, from unread Chicago e-mail, from everything else.  Each inbox in multiple inbox mode is driven by a filter, a feature of Gmail that is really broad and useful.

In filters, the search field acts more like a command line than a simple keyword matching tool.  For instance, if you prefix an e-mail address or name with the keyword from:, you’ll see only messages from that person.  This is different from just searching for the name or e-mail address by itself, whereby you’ll get address, subject, and body keyword matches. There are other prefixes and special keywords too, like to: and subject:, and also is:unread, is:read, and has:attachment.

But what I wanted to do was filter out everything unread and from Chicago.  To do this, I needed a not, as in show me everything that is unread, but not from Chicago. Gmail supports and documents the use of the word NOT in keyword searches, e.g., foo AND bar NOT foobar, but this doesn’t work with the prefixes listed above.  It took a bit of guess and check to figure it out, but eventually I discovered this solution: is:unread from:!email@domain.com.  (Take note of the exclamation point.)

This solution works perfectly, proving once again just how superior Gmail is to all other Web-based e-mail, as well as how well its developers have used patterns for solving their problems.

Day 70

‘Cause it just ain’t official until you’ve announced it on Facebook.

facebook-announcement

Day 67

“I’m never having children.”

I don’t remember why we were talking about it, but Mom and I were discussing children.  This was years ago.  I was being very dramatic, which was par for the course for me at that age.  (Wifey would probably argue that I’m still playing the back-nine on that particular course.)

At that age I was looking around the world and thinking, “Man, what does this world need with yet another little, helpless person?” The world was full of poverty and hunger, racial strife, bad ideas, and lot’s of anger.  The way I remember it, Mom seemed to recall having similar sentiments at my age.  Obama or no Obama, not much in the world has changed since the 90s.  Heck, you could even argue that things have gotten a lot worse around here in the last two years or so.

So why the about-face?  To tell you the truth, I don’t remember the exact moment of the shift.  It was probably more gradual than sudden.

For one thing, I grew up.  The idea of having a child is a bit much for a child himself to be imagining.  On a recent random trip to the local mall I was shocked by the number of teenage parents roaming the aisles.  Little mommies and daddies pushing wee ones in strollers.  Even at twenty-seven there are aspects of being a father that loom large.  But my life is very stable – I have a good job, I have a great marriage, and I have years invested in knowing myself and learning to recognize my limitations.

At some point, having a child of my own began to seem less like burdening the world with another mouth and mind and more like part of the purpose of my being.  Hormones probably played a role in all this, too; but to tell you the truth: I want the challenge.  I want to be a parent.  I want to learn about the world anew, through the eyes of my child.  I want to stand there as my child takes her first steps toward me from her mother’s arms. I want to read to her before bed.  I want to teach her to ride a bicycle.  I want to be there for the after school programs, and the algebra homework.  And all the things in between… even the poopy ones.

When you’re going to be a parent, you receive license to use the word “poopy” in everyday conversation, but not before.

By the way, in case you’re wondering what happened to days 65 and 66, I’ve decided I’m going to give myself a break from this narrative on the weekends.  Besides being the only time I have to get any work done on my side-projects, I need to spend some more time collecting the experiences for filling this category, and a little bit less time writing them down.

Day 64

Babies are expensive, but only when compared to other major purchases.

Compounding this is an unfortunate financial reality: no one will give you a loan to purchase a baby.

In reality, I am far from focused on the expenses that I’m about to accrue. The idea of my child being an investment of anything other than my time and love has never crossed my mind.

But this is also typical of my attitude toward money.  Handing over the management of my finances to my wife has been one of the best choices I have ever made.  For me, managing money is a stressor; but for my wife, it’s a piece of cake.

So, with what can only be considered morbid curiosity (and a little encouragement from Justin), I have started putting together a list of stuff we’re probably going to need.  Although we are hoping to acquire what we need from many sources, I’m going to begin with the assumption that everything we need can be purchased new from the likes of Wal-Mart and Costco.

According to MoneySavingMom.com, Wifey and I are going to need stuff from six general categories:

  • clothing — six onesies, six sleepers, a few pairs of socks, a few hats, and 4-6 blankets
  • a bed, as little Wifey will not be sleeping in our bed
  • a car seat
  • a stroller
  • diapers and wipes
  • and possibly formula

To this list, Wifey adds:

  • bottles
  • a breast pump
  • and a baby-sized plastic wash tub

So, list in hand, I ventured forth to WalMart.com and Costco.com.

Clothing and blankets

Infant clothing comes in packs, like socks.

onesies 4 pack x 2 = $24
sleepers = $60
socks = $10

Strangely enough, I couldn’t find baby hats on the Web sites.  Let’s call that $10.

And I’m going to assume baby blankets are, like their namesake, mini versions of grown-up blankets.  Let’s call that $20.

Bed and bedding

Wifey is very fond of IKEA.  The ridiculous in-store shopping experience notwithstanding (would it kill them to add more shortcuts to the bathrooms?), their products are top-notch.  And if you have any fondness for Legos, assembling an IKEA product is not an experience to be missed.

Not surprisingly, IKEA has a nice collection of baby beds.  We presently have our eyes on the LEKSVIK model, which actually converts from a crib-style bed to a toddler bed.  Gotta love products that grow with the child.

bed – leksvik crib/bed x 1 + sultan blunda mattress = $199

Baby transportation

The options for car seats are many, with little to distinguish one from the next.

Apparently, one begins with what is known to Wal-Mart as an infant car seat.  This is the kind that is two pieces: a base that gets strapped in, and then the carrier basket (for da baby), which connects to the base with a latching mechanism.

We’re not going to pick one out yet, but given the available options we’ll assume that this item can be purchased for less than $100.  Later on we’ll need to budget for another car seat: one with a higher weight rating and maybe convertibility (can face forward or backward).

My wife has stated plainly that the baby’s stroller is to be (a) light and (b) inexpensive.  Wal-Mart has a nice model for $40. Comes in hot pink or black.  Come on black!  (Bad Vegas joke.)

Stuff that ends up in the trash

Does anyone know how many diapers a newborn goes through in a single day?  Assuming we use 8 diapers a day, and 2-4 baby wipes per diaper (Wifey likes to be thorough), we’re looking at some serious cash.

Diapers.com to the rescue.

diapers – 180 size 1 x 2 (for one and a half month’s supply) = $82 (plus S&H)
wipes – Kirkland brand wipes, about 700 to a box = $16

Feed the baby

Um… the whole breast pump thing makes me uncomfortable.  I don’t know why, really.  It’s just something about the idea of it, I guess.  I’ll just add that to my list of reasons why I’m glad I’m the man.

bottles – Dr. Brown’s 7 oz, 2 to a pack x 4 = $60
one breast pump – …? = $150

Other stuff

For now this list includes only what Wifey has asked for.  But if anyone reading this would like to contribute their ideas, please don’t hesitate to leave us a comment!

plastic wash tub = $20

Grand total

Factoring in a six month supply of the stuff that ends up in the trash: $1,040 (with some rounding, because it’s midnight and I’m not at work).

That places baby somewhere between iPhone and car payments on the ideas that put their hands in my pockets scale.  Still, despite what this adventure is going to cost me, I think it’s going to be totally worth it.

(And then came education.  Just kidding!)

Day 63

Tellin’ people important stuff is hard.

“Mr. President, we’re under attack.”

“Your portfolio has lost 75% of its 2005 valuation.”

“Russia has cut off our gas supply.”

But when the news is good, there tends to be a reward for one’s trouble.

“Wifey is pregnant.  Eight weeks.  Yeah, we weren’t planning it.  How do I feel?  Overjoyed.  A little concerned for her.”  People tend to get really excited about pregnancies.

I thought Scott’s eyeballs were going to pop out of his head.  There we were, standing in the dark, in the driveway of a client’s home.  It was really damn cold, but he couldn’t wait any longer.  Poor chap.  I had been teasing him about it for nearly a month.  “I kept calling it my “secret project.”  It was a great game, while it lasted.  So there we were, and he’s jumping up and down like some sort of marsupial.  His reaction was priceless, and I will remember it with clarity for the rest of my life.  “Uncle Scott.”  I love it.

Some people cried.  I cried.  My father had no idea what to say.  To his credit, our common vocabulary has consisted mostly of microprocessors and video games for the last 16 years or so.  I know he’ll come around.  He’s going to make a great grandfather.   My mother seemed intent on impressing upon me the idea of how much this child was going to change my life.  I’m sure she’s right: my life will forever be different, though probably in ways not exactly like those she experienced.

How we relate to people is one way in which Wifey and I are totally different.  When something big happens in my life, I can’t wait to tell everyone about it.  Whether the event be blessed or damned, I have benefited greatly from evaluating the perceptions of others.  My wife is more guarded, placing a greater value on her own inner process.  We meet in the middle, and it’s all good; but sometimes her brooding is hard to watch.  This has been no exception.  In the end, her rewards were immense.  The warmth she received from her family poured over her like a warm summer rain.  And as she sat there before me, drenched in spirit, I couldn’t help but share her sentiment:

It’s all going to be OK.

Calculate the distance between two U.S. zip codes

Every once in a while a Web developer gets the opportunity to use those math skills he honed in college.  (I suppose this is only theoretical, since I didn’t go to college.)

We’re working on a project that calls for restricting search results to those occurring within a fixed distance from a user-supplied zip code.  The premise is simple enough: discover the geographical location of two zip codes and calculate the distance between them.  Of course, there are a few prerequisites:

  • a database of geocoded zip codes
  • a formula for calculating the distance between them

I thought the first resource would be difficult to find, especially considering my budget for this project is exactly $0.  But lo and behold, much to my surprise and delight, the folks over at PopularData.com provide such a resource, and it’s free!  (As well it should be, since it’s probably based on the U.S. Census data collected in 2000 or earlier.)  They claim that the database is mostly complete, except for a few dropouts (most of which, they say, are military stations, and not too useful to our application.)

I had built an application similar to this one in the past, so I knew somewhere someone had written down the formula for calculating the distance.  Remember that it’s not just a simple point to point calculation.  No, that would be too easy.  You see, the Earth is round.  (No, really.)  And the curvature of the Earth increases the distance between two points.  Oh, if only Columbus had been wrong: think of how much gas we’d save!

In fact, the formula for calculating this distance is known as the Haversine formula. You can read more about it, if you wanna; but it basically goes like this (in JavaScript):

var R = 6371; // circumference of the Earth, in kilometers
var dLat = (lat2-lat1).toRad();
var dLon = (lon2-lon1).toRad();
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
Math.sin(dLon/2) * Math.sin(dLon/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
copy code

For our application, we basically want a view of our zip code data that represents the set of zip codes within X miles (or kilometers) of a given zip code origin.  We’ll use that view to filter our other records before returning those to the end-user.  To achieve this, I’ve written three MySQL procedures:

  • function km, which performs the calculation between two sets of latitude and longitude coordinates
  • function miles, which relies on km to do the calculation, and then converts the result to miles
  • procedure inside, which accepts two parameters: a zip code origin, and a maximum distance with units (km for kilometers, and mi for miles)

So, to query those zip codes within a ten mile radius of my home, the SQL looks something like this:

CALL inside('22601', '10mi');
copy code

And the results are a bit like this:

"22601",39.1697,-78.1686,"WINCHESTER","VA",0
"22604",39.1676,-78.1686,"WINCHESTER","VA",0.142347455024719
"22655",39.1634,-78.2462,"STEPHENS CITY","VA",4.17041921615601
"22656",39.2137,-78.0901,"STEPHENSON","VA",5.17398071289062
"22602",39.1501,-78.269,"WINCHESTER","VA",5.53605270385742
"22603",39.264,-78.1989,"WINCHESTER","VA",6.70094060897827
"22638",39.2369,-78.2885,"WINCHESTER","VA",7.90875339508057
"22624",39.2719,-78.0998,"CLEAR BROOK","VA",7.94622468948364
"22622",39.2543,-78.0664,"BRUCETOWN","VA",7.98962259292603
"22611",39.1357,-77.9919,"BERRYVILLE","VA",9.72859001159668
copy code

To increase the usefulness of the result set, we sort the results of the stored procedure by their distance from the origin: least to greatest.

I hope this turns out to be as useful for you as it is for us.  If you’d like to get a head start, feel free to download our source files:

Day 62

Be forewarned: Day 62 is not for the squeamish.  We’re gonna talk about blood.

My father-in-law had a saying.  “No blood, no pain.”  Sorta makes sense, right?  Surely if you’re bleeding, you’re experiencing some pain, even if that pain is “merely” emotional.  Of course, being a programmer and an extrovert (and a smart ass), I love to point out when people make errors in converse logic:

If bleeding, then in pain is not logically equivalent to If not bleeding, then not in pain.

Once upon a time, Wifey broke a bone.  I think it was in her foot.  And this hurt, of course.  But her father would have nothing of it.  “No blood, no pain.”  And so she went to bed with a broken foot.  Low and behold, the next morning, her foot had grown to twice its normal size.

If not in pain, then not bleedingIf in pain, something is wrong.

But every rule has its exceptions.  I think I was in early adolescence when I first heard the word spotting.  Perhaps this is because between my tenth and fourteenth years, I lived in a small apartment with my mother and my younger sister (younger by one year).  I learned all sorts of stuff about the female reproductive system and its cycle, most of it the hard way.

The normal menstrual cycle follows the rule. 

If bleeding, then in pain.

From what I gather through observation, the menstrual cycle hurts a lot.  First, depending upon her susceptibility to hormonal fluctuations, the patient experiences something akin to insanity (not to be confused with actual insanity). Then, the cramping experienced prior to and during menstrual bleeding seems to be some of the most uncomfortable pain imaginable.  I mean, leg cramps aren’t much fun; but I can’t imagine experiencing a leg cramp in my abdomen.

Spotting, however, is something altogether different.  Spotting is the appearance of minute amounts of blood, exiting from whence blood is expected, just not at the right time.  Spotting can occur prior to the normal menstrual cycle; can occur at the time the ovum is embedded into the wall of the uterus; and, as we have experienced, can occur at 1 AM when it’s approximately 3 degrees (Fahrenheit) outside.  The confusing part is that this kind of bleeding isn’t necessarily associated with pain, thus breaking the rule.

If bleeding and not in pain, then… what?

Not long after we found out we were pregnant, we had a bit of a scare.  Nothing beats going to the E.R. at one in the morning, except for when it’s the middle of January and really damn cold. That’s not to mention the difficulty associated with assimilating the idea of your wife experiencing a miscarriage.

Apparently, a tiny corner of the placenta had torn away from the wall of the uterus.  Assuming the tear does not continue, normal blood clotting occurs, the torn tissue dies, and the whole mess gets reabsorbed by the body. They called her spotting — which was quite a bit heavier than any other spotting she’d experienced — a threatened miscarriage.  This sounds like something an angry baby would do.  “If you eat beans one more time, why I outta!”

If bleeding and pregnant, do not wait for pain.

After the exhaustion and stress subsided, we were able to reflect fondly upon the evening.  Not only did we have the reassurance of a blood test, but through ultrasound Wifey got her first glimpse at our baby.  (Note to husbands everywhere: if they say they’re taking your wife to do an ultrasound, go along, even if it is 3 AM and you can barely see.  They didn’t offer, so I thought nothing of it.  I regret this.)  Seeing and hearing the heartbeat made the pregnancy very real for her, on a level that her physical symptoms had failed to achieve.

If bleeding, then alive.

Older Posts »

Subscribe to Perseverance Trumps Talent