Tuesday, October 27, 2009

Mielie Bread Recipe

2 cups flour
3 teaspoons baking powder
1 tin creamed sweetcorn
2 eggs
1 tablespoon sugar
½ teaspoon salt
3 Tablespoons melted butter
½ cup milk

Sift flour, salt, baking powder. Add sugar. Beat eggs, add milk, sweetcorn and (cool) melted butter and mix. Gradually add liquid mixture to dry ingredients, stirring to ensure smoothness.
Bake at 1800 C for approx. 35 minutes, reduce temperature to 1400 and cook for a further 15-25 minutes until set.

Crumpet Recipe

1 egg
2 Tablespoons sugar
pinch salt
1 cup flour
3 teaspoons baking powder
¾ cup milk
2 Tablespoons oil

Beat egg and sugar till light and fluffy. Add milk. Sift salt, flour and baking powder. Gradually add egg and milk mixture, stirring to keep batter smooth. Lastly, gently stir in oil. Do not beat as this will destroy baking powder action. Cook in lightly greased pre-heated pan on a medium-high temperature.

Marie Biscuit Fudge Recipe

Ingredients

1 pkt. crushed Marie biscuits
250g butter
1 egg
1 pkt. icing sugar
3 level Tablespoons of cocoa

large, shallow dish

Method

1. crush biscuits
2. beat egg
3. melt butter
4. add cocoa and beaten egg to molten butter
5. mix in icing sugar and crushed biscuits
6. stir well - until icing sugar is melted and biscuits are evenly mixed
7. grease a large shallow dish with butter, until there is a thin layer across the whole interior surface
8. pour the fudge mixture into the greased dish
9. refrigerate - for 6 to 8 hours
10. during cooling, when the fudge has started to set, but still not yet rock hard, cut into squares

Peanut Butter Biscuit Recipe

125 grams butter 1 ½ cups flour
½ cup brown sugar ¾ teaspoon bicarb.
½ cup white sugar ¼ teaspoon salt
1 egg (beaten) ½ cup peanut butter
½ teaspoon vanilla

Heat oven to 2000 C . Grease baking sheet. Cream butter and sugar, add egg and essence and beat well. Sift dry ingredients and add to cream mixture. Mix well. Add peanut butter to form a soft dough. Roll out and flatten on floured surface. Cut biscuits into desired shapes. Bake for 5-20 minutes. Cool.

Date Loaf Recipe

1 cup chopped dates
¼ teaspoon salt
½ cup sugar
1 rounded teaspoon butter
1 ½ cups flour
1 cup boiling water
1 teaspoon bicarbonate of soda
½ cup chopped nuts/raising/mixed fruit
1 egg

Pour boiling water over bicarb. Pour over chopped dates while fizzy. Mix well to soften dates. Add butter, sugar, nuts/raising and beaten egg, stirring well with each addition. Separately, sift flour and salt. Add to date mixture when cool. Bake in loaf pan at 1800 C for 45-60 minutes.

Banana Loaf Recipe

2 eggs
1 ½ cups sugar
¼ lb. butter or 3 tablespoons cooking oil
3 cups flour
4 ripe bananas, mashed with a little lemon juice
1 cup milk
2 teaspoons bakiing powder
½ teaspoon bicarb. of soda
½ teaspoon salt

Cream butter and sugar i.e. mix and beat till creamy. Add eggs, beat well. Then add bananas, mashed with a fork. Dissolve bicarb in 1 tablespoon hot water. Add enough milk to fill one cup. Sift dry ingredients together. Add alternately with milk to egg mixture. Bake in greased tin/2 tins at 180o C for 1 hr. or until done. Makes one big or two smaller loaves.

Pasta Recipe

Home made pasta

250 g (= 2¼ cups) bread (durum wheat) flour
1 teaspoon salt
3 small eggs (beaten)
1 tablespoon olive oil

sift flour and salt into
add egss and oil
knead and roll (with pin) to a homogeneous paste
wrap paste in cling film
age for 30 minutes
roll & cut pasta to size
dry pieces by laying on an adsorbent surface (e.g. paper towl) for 30 minutes
cook in boiling salted water for 3-5 minutes

Basil Pesto Recipe

How to Make Pesto like an Italian Grandmother

