Whole Wheat Oatmeal Teff Chocolate Chip Cookies

| No Comments | No TrackBacks

The title is quite a mouthful, and so are these cookies! Crunchy, soft, crumbly, textured, tasty, and as it happens, vegan and parve! I made this recipe up last weekend while it was raining in San Francisco, and had a hankering for cookies. Ate a bunch, and brought the rest in to work to share and meet my coworkers. We all knew it was a rainy weekend, because the company message board was full of "extra cookies in the break room!" messages :)

2/3 cup whole wheat flour
2/3 c. oatmeal
1/3 c. teff flour
1/2 c. sugar (white, demerara, brown, etc.)
1/3 c. olive oil
1/3 c. dark chocolate chips
2 tbsp. vanilla
1 tsp. baking soda
1 tsp. baking powder

Now you're probably looking through that list and thinking, "Ok, all that looks familiar, except for that teff stuff. What's that!?" Teff is a grain grown in Ethiopia. It's one of the most protein-dense grains, and also the smallest whole grain. Ethiopians use it to make their native style of bread, called injera, which I can best describe as a sourdough crêpe. Bob's Red Mill sells teff flour, available at most natural foods stores and Whole Foods.

Next time I make this recipe, I might also throw in some frozen concentrated orange juice to add a little bit more binding to the finished batter. Eggs would do the trick, too, but I didn't have any in the fridge when I whipped this up.

Ikea Hacking: Gorm Wine Rack

| No Comments | No TrackBacks
Gorm assembly hint: get a 10mm socket for your drill-driver.10mm nut driver bit

Ikea has at least half a dozen options for wine storage, but its Gorm shelf system takes the cake for versatility. The Gorm is made of solid, unfinished pine, allowing you to hack it more easily than Ikea products made of cardboard, spit shine veneer, and plastic cams. Gorms can stand alone, be chained together, mixed-and-matched with any part in the series, and, because of its simple, solid wood construction, sawed, drilled, screwed, painted, or stained to your heart's content.

Gorm Wine and Glass Rack For this hack, I started with a Gorm 30"w x 13"d x 68"h kit, using three of the four shelves, and mixed in three more Gorm wine rack shelves. Before I left Ikea, I went over to the parts department and got eight more screws to match the ones that hold the backstays onto the Gorm.

Adding stemware hangers to a Gorm shelf I picked up two chrome wine glass racks and a dozen wine glasses from Bed, Bath & Beyond, screwed the racks to the underside of the top Gorm shelf (with those extra screws from Ikea), and voilà, my very own wine bar!

Python Meta Decorators

| No Comments | No TrackBacks
Recently, I was working on a project in Python framework that was built around decorators. Each of my functions needed something like six decorators, each with its own arguments, but mostly all the same. I thought, "This is a classic case of cut-and-paste coding; there has to be a better way!" I toiled over decorators for a while, and finally came up with this pattern:
def monkey(arg):
  def outer(f):
    def inner(*args, **kwargs):
      print "Monkey: %s" % arg
      f(*args, **kwargs)
    return inner
  return outer

def zombie(arg):
  def outer(f):
    def inner(*args, **kwargs):
      print "Zombie: %s" % arg
      f(*args, **kwargs)
    return inner
  return outer

def wrapper(m, z):
  def outer(f):
    @monkey(m)
    @zombie(z)
    def inner(*args, **kwargs):
      f(*args, **kwargs)
    return inner
  return outer

@wrapper("coconut", "brains")
def mytesta(foo):
  print foo

@wrapper("bacon", "chainsaw")
def mytestb(foo):
  print foo

mytesta("Hello World")
mytestb("Hello World")
What I'm doing here is first setting up two standard argument-taking decorators, @monkey and @zombie. Then I'm setting up a decorator that returns a decorated function, whose arguments are built at decoration time. This lets me template out a complex decoration pattern where only a few arguments need to change for each function, and pass just those arguments into my meta-decorator. This is the output:
Monkey: coconut
Zombie: brains
Hello World

