Tofu-stuffed eggplant with mushroom ragout

Tofu-stuffed eggplant with mushroom ragout

Tofu-stuffed eggplant with mushroom ragout

Tofu-stuffed eggplant with mushroom ragout in baking dish

Tofu-stuffed eggplant with mushroom ragout in baking dish

Tonight I made a new recipe. Clare had bought some mushrooms the other day, and I bought eggplant yesterday. I thought that an eggplant mushroom ragout sounded good, though I didn’t know exactly what it would entail. I googled it, and found 2 good possibilities. The first possibility, which I did not choose, was more what I would think of as stuffed eggplant. It involved slicing the eggplants in half and filling them. This particular recipe seemed to throw away most of the eggplant flesh though, which seemed strange to me. The second choice, which I did make, instead called for rolling up thin slices of eggplant. I decided that the eggplant would taste better this way, so I went with it.

Even though it took several hours, the result was very tasty, and worth the effort. I followed the recipe almost verbatim, except that I substituted dried tarragon for fresh basil in the stuffing, since my basil plant is pretty much dead. Clare enjoyed it too, though as I predicted, she wasn’t too wild about the sun-dried tomatoes. She couldn’t put her finger on it until I told her the ingredients though. She also mentioned that I should have put more olive oil on the eggplant, which is correct.

Posted in cooking | Comments Off on Tofu-stuffed eggplant with mushroom ragout

Multi-column balanced lists

List with balanced columns

List with balanced columns

List with unbalanced columns

List with unbalanced columns

Recently I was working on a project where a client wanted a list of items to be displayed over multiple columns, and requested that the columns be balanced (as balanced as possible). It didn’t take me too long to figure out how to do this for 3 columns, but I knew that there was a more general solution, which did take me a little time to figure out. I am sharing my solution here for my future reference. Perhaps some one else will find it useful too. The solution is in php, though the general algorithm should apply to any language.

The intuition that led me to this solution was to examine unbalanced columns. Let’s look at the case of 5 columns with 56 items, as shown in the figures. It quickly becomes obvious that you need 12 items per column (ceil(56/5)). However, this yields columns of lengths 12, 12, 12, 12 and 8. If you decrease the number of total items to 55, then you have balanced columns of 11. If you increase the number of items to 60, you have balanced columns of 12. Thus, it is possible for the last column to have n-1 items less than the other columns, where n is the number of columns. The preferred output is to have columns of 12, 11, 11, 11, and 11. So what we are doing is shifting over elements from columns 2, 3, and 4 to column 5 (note that we are not messing with the order of the elements). We can always achieve the desired result by simply decreasing the number of items from some of the columns by 1. To determine which columns to decrease, we simply look at the difference in the number of elements per column in the unbalanced solution. In the case of 5 columns with 56 items, the last column would only have 8 items, which is 4 less than 12. So we should start reducing the number of items per column at the 2nd column ((5-4)+1). If we had 57 items total, we would start reducing at the 3rd column ((5-3)+1).

Here is the snippet of code which takes care of figuring this out:

$numCols = 5;
$numItems = 56;
$itemsPerCol = ceil($numItems / $numCols);
$adjustedItemsPerCol=$itemsPerCol;
$blank =$itemsPerCol - ($numItems % $itemsPerCol);
if ($blank!=$itemsPerCol && $blank >0) {
  $adjustedItemsPerCol--;
}

While we are looping over our array of items (or, in my example case, using a while loop), we check to see which column we are on, and if we are on the column where we start to decrease the number of items per column, then we switch $itemsPerCol to $adjustedItemsPerCol.

if ($colNum == ($numCols - $blank)) {
  $itemsPerCol=$adjustedItemsPerCol;
}

Feel free to look at this working example, along with the code for it. I have used the CSS float property to make the divs act like columns, and added some colors to help them stand out.

Posted in (x)html, css, php, wordpress | Comments Off on Multi-column balanced lists

A year of new recipes

Working towards 52 new recipes in 2009

Working towards 52 new recipes in 2009

