Friday, July 27, 2007

Transforming Mac OS X Property List (plist) XML Files for Easier Handling


If you've every dealt with a Mac OS X property list XML file (.plist), such as that produced when exporting an iTunes playlist file, then you've maybe noticed the structure is a pain to work with, especially with respect to XSL transformations.




Consider an example:




<plist version="1.0">
<dict>
<key>Major Version</key><integer>1</integer>
<key>Minor Version</key><integer>1</integer>
<key>Application Version</key><string>7.3.1</string>
...



The xpath expression to select the Application Version looks something like:




/plist/dict/string[preceding-sibling::key[1] = 'Application Version']



All those selectors using "preceding-sibling" are a pain to write and less-than-clear. I think it's helpful to first transform the plist into a more useful form first. What if we could make the above plist snippet look like the following:




<?xml version="1.0"?>
<plist version="1.0">
<dict>
<entry key="Major Version">
<integer>1</integer>
</entry>
<entry key="Minor Version">
<integer>1</integer>
</entry>
<entry key="Application Version">
<string>7.3.1</string>
</entry>
...



With this new form, we can now rewrite our selector as:




/plist/dict/entry[@key = 'Application Version']/string



It's more concise, easier to write, and clear about what is actual going on in the code. I like it. We can use XSL to transform any plist XML file into this new form. The transform is as follows:




<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:apply-templates mode="element" />
</xsl:template>

<xsl:template mode="element" match="dict">
<xsl:copy>
<xsl:for-each select="@*">
<xsl:attribute name="{name()}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="dict" select="key" />
</xsl:copy>
</xsl:template>

<xsl:template mode="dict" match="key">
<xsl:element name="entry">
<xsl:attribute name="key">
<xsl:value-of select="." />
</xsl:attribute>
<xsl:apply-templates mode="element" select="following-sibling::*[1]" />
</xsl:element>
</xsl:template>

<xsl:template mode="element" match="*" >
<xsl:copy>
<xsl:for-each select="@*">
<xsl:attribute name="{name()}">
<xsl:value-of select="." />
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates mode="element" />
</xsl:copy>
</xsl:template>

</xsl:stylesheet>



In Mac OS X, you can apply this transform right at the command line with the xsltproc command.

Sunday, July 15, 2007

Maple Bacon Cupcakes

Tired of vegetarians stealing all your cupcakes? Finally, a solution. Credit to Jon Hsieh, who sent me this recipe most likely after hearing of my illustrious history of bacon baked goods (bacon cookies anyone?). I made these recently for a cookout, where they were definitely a hit with some and feared by others. I felt the flavor was good, but the texture was a little coarse for my tastes. I've modified the original recipe for maybe a bit of improvement?



4 1/2 Tbsp. of butter, room temperature

1/2 Tbsp. of bacon drippings (left in the fridge to become solid)

5 Tbsp. of brown sugar

1 egg

1 1/4 cup of all purpose flour

1 tsp. of baking soda

1/2 tsp. of baking powder

tiny tiny pinch of kosher salt

4 Tbsp. maple syrup

1/4 cup of milk

1/4 cup of minced bacon, cooked and drained



Cook some bacon in a fry pan (about 6 thick strips). Reserve the drippings and place in the fridge to solidify. Mince 1/4 a cup of the bacon. The chef should eat whatever is left to assure that the bacon is tasty.



Beat the crud out of the butter and solidified bacon fat 'till light and creamy. Add the brown sugar and beat well until combined. Add the egg and beat until incorporated.



Sift the flour, salt, baking soda and powder together. Combine the milk and maple syrup. Alternate additions of half of the flour, half of the liquid, the remaining flour, and finally the remaining liquid, mixing each addition just until combined. Fold in the bacon bits. Scoop into cupcake papers and bake at 350 F for 18-22 minutes or until a toothpick comes out clean.



Maple Syrup Frosting



4 Tbsp. of butter

2 Tbsp. of maple syrup

1 cup of powdered sugar

turbinado sugar (optional, but recommended)

coarse grain sea salt (optional, but recommended)



Combine the syrup and butter until combined. Add the sugar, a bit at a time, and whip at high speeds until combined. Pipe or spread onto cupcakes. Sprinkle on sea salt and turbinado sugar for decoration and a lot of added flavor.