Monkey: bacon
Zombie: chainsaw
Hello World

The Globe

| No Comments | No TrackBacks

Since it's my birthday, I'll share my new favorite drink:

The Globe
from the SFist

3 oz. 209 Gin
1 oz. St. Germain
1 oz. lime juice
1/2 oz. agave nectar

Shake and serve up with a mint garnish.

Convert a Postfix queue to mbox format

| No Comments | No TrackBacks

Today I wanted to convert the contents of my postfix 'deferred' queue, which was all spam stuck in my MTA, to mbox format so that I could feed it into various spam-learning systems.

First I converted my Postfix queue to human-readable format with postcat:

cd /var/spool/postfix/deferred
mkdir spam
for i in {0..9} {A..F}; do mkdir spam/$i; done
for i in `ls */*`; do postcat $i > spam/$i; done

This made a copy of each file in postcat format, but that's only halfway there -- postcat has its own output format that isn't anything like an mbox or a maildir. Inspecting the output, and brushing up on my sed, I came up with this:

sed -n '
  /^\*\*\* ENVELOPE/,/^\*\*\* MESSAGE CONTENTS/ {
    /^message_arrival_time:/ {
      s/^message_arrival_time: \(.*\)$/\1/
      h
    }
    /^sender:/ {
      s/^sender: \(.*\)$/\1/
      H
      g
      s/\(.*\)\n\(.*\)/From \2 \1/
      p
    }
  }
  /^\*\*\* MESSAGE CONTENTS/,/^\*\*\* HEADER EXTRACTED/ {
    /^\*\*\* MESSAGE CONTENTS/ d
    s/^\*\*\* HEADER EXTRACTED.*$//
    s/^\(>*From \)/>\1/
    p
}' -

A final pass over all of the messages, and I had my mbox file to train SpamAssassin with:

for i in `ls */*`; do sh mkmbox.sh < $i >> spam.mbox; done
sa-learn --spam --mbox spam.mbox

Recipe for Seitan Stew

| No Comments | No TrackBacks

Found in a backcopy of Vegetarian Journal, March 1996:

1 cup of water plus 1/2 cup water
1 ounce dried wild mushrooms
1 Tablespoon oil
1 large onion, chopped
2 carrots, diced
3 small turnips, peeled and cut in quarters
4-5 small potatoes, cut in half
1/2 pound mushrooms, halved
3 dried tomatoes, made into powder
8 ounces seitan, cut in small chunks
1 teaspoon dried rosemary
1 teaspoon dried thyme
1 teaspoon dried sage
1 Tablespoon miso
1 Tablespoon arrowroot
2 Tablespoons fresh chopped parsley
Black pepper to taste

Boil one cup of the water and soak the dried mushrooms (if they are morels or shiitake) for 30 minutes. Save soaking water. If using porcini add when recommended.

Heat oil in pan over medium heat. Add onion, carrot, turnips, and potatoes. Sauté for 3 to 5 minutes until onion begins to soften. Add fresh mushrooms, tomato powder, and 1/4 cup water. Cook for 5 more minutes. Then add seitan chunks, dried herbs, and rehydrated mushrooms that have been cut in pieces. Cook for 5 more minutes.

Add soaking water drained of any debris and porcini, if using them. Add the miso and stir. Cook for about 10 more minutes until vegetables are almost tender.

Combine the remaining 1/4 cup water with the arrowroot and add to the pan over medium heat, stirring until thickened. If too thick add water 1 tablespoon at a time. If too thin add arrowroot 1 teaspoon at a time. Season with black pepper. Add parsley just before serving.

A recent AP story about health care spotlights the sort of close-minded, numb stupidity that fuels anti-reformers:

Andrew Newcomb, 28, who works in sales and lives near Destin, Fla., said he doesn't think taxpayers should have to take on the costs of covering the uninsured.

"I don't want my tax money to pay for some pill-popper to fake some injury and go to the hospital when I don't ever go to the hospital," said Newcomb, adding he can afford to go to the doctor and pay $60 for a checkup.

