Tuesday, December 7, 2010

In every pot

I've been cooking a lot of chook recently. I'm afraid the family's getting a little tired of chicken stew, but it's just not getting old for me.

From Chicken stew


Looks like we've finally figured out how to make a good chicken stew. I have to confess that I made mediocre chicken stews for years, coasting on the fact that it's hard to really ruin chicken...

So here's how we do it:

First I take down my favourite stew pot: my 5-Quart cast iron Dutch oven by Lodge Logic. I chop up a large onion (or two medium onions, or...) and a few of those "baby carrots" and a couple sticks of celery. I put a healthy thwack of butter into the pan and get it hot. Onions, carrots, and celery go into the butter along with a couple garlic cloves. They get covered in a generous dose of salt and way too much black pepper, then I cook them until the onions are translucent. Once done, I empty the pot into a bowl.

From Chicken stew


Next I brown the chicken. I generally take some leftover bacon grease and add it to the pot, which is already hot. I put in more than enough to cover the bottom: there was a good 1/8 inch of grease in there this last time. I put three or four chicken thighs (skin on) into the grease, put salt and a generous layer of pepper on them, and let them brown. Now here's the thing: when I say "brown", I mean "mahogany". I essentially fry those thighs in that bacon grease for twenty or more minutes. When one side gets brown, I turn them over and do the other side. If I want to use more chicken I brown it in batches of three or four so they all get plenty of one-on-one time with the cast iron and bacon grease.

From Chicken stew


Once the chicken is brown, I put the onions, carrots, and celery back in the pot, cover it, and cook at medium for a good 45 minutes or so.

As the chicken is stewing in the onions, I cut some red potatoes, wash them, and pan-fry them. So I put some bacon grease on the griddle and lay out the potato chunks in it to fry. When one side is brown, I roll them to brown the other. I want the potatoes to have a healthy golden-brown crust.

Once the potatoes are done it's time to pull the skin off the chicken. Chicken skin is high in fat, so you really don't want to eat it.

Then the potatoes go into the pot along with frozen green beans, I cover it, and cook at until it's all done. I like to cook this at a medium on the stove-top, or 250--300F in the oven.

From Chicken stew


Be aware this is not low-fat cooking. It's highly likely you'll have a massive coronary while eating my cooking. But my goodness it's good.

Sunday, December 5, 2010

Wow

I, uh, haven't had a lot to say. More probably I've been too busy to say it.

Friday, July 23, 2010

Every minute

I had a problem with my jaw this week. I woke up Tuesday and it felt out of joint. It hurt Tuesday and Wednesday, and Thursday I was starting to wonder if there was a serious problem. So I made an appointment to go to the Chiropractor and have him pop it back in. This morning I woke up feeling great. But because I had an appointment, I figured I might as well go in.

So I went to the chiropractor with no real complaints, but feeling a sense of obligation because I'd made an appointment.

After 2 1/2 hours, I'm $270 lighter and they want me to come back Tuesday. And bear in mind the reason I went in the first place was a jaw problem that cleared itself up. So it cost me 2 1/2 hours and $270 to feel coming out exactly like I did going in.

And they want me to come back Tuesday for another $60 session. Apparently I have all sorts of spinal alignment issues.

Uh-huh.

I just called them back and canceled my follow-up without a reschedule. They say there's one born every minute, but this time his name's not going to be Ox.

Monday, July 19, 2010

Nice and cozy

Every once in a while, someone gives a gift so extraordinary that it actually impacts how I live my life. Last year, Shanta gave me just such a gift... my Bodum Cozy.

From Bodum Cozy


I love my Bodum Cozy.

Thanks, Shan!

Sunday, July 11, 2010

Grits ain't groceries

Friday nights I make pizza. Saturday mornings Ames makes a huge breakfast.

This last weekend, it was very hot here in the Northwest. I think it was 90 F on Friday when I was biking home. Not perhaps hot by Southern standards, but people here don't generally have air conditioning. So yeah, it was hot. It was hot enough Ames decided to have a light breakfast: she sauteed some onions and peppers, scrambled some eggs, and cut some fruit.

When she called us all for breakfast, the youngest asked what was for breakfast. Ames told her, and she demanded in her most stentorian, Ghost of Christmas Present voice, ``Are there no grits? Is there no bacon?"

Sometimes I'm overcome with pride.

Saturday, June 26, 2010

Tail Recursion