Chocolate Revel Bars

Chocolate Revel Bars are a good answer to the question, "I love oatmeal cookies and I love brownies... can't I have both?"



Crust



1 Cup butter, softened

2 1/2 Cups flour

2 Cups packed brown sugar

2 eggs

2 tsp. vanilla

1 tsp. baking soda

3 Cups quick rolled oats



Filling



1 1/2 Cups semi-sweet chocolate pieces

1 14-oz. can sweetened condensed milk

2 Tbsp. butter

1/2 Cup chopped walnuts or pecans

2 tsp. vanilla



Directions



In a large mixing bowl, beat the 1 cup butter till softened. Add half the flour to the butter. Add brown sugar, eggs, 2 tsp. vanilla and baking soda. Beat until throughly combined. Beat in remaining flour and oats; set aside.



For the filling, in a medium saucepan, heat the chocolate pieces, condensed milk, and the 2 Tbsp. butter over low heat until the chocolate is just melted, stirring occasionally. Remove from heat. Stir in the pecans and 2 tsp. vanilla.



For the crust, press 2/3 of the oat mixture into the bottom of an ungreased 13x9 inch baking pan. Spread the filling over the crust. Drop the remaining oat mixture by teaspoons on top of the chocolate layer. Bake in a 350˚ oven 25-30 minutes or until the top is lightly browned.

Wednesday, July 11, 2007

Pie Crust for Fun and Profit

With Optional Apple Upgrade

Makes two 9" pie crusts

The Ingredients

3 cups flour
1 1/2 tsp. salt
1/3 cup butter
2/3 cup + 2 Tbsp. butter-flavored shortening
~8 Tbsp. ice-cold water

The general rule of thumb is to keep everything cold: the shortening and butter, the water, even the flour. I keep my butter in the fridge and my shortening in the freezer to keep both as cold as possible, but still workable. Warm dough gets sticky, which means you have to add more flour, which makes the final dough tough. You can optionally use lard in place of the shortening, but be sure to find one that doesn't taste so much like bacon.

Cutting the Shortening

Mix the flour and salt in a large bowl. Put the butter and shortening in the bowl, and put it in the fridge for a while (5-10 minutes). Once everything is nice and chill, cut the butter and shortening into the flour using a pastry blender until it has a chunky consistency, with chunks about the size of small peas. Work quickly so as to avoid heating up the shortening too much. Also, be sure to use a cutting motion (vertical) with the blender and resist the urge to grind with the blender.

Another approach that works well when you don't have a pastry fork (or even when you do) is to freeze the butter and shortening ahead of time and then grate them right into the flour with a cheese-grater. You then work the mixture with your fingers for 30-60 seconds until the desired consistency is reached.

Adding the Water

Begin adding the water to the dough in 1 Tbsp. increments, mixing with a fork. The goal is not to thoroughly mix, but simply moisten the ingredients. Depending on the humidity and other mysterious factors, you may need to add less than or more than the full 8 Tbsp. of water. A good test to see whether your dough is ready is to pinch a few pieces together and see if they stick together without dry cracks.

Preparing to Roll

At this point, the dough can be divided into two and formed into two balls. Try not to work the dough too much; the goal is not to kneed the dough. The balls can be wrapped in plastic wrap or waxed paper and kept in the fridge while you are preparing the rest of the ingredients for you pie. In fact, you should probably refrigerate the dough for a while before rolling regardless of when you will need the dough. When you are ready to roll, remove the dough from the fridge, let it warm back up for 20 minutes, and then press the dough with your hands into a flat disk about 2" thick on a floured pastry cloth.

Oh We Rolling Now

Begin rolling the dough, always starting in the center of the disk and moving outwards. After each roll, pick another path 30º off the original, so that you slowly work around all directions of the crust, creating a nice, consistent circle.

When the circle has reached desired thickness and size, loosely place a piece of plastic wrap over the dough and then gently fold the dough in half, such that you're left with a half-circle of dough. The dough is a lot easier to move this way and the saran wrap keep it from sticking to itself. Place the half-circle of dough into a pie plate and unfold the dough.

Cool Decorative Stuff Goes Here