Andrew, since you never go to the hospital, I'm sure it won't ever be a problem. But if you do get sick, be sure to die quickly. Otherwise you might cost us taxpayers a lot of money at a taxpayer-funded emergency room.

Updating Soekris firmware using Kermit

| No Comments | No TrackBacks
I've had trouble getting minicom's xmodem to fully upload a Soekris firmware image over USB serial adapters, and I've never been a big fan of minicom in the first place. I like good old Kermit. Recently I discovered how to get Kermit to speak xmodem, and used it to update the firmware on my Soekris Net4801.

First, install kermit and lrzsz. Next, connect your Soekris box. Now fire up kermit and go!

$ kermit

set protocol xmodem-crc download {} {lsx %s} {} {lrx %s} {}
set line /dev/ttyUSB0
set speed 19200
set carrier-watch off
set flow none
connect

> download -

send /binary firmware-file-name
connect

> flashupdate

Python's Lame Lexical Closures

| No Comments | No TrackBacks
Here's a simple generator function in Python that you can use in a test harness to find out how many times the function was called. Call the function once with an argument, and then each time you call the function again it will return that argument and increment an internal counter. Call the function with the named argument 'got_called' and it will reset and return its current call count.
def GotCalled(ret):
  """Stub that counts how many times it was called."""
  count = [0]

  def _GotCalled(*unused_args, **kwargs):
    if kwargs.get('got_called'):
      lame = count[0]
      count[0] = 0
      return lame
    else:
      count[0] += 1
      return ret

  return _GotCalled
But note how count is a list. And I'm incrementing and returning the first member of the list. Guess what -- you can't use a variable directly in this situation! It'll error out on the 'count += 1' because the act of assigning to the variable in the inner function creates a new instance of that variable, one that hasn't been used before and so fails the + part of the +=. LAME.

Perl Hash Slices

| No Comments | No TrackBacks
One of my favorite things to do with Perl hashes is slice them with this incredibly concise syntax. The first time I saw this, I Just Got It (TM). Lifting a chunk of text from the excellent (though dated) online book Picking Up Perl, here's how it works:

Slices

It turns out you can slice hashes just like you were able to slice arrays. This can be useful if you need to extract a certain set of values out of a hash into a list.
use strict;
my %table = qw/schmoe joe smith john simpson bart/;
my @friends = @table{'schmoe', 'smith'};
# @friends has qw/joe john/
Note the use of the @ in front of the hash name. This shows that we are indeed producing a normal list, and you can use this construct in any list context you would like.

Context Considerations

We have now discussed all the different ways you can use variables in list and scalar context. At this point, it might be helpful to review all the ways we have used variables in different contexts. The table that follows identifies many of the ways variables are used in Perl.
Expression Context Variable Evaluates to
$scalar scalar $scalar, a scalar the value held in $scalar
@array list @array, an array the list of values (in order) held in @array
@array scalar @array, an array the total number of elements in @array (same as $#array + 1)
$array[$x] scalar @array, an array the ($x+1)th element of @array
$#array scalar @array, an array the subscript of the last element in @array (same as @array -1)
@array[$x, $y] list @array, an array a slice, listing two elements from @array (same as ($array[$x], $array[$y]))
"$scalar" scalar (interpolated) $scalar, a scalar a string containing the contents of $scalar
"@array" scalar (interpolated) @array, an array a string containing the elements of @array, separated by spaces
%hash list %hash, a hash a list of alternating keys and values from %hash
$hash{$x} scalar %hash, a hash the element from %hash with the key of $x
@hash{$x, $y} list %hash, a hash a slice, listing two elements from %hash (same as ($hash{$x}, $hash{$y})

Tweets

Loading . . .

Recent Comments

  • SodaBrew: You rewrote the device identification bits so that the system read more
  • Michael: Can you tell me how make the usb storage device read more
  • Дилян Палаузов: Why don't you use the Certificate Subject Alt Name extension read more
  • David: Hello, I'm the developper of Wiclear. I'd like to let read more

Categories