Thanksgiving!

December 1, 2009 2:43 pm

Kyle and I went to Frisco, TX to see my family for Thanksgiving. We flew out Tuesday evening (our flight was delayed for mechanical problems, so we got in VERY late) and came back early Saturday morning. We would have liked to stay longer, but it would have cost big bucks to stretch it any longer. Insane. But we really enjoyed our quick trip anyway.

Part of the reason it was such a priority to get out there was that Chance, Rachael, and Maddox hadn’t yet gotten to meet Kyle! But they all finally got to meet, which was good. It took Maddox a while to warm up to Kyle, but by the time we left, he had acknowledged him as a human being. Sometimes with a name! “Uncle Kyled,” he calls him. Here’s Chance and Rachael:P1000494

We spent Wednesday just hanging around the house, mostly. We played Mario Kart and Guitar Hero with Colton (who actually beat Kyle pretty bad at GH!).P1000482

Chance, Rachael, and Maddox came over and I got to play with him and try to remind him that he already knew me, so he didn’t really need to be afraid of me. The process was significantly sped up by playing with old McDonald’s chicken nuggets toys. Also reading video game manuals. Basically, we all goofed around most of the day. It was lovely.

P1000492 P1000486On Thanksgiving morning, Chance, Colton, Cameron, and Dad went to the ward Turkey Bowl, but Kyle chickened out on the grounds that he hadn’t brought anything warm enough to play football in that early in the morning. We were already up at this point, though, so I dragged him into the office and made him watch while I rediscovered a bunch of my favorite childhood books. This was definitely a highlight of the trip.

Later on, everybody came back and we got ready for dinner. Mom and Dad had invited Shelley and Robbin Holley to join us, so they came over, too, which is always fun. Dad barbecued the turkey, and we had all the classic sides, just like I like (though Mom says every year that we need new stuff, ‘cuz it’s boring…blah blah blah). And delicious pies for dessert! We played cards and Scattergories later on, and talked all afternoon. It was a great time, and I’m so glad we were there. Here’s a couple of random pictures from that day:P1000493 P1000490

Friday was our last day in Frisco, and again, we didn’t do a whole lot. (Actually, all this time, Kyle was doing quite a bit of work on the registry website, but I’m sure he’ll post about that some time far more intelligently than I could, so I’ll leave it at that.) I took one of my completed cross stitch projects with me so that Mom could “help” me make it into a bell pull. See, I know how to cross stitch, but I can’t really sew. Plus, I don’t have a sewing machine. But Mom does, and she’s a genius! And a benevolent one at that. So she agreed to “assist” me with this (I’d like to avoid having every single one of my cross stitches get framed so they all look exactly the same, y’know? And since this one is actually designed to be made into a bell pull, it seemed ideal for doing something else with.) Anyway, she made it into this:

Mom madet this cross stitch I did into a bell pull over Thanksgiving break.And isn’t it great? Now I just need to find some kind of hanging hardware (which is being slightly more difficult than I thought it would be). I’ll probably end up getting a dowel rod and finials and staining them; I just don’t want to stain them. Call me lazy.

Anyway, we all went out for dinner Friday night at the restaurant I used to work at, which was slightly odd just because I have all these vivid memories of working there, but it’s been ten years, so nobody remembers me at all. Which is fine. Just slightly odd.

And then it was before the crack of dawn Saturday and time to go. It was so good to see and get to talk to everybody! I miss you guys.

Grails: Querying across associations

November 24, 2009 9:45 am

Another nerdy post. Grails is a pretty good framework. I’m a python guy, so I prefer Django, but when forced to use Java-like things Grails is better than the alternative. However, it’s still young. Django and Grails are both currently on their 1.1.1 releases, but Django is much more mature for its age.

In Django it’s really easy to query across related objects (they’re called “related objects” in Django and “associations” in Grails). Grails is still struggling with this. (Grails is also struggling with good, in-depth documentation, but that’s not the purpose of this post.)

After much searching all I could find was some forum posts by the project lead of Grails, Graeme Rocher, from 2007 saying that nested associations aren’t currently (as of 2007) supported.

Nested Associations: Suppose I have 3 classes: Person, Family, and Country. Suppose the classes are designed such that each person belongs to a family and each family is linked to an origin country. Now suppose you want to get a list of all persons whose family is from England. Persons don’t have a direct link to that information, so you’d need to hop through the family to get to the country.

Based on the current setup you’d expect to be able to do something like:

Person.withCriteria {
family {
country {
eq("name", "England")
}
}
}

And you can. So for anyone searching for how to do this and finding that old post from 2007 saying you can’t: it’s wrong. You can.

But now let’s pickup where I left off in my previous post with separating out query pieces for re-usability and adherence to the DRY principle.

We need to build a criteria object specifically and separate out the criteria to a separate closure:

def someView = {
def critBuilder = Person.createCriteria()
def critClosure = { filterByEngland.curry(critBuilder)() }
def results = critBuilder.list(max:params.max, offset:params.offset, critClosure)
def totalCount = results.totalCount
}

def filterByEngland = {critBuilder ->
critBuilder.family {
critBuilder.country {
eq("name", "England")
}
}
}

And now we can combine that with other pieces of modularized code. I have my queries broken up so that I can easy sort using different functions based on what kind of output the data is going to be used in. So you can have something like this:

def someView = {
def critBuilder = Person.createCriteria()
def critClosure = {
filterByEngland.curry(critBuilder)()
sortForCSV.curry(critBuilder)()
// sortForXML.curry(critBuilder)()
}
def results = critBuilder.list(max:params.max, offset:params.offset, critClosure)
def totalCount = results.totalCount
[results: results, totalCount: totalCount]
}

def filterByEngland = {critBuilder ->
critBuilder.family {
critBuilder.country {
eq("name", "England")
}
}
}

def sortForCSV = {critBuilder ->
critBuilder.order("lastName", "asc")
critBuilder.order("firstName", "asc")
critBuilder.order("age", "asc")
}

def sortForXML = {critBuilder ->
critBuilder.family {
critBuilder.country {
order("name", "asc")
}
order("id", "asc")
}
}


Since this nested association querying isn’t documented anywhere (that I could find) and the only mention is that it _doesn’t_ work, it was a pain in the butt figuring it out.

Other gripes with Grails. I can’t define a relation to another class unless it is based on the primary_key of the classes. A less-than-usual case for sure, but there really isn’t any good reason to disallow such a situation.

And now my feet hurt.

November 20, 2009 3:14 pm

I’ve spent my afternoon scrubbing mildew out of windowsills. (How is it suddenly there in such large, disgusting amounts, when it was previously not there at all?) Blergh. The worst was pulling back the blinds in front of the patio door. [shudder]

If anybody has any magical tips for preventing/easily getting rid of* said pestilence, I’d love to hear them. This is something we’ve not had to deal with before. Do not like.

*I know I can use bleach, but I’m scared of getting it on the carpet (some of the mildew is around the patio door) or something and ruining the carpet. And I’ve heard that rolled up towels on the windowsills will catch the water and help, but I’m not sure how much that will help (I haven’t tried it) and I don’t like the idea of how it would look. I may be willing to at least try it, though, if there aren’t any better options. Some of these are porous surfaces, which makes them rather difficult to clean. Today’s method was just a wet rag and Fantastik, which worked okay, but there’s gotta be something better. 🙁

Life at Work

November 12, 2009 9:13 pm

I’ve been working some small projects to prototype using Groovy and Grails as our new framework. It’s been fun to focus on a small project with enough time to actually polish it up nicely. The Grails framework lets us actually focus on functionality rather than minutiae that make the system function. So we’ve been putting together a nice little system which uses Ajax to provide a quick and clean interface.

Halloween

8:51 pm

Ok, we’ve been lazy about Halloween. Ok, Ok, blogging Halloween was _my_ job, so I’ve been lazy.

Anyway. The week before Halloween we went out to a farm in Lathrop which was supposed to have a pumpkin patch which would allow you to pick a pumpkin straight from the vine (unlike the “pumpkin patch” in Livermore which trucks them in and lines them up). So we headed out there for the pumpkin patch, and corn mazes, aand pumpkin CANNONS!

It turned out that the pumpkin was a bit lame. It looks like it had been an actual patch, but it looked like they had done their best to destroy any vines that had been there.

But we did still go through a corn maze:DSCN4427Jess didn’t particularly enjoy the corn maze. She felt that if she wanted to be lost, she could just go walk around town for 10 minutes. After wandering for a bit we picked a wall and followed it all around until we got out. There were 3 mazes, but we only did one.

Then we headed over to the CANNONS! You get a bucket of small pumpkins that you can load one-at-a-time into your compressed-air cannon. It was getting dark and the lighting was crappy so the pictures aren’t very good. In this one you can see one of the targets you get to aim at, a giant jack o’ lantern. There was a good 6 feet of piled pumpkin remains at its base:DSCN4430And here’s Jess:DSCN4433
So that was fun. The pumpkin cannons were definitely worth it.

We bought a pumpkin from the grocery store because it was cheaper than the “pumpkin patch”. We didn’t get around to carving it until Halloween. I began working on a top-secret pumpkin exo-skeleton project:DSCN4442It didn’t work out very well. But the jack o’ lantern was pretty decent:DSCN4444We sat about waiting for trick-or-treaters (with a big bowl of candy) but were rather disappointed in that regard. We had one family with 3 small kids come by. That was it. So now we have a bunch of candy to eat (and Jess got more for 75% off at CVS after Halloween). Since the door wasn’t busy Dr. Horrible walked down to Panda Express for traditional Halloween cuisine (the new SweetFire Chicken Breast is awesome, I can’t eat Orange Chicken anymore):DSCN4450