Adding decorative borders to crust is an art-form not easily described with words. The basic gist is to trim the dough so about an 1 to 2 inches overhang the edge of the pie plate. Next, fold the dough underneath itself so that a small curl of pie dough is sitting on top of the lip of the pie plate. At this point, you can do all sorts of decorative pinching, molding, and squeezing. Or you could just bake it as is, and you'd be fine.

On The Topic of Pre-Baked Crusts

When you need to pre-bake your crust for use in a cream pie, be sure to take a fork and liberally poke many holes into the crust. These holes will allow hot air to escape from underneath the crust when baking. Without the holes, the crust would balloon up and generally, it'd be bad. When poking, be sure to wiggle the fork around a little bit so as to open up the holes. Just stabbing the dough will create small holes that will seal back up as the dough is heated in the oven. Be sure to refrigerate the crust before baking; the crust must be chilled for proper results. Generally, bake the crust in a 450º oven for 9-11 minutes, checking towards the end for proper browning.

Extra Credit: Apple Pie

6 cups apple (Golden D + Granny Smith)
1/4 cup flour
3/4-1 cup sugar
1 tsp. cinnamon

The key to a good apple pie is good apples. Specifically, you want something that's a little bit sweet, a little bit tangy, but most importantly, an apple that will not bake down to mush. Crisp apples like Golden D and Granny Smiths work well. Avoid Red Delicious like the plague. Regional apples likes Jonagold, Honeycrips, Pacific Rose, and other varieties are worth a look too.

Peel and core and cut the apples into 1/2-inch-think slices. Mix the apples and the remaining ingredients, adjusting the sugar based on the sweetness of the apples. Let apples sit and juice up for about five minutes.

You'll have previously wanted to prepare the two 9" pie crusts mentioned above. Roll out one of the crusts and place it into a pie dish. Pour the apples into the pie dish, spreading evenly. Cut a few tablespoons of butter up and place the chunks randomly over the apples. Roll out the remaining pie crust and place it over the top of the pie. Proceed to trim and crimp the edge of the crust as described above.

So that the pie doesn't explode while baking, cut a few triangular slits in the center of the pie crust. These can be as decorative as your knife skills allow, but their main purpose is to allow and outlet for hot, expanding air inside the pie as it bakes. Try not to cut the holes close to the edge, as the filling tends to bubble out.

To get nice browning of the crust, you may wish to brush the top of the crust with a little milk, or an egg mixed with milk. Keep an eye on the pie as it is baking. If it's looking too brown, you can cover it with tin foil to stop the browning.

Bake the pie at 400º for 15 minutes. Reduce the temperature to 375º and bake an additional 20-30 minutes. You can tell the pie is done because the filling will appear bubbly.

Enjoy.

Tuesday, July 10, 2007

File Sharing Websites

Looking for a good website to send a large file to a friend or two? There are a ton of sites out there, but some are definitely better than others. Here is my take on the sites to use:



Good



senduit : A very simple, non-intrusive site that does simple sharing and does it right, with fast downloads to boot. [maxfilesize: 100 MB]



yousendit : One of the more prominent sites, it's simple, non-intrusive, and has fast downloads. Also one of the few sites with bandwidth limits, so do the math before sharing a large file with lots of people. [maxfilesize: 100 MB, maxdownloads: 100, maxbandwidth: 1G]



mediafire : Similar to yousendit, but without download caps. [maxfilesize: 100 MB]



Bad



sendspace : Slightly larger file sizes are offset by the ad-heavy layout and broken-support for download managers and slowish download speeds [maxfilesize: 300 MB]



zshare : Clean, unobtrusive interface, but sluggish download [maxfilesize: 100 MB]



zupload : Larger file size supported but also more ads and sluggish downloads [maxfilesize: 500 MB]



uploadhut : Small file size, more ads, and super sluggish downloads [maxfilesize: 50 MB]



rapidshare : Ad-heavy interface and so-so speeds [maxfilesize: 100 MB]



sharebee : More of a meta-file-share, it uploads your file to a number of other file-share sites. Unfortunately, it uses mostly bad ones. [maxfilesize: 100 MB]




Ugly



The following sites are infested with invasive pop-up ads, time delays that force you to look at ads before downloading, and other shenanigans:



megaupload
turboupload
depositfiles
sharebigfiles



None of the following sites worked for me:



filefactory
spread-it
mytempdir