One key to perfect pesto is chopping all the ingredients by hand, preferably with a sharp mezzaluna or knife. I gave my double-bladed mezzaluna to a friend last year because it was collecting dust (I also didn't like how ingredients would get stuck between the blades), but have a large half-moon shaped pizza cutter that works like a dream. Francesca's mom even approved and said it cut her chopping time in half. This pesto will keep a bit in the refrigerator, but it really hits its peak when served soon after it is made.

The technique here is: chop a bit, add some ingredients, chop some more. I think part of the reason she does it this way (instead of chopping everything all at once) is because some things get chopped into oblivion, while some not as much - it encourages specturm of cut sizes throughout the pesto contributing to the overall texture. All told, the chopping took me a leisurely twenty to thirty minutes, I wasn't in any particular rush.

You'll notice this recipe doesn't have any added salt (just the saltiness from the cheese), make sure your pasta water is well salted if you are going to use this pesto on pasta or the overall flavor profile will fall flat. Also, be sure to adjust for seasoning before serving. With food this simple, you need to get the seasoning right.

1 large bunch of basil, leaves only, washed and dried

3 medium cloves of garlic

one small handful of raw pine nuts

roughly 3/4 cup Parmesan, loosely packed and FRESHLY GRATED

A few tablespoons of extra-virgin olive oil

Special equipment: large mezzaluna for chopping

Start chopping the garlic along with about 1/3 of the basil leaves. Once this is loosely chopped add more basil, chop some more, add the rest of the basil, chop some more. I scrape and chop, gather and chop. At this point the basil and garlic should be a very fine mince. Add about half the pine nuts, chop. Add the rest of the pine nuts, chop. Add half of the Parmesan, chop. Add the rest of the Parmesan, and chop. In the end you want a chop so fine that you can press all the ingredients into a basil "cake" - see the photo up above. Transfer the pesto "cake" to a small bowl (not much bigger than the cake). Cover with a bit of olive oil, it doesn't take much, just a few tablespoons.

You can set this aside or place it in the refrigerator until you are ready to use it. Just before serving give the pesto a quick stir to incorporate some of the oil into the basil. She occasionally thins the pesto with a splash of pasta water for more coverage, but for our gnocchi this wasn't necessary.

Makes about 1 cup.

SciPy

Anders Andreasen's two-part piece on graphing with SciPy
part 1
part 2

Data Visualisation in Linux

See Tims Jones' IBM white paper on the subject.

Wednesday, October 21, 2009

log4net - Force New (Specified) Log File


private static readonly ILog alog = LogManager.GetLogger("AlgoLogger");

public void SwitchToNewUniqueAlgoLogFile(long scheduleID)
{
ILoggerRepository logRepos = LogManager.GetRepository();
IAppender[] logAppenders = logRepos.GetAppenders();

string targetAppenderName = "myAppender"

// first find the logger we are actually looking for

for (int i = 0; i < logAppenders.Length; i++)
{
IAppender appender = logAppenders[i];

if (appender.Name == targetAppenderName )
{
// cast generic appender to our type
RollingFileAppender rfa = appender as RollingFileAppender;

// get full name of current log file
string oldFName = rfa.File;

// extract path
int indexOfLastSlash = oldFName.LastIndexOf(@"\");
string path = oldFName.Substring(0, indexOfLastSlash + 1);

// generate new log file name
string newLogFileName = "newLog.txt"
string newFullFileName = path + newLogFileName;

// set new file name
rfa.File = newFullFileName;

// indicate to change
rfa.ActivateOptions();

break;
}
}
}

Switching Log-Files During Logging



private static readonly ILog alog = LogManager.GetLogger("AlgoLogger");

public void SwitchToNewUniqueAlgoLogFile(long scheduleID)
{
ILoggerRepository logRepos = LogManager.GetRepository();
IAppender[] logAppenders = logRepos.GetAppenders();

string targetAppenderName = "myAppender"

// first find the logger we are actually looking for

for (int i = 0; i < logAppenders.Length; i++)
{
IAppender appender = logAppenders[i];

if (appender.Name == targetAppenderName )
{
// cast generic appender to our type
RollingFileAppender rfa = appender as RollingFileAppender;
string oldFName = rfa.File;
int indexOfLastSlash = oldFName.LastIndexOf(@"\");
string path = oldFName.Substring(0, indexOfLastSlash + 1);

// generate new log file name

string scheduleName = SQLHandler.GetScheduleName(scheduleID);

string newLogFileName = "newLog.txt"
string newFullFileName = path + newLogFileName ;

rfa.File = newFullFileName;
rfa.ActivateOptions();

break;
}
}
}

Thursday, October 1, 2009

Debugging Python

The standard python includes includes a debug module : PDB
Python Docs Entry @ doc.python.org

Cheat Sheet

reqd to use the debugger
= import pdb

define breakpoint
= pdb.set_trace()
halts program execution, and drops you into the debugger console

commands available within debugger console
n = execute next line of code, making entire method call
s = execute next line, stepping into any method calls
c = continue to next break point
q = quit
!xxxxx = execute python instruction xxxxx

Tutorials
- Ayman Hourieh Blog Post
- Steve Ferg Blog Post
- SonTek / John Anderson Blog Post

C# Object.CompareTo(otherOb)

big.CompareTo(small) = 1
self.CompareTo(self) = 0
small.CompareTo(big) = -1