There was a conversation at work a few weeks back on the difference between recursion and iteration. Someone made the claim "Recursion doesn't always work," and pointed out that the Fibonacci Sequence, while easy to implement in naive recursion, tends to blow up when the numbers get large.

I argued that there is an efficient solution using tail-recursion. It's faster than naive recursion, and simpler than an iterative solution.

A third person pointed out tail-recursion is a Scheme thing, and not all languages properly optimize it. This is completely true, but... it's also true that tail-recursive algorithms are in principle more efficient. Abelson and Sussman point out that doesn't always translate into actual performance, though:
most implementations of common languages (including Ada, Pascal, and C) are designed in such a way that the interpretation of any recursive procedure consumes an amount of memory that grows with the number of procedure calls, even when the process described is, in principle, iterative. As a consequence, these languages can describe iterative processes only by resorting to special-purpose ``looping constructs'' such as do, repeat, until, for, and while.


So here's a short test... I wrote a short tail-recursive Fib generator in Common Lisp. Note it takes a number (i.e. the number of terms to generate) and returns a list representing the sequence:

(defun fibonacci-sequence (num)
"Calculate a Fibonacci sequence to a number NUM."
(labels ((fib (n acc)
(cond ((equalp n 0) acc)
(T (fib (1- n)
(cons (+ (car acc)
(cadr acc)) acc))))))
(cond ((= num 0) '(1))
((= num 1) '(1 1))
((> 0 num) 'undefined)
(T (reverse (fib (- num 2) '(1 1)))))))


We can loosely translate that to Perl. Perl doesn't have an equivalent to Common Lisp's 'labels', so I had to write two named functions to implement it. But this short script is more-or-less equivalent to the Lisp version: it takes a number on the command line and prints a list representing a sequence with that number of terms:

#!/usr/bin/perl

=head1 NAME

fib-sequence.pl

=head1 AUTHOR

Clumsy Ox

=head1 SYNOPSIS

fib-sequence.pl $NUMBER

=head1 DESCRIPTION

Calculates the Fibonacci Sequence to $NUMBER terms.

This is just an exercise in tail-recursion.

=cut

use strict;
use warnings;

use Data::Dumper;

my $number = shift;

my @sequence = fibonacci ($number);

print STDOUT join (', ', @sequence), "\n";

=head2 fibonacci

fibonacci ($number) => @sequence

=cut
sub fibonacci {
my $num = shift;

return (1) if $num == 0;
return (1, 1) if $num == 1;

return reverse fibt( $num - 2, 1, 1);
}

=head2 fibt

fibt ($number) => @sequence

=cut
sub fibt {
my $num = shift;
return @_ if $num == 0;
return fibt ( $num - 1, $_[0] + $_[1], @_);
}


Notice both solutions accumulate the sequence as a list. So there is some definite overhead in carrying that sort of data structure, but it's "fair" in the sense that both are having to do it.

Just informally checking it, the Perl solution is slower than the Lisp solution, but not by an amazing amount. I ran a quick-n-dirty test of the Perl solution, and it timed out reasonably. But I found it blew Perl's number stack very quickly and went to 'inf':

bash-3.2$ time ./fib-sequence.pl 10000 > /tmp/output
Deep recursion on subroutine "main::fibt" at ./fib-sequence.pl line 56.

real 0m1.072s
user 0m0.640s
sys 0m0.380s


Just for comparison, Lisp returned:

(time (fib-sequence 10000))
Evaluation took:
0.019 seconds of real time
0.018860 seconds of total run time (0.012529 user, 0.006331 system)
[ Run times consist of 0.010 seconds GC time, and 0.009 seconds non-GC time. ]
100.00% CPU
47,236,537 processor cycles
4,893,824 bytes consed


Both took longer to print the result than to actually calculate it.

I haven't tried the experiment in Java or C, but I think it might be interesting to see what would happen.


Incidentally, according to SBCL, the 10,000th element of the Fibonacci Sequence is a 2090 digit number:

(format t "~:d" (car (last (fib-sequence 10000))))
33,644,764,876,431,783,266,621,612,005,107,543,310,302,148,460,680,063,906,564,769,974,680,081,442,166,662,368,155,595,513,633,734,025,582,065,332,680,836,159,373,734,790,483,865,268,263,040,892,463,056,431,887,354,544,369,559,827,491,606,602,099,884,183,933,864,652,731,300,088,830,269,235,673,613,135,117,579,297,437,854,413,752,130,520,504,347,701,602,264,758,318,906,527,890,855,154,366,159,582,987,279,682,987,510,631,200,575,428,783,453,215,515,103,870,818,298,969,791,613,127,856,265,033,195,487,140,214,287,532,698,187,962,046,936,097,879,900,350,962,302,291,026,368,131,493,195,275,630,227,837,628,441,540,360,584,402,572,114,334,961,180,023,091,208,287,046,088,923,962,328,835,461,505,776,583,271,252,546,093,591,128,203,925,285,393,434,620,904,245,248,929,403,901,706,233,888,991,085,841,065,183,173,360,437,470,737,908,552,631,764,325,733,993,712,871,937,587,746,897,479,926,305,837,065,742,830,161,637,408,969,178,426,378,624,212,835,258,112,820,516,370,298,089,332,099,905,707,920,064,367,426,202,389,783,111,470,054,074,998,459,250,360,633,560,933,883,831,923,386,783,056,136,435,351,892,133,279,732,908,133,732,642,652,633,989,763,922,723,407,882,928,177,953,580,570,993,691,049,175,470,808,931,841,056,146,322,338,217,465,637,321,248,226,383,092,103,297,701,648,054,726,243,842,374,862,411,453,093,812,206,564,914,032,751,086,643,394,517,512,161,526,545,361,333,111,314,042,436,854,805,106,765,843,493,523,836,959,653,428,071,768,775,328,348,234,345,557,366,719,731,392,746,273,629,108,210,679,280,784,718,035,329,131,176,778,924,659,089,938,635,459,327,894,523,777,674,406,192,240,337,638,674,004,021,330,343,297,496,902,028,328,145,933,418,826,817,683,893,072,003,634,795,623,117,103,101,291,953,169,794,607,632,737,589,253,530,772,552,375,943,788,434,504,067,715,555,779,056,450,443,016,640,119,462,580,972,216,729,758,615,026,968,443,146,952,034,614,932,291,105,970,676,243,268,515,992,834,709,891,284,706,740,862,008,587,135,016,260,312,071,903,172,086,094,081,298,321,581,077,282,076,353,186,624,611,278,245,537,208,532,365,305,775,956,430,072,517,744,315,051,539,600,905,168,603,220,349,163,222,640,885,248,852,433,158,051,534,849,622,434,848,299,380,905,070,483,482,449,327,453,732,624,567,755,879,089,187,190,803,662,058,009,594,743,150,052,402,532,709,746,995,318,770,724,376,825,907,419,939,632,265,984,147,498,193,609,285,223,945,039,707,165,443,156,421,328,157,688,908,058,783,183,404,917,434,556,270,520,223,564,846,495,196,112,460,268,313,970,975,069,382,648,706,613,264,507,665,074,611,512,677,522,748,621,598,642,530,711,298,441,182,622,661,057,163,515,069,260,029,861,704,945,425,047,491,378,115,154,139,941,550,671,256,271,197,133,252,763,631,939,606,902,895,650,288,268,608,362,241,082,050,562,430,701,794,976,171,121,233,066,073,310,059,947,366,875


Update: I decided to try a quick-n-dirty Java implementation. It's rough and ugly, but it seems to work.

Here's where it gets interesting: the Java solution works just fine, but it's slow, and it runs into a StackOverflow at just over 10,000 elements. I suspect that could be increased dramatically with some better java runtime settings, but it seems to disprove my thesis that tail recursion is an appropriate solution regardless of implementation language.

I was also able to get Perl to give me better results with
use bignum;
Still, Lisp is by far the fasest solution.

Thursday, June 24, 2010

Poor Navigation

So I'm in Raleigh, NC this week. I head back to the Northwest tomorrow afternoon. Since I'm so close, I lined up lunch with a good friend in Charlotte. It was what they call a "wild hair": a two-to-three hour drive for lunch, but I figured it might be worth it.

I have a pretty sorry little rental car this week, so between my fear of it dying on the Interstate and a desire for a nicer drive, I decided to take 64 to Asheboro, then 49 to Charlotte:

View Larger Map

But I missed the turn from Hwy 1 to Hwy 64 in Apex. I have no idea how I missed it, but I did. I started getting nervous when I saw signs for Southern Pines, but still hadn't seen signs for Siler City.

Yep, I ended up in Moore County, "on the way" to Charlotte. I was south of Sanford.

I had to call both people I meant to meet and tell them. They both laughed, so there were no hard feelings. But I sure felt stupid.

Gah.