My resolution for 2009 was to make 52 new recipes throughout the year, or roughly one per week. I tracked my progress using kibotzer.com. I didn’t quite reach my goal, but I ended up making 45 new recipes, and I am pretty satisfied with that. Most of the recipes were from cookbooks I already own or from the internet, but some were my own inspirations. For most of the recipes, I also blogged a little about them, so that I would remember how I made them. In 2010, I am looking forward to revisiting many of these recipes, and continuing to improve upon them to fit my taste.

I tried this goal once several years ago, and enjoyed it, but by June the goal had definitely slipped my mind. Kibotzer helped me keep working towards my goal through gentle reminders every month or so, plus having my goal public also gave me a little extra incentive.

Here is a little slideshow of most of the recipes I tried.
[slideshow]

Posted in cooking | Comments Off on A year of new recipes

Rigatoni with seitan puttanesca sauce

Rigatoni with seitan puttanesca sauce

Rigatoni with seitan puttanesca sauce

This was my last new recipe for 2009, and it was fairly improvised. I had recently looked up puttanesca in wikipedia, discovering that it is a “pantry dish”, meaning that most of the ingredients are staples in an Italian pantry, and mine too. I did alter it a bit. Normally it has anchovies, which I omitted, and normally it does not have onions which I added. And I also added in some seitan for protein. The result was quite tasty.

Here is what I used:

  • 3 cloves garlic
  • 2 pasilla (poblano) peppers
  • 1 large onion
  • 1 can mock pork (seitan)
  • 20 green olives, chopped
  • 2 cans petite diced tomatoes
  • 1 can tomato paste
  • 2 tsp capers
  • 1 cup white wine
  • Italian seasonings
Posted in cooking | Comments Off on Rigatoni with seitan puttanesca sauce

WordPress 2.9 image changes

WordPress 2.9 has several new image enhancements. One of the biggest features is some basic image editing functionality. Another one is that you can now specify different alt text from the “caption” field. The “caption” field places a caption under the image. The “alt” text is used to describe the picture to non-seeing users (including search engines). This is a nice addition. However, I usually like my caption, alt text, and title text to be all the same, and I don’t like to have to enter it all manually or copy and paste. By default, wordpress will use an IPTC caption as its “description” field, which shows up in the title attribute of the image. This is nice, since I can add a caption in my image editing program of choice (Picasa) and then I don’t have to enter it again. Except for those pesky alt and caption fields, which are blank by default.

This is particularly important if I am uploading many pictures. So I wrote a little sql which will set the “caption” and “alt text” fields to be the same as the description. I already had this working for the “caption” field for quite some time, but getting it to work for the different alt text handling in 2.9 was a bit tricky, since I discovered that the alt text is not stored in wp_posts like the other fields. Instead it is stored in the wp_postmeta table, which is new in 2.9. Although it took me awhile to figure this out, the new table is a welcome addition. Now for each image you upload, wordpress stores meta information in this table, including the width and height, different sized versions of the file, the IPTC caption, some EXIF info and a few other goodies. This means that if you like to include EXIF info about your pictures, that doing so requires only a simple database lookup, instead of having to read the headers from the image, which should be considerably faster I would imagine.

Now for my little SQL which sets the “caption” and “alt text” to be the same as the description. I run this on my server after uploading pictures. It would be even better if I could figure out how to do this as a wordpress plugin.

-- First we set the image caption (post_excerpt) to be the same as the
-- description (post_content)
UPDATE wp_posts SET post_excerpt=post_content WHERE post_type='attachment' AND
DATE(post_date)=curdate();

-- Next we set the alternative text to be the same as the post_excerpt
INSERT INTO wp_postmeta (wp_postmeta.post_id, wp_postmeta.meta_value) SELECT
DISTINCT wp_posts.ID, wp_posts.post_excerpt FROM wp_posts, wp_postmeta WHERE
wp_posts.ID=wp_postmeta.post_id AND post_type='attachment' AND
DATE(post_date)=curdate();

-- This line sets the correct meta_key for the previous line, which doesn't
-- seem possible otherwise
UPDATE wp_postmeta SET meta_key='_wp_attachment_image_alt' WHERE meta_key IS
NULL;
Posted in sql, wiki/cms, wordpress | 2 Comments