Peter Brett's Blog

Sunday, July 26, 2009

Double-chocolate brownies

While CURA were at Bisley for the Imperial Meeting this year, I made the team some of these brownies. They were very much enjoyed by all!

This recipe is designed to make quite firm brownies that travel easily (e.g. on the back of my bike). If you like your brownies nice and squidgy, put less flour in (175 g instead of 225 g).

  • 275 g plain chocolate (50% cocoa solids)
  • 220 g unsalted butter
  • 85 g walnut pieces
  • 170 g milk chocolate (cut into chunks)
  • 225 g plain flour
  • 1 tsp baking powder
  • 4 large eggs, lightly beaten
  • 1 tsp vanilla essence
  • 325 g caster sugar

Pre-heat oven to 170°C (155°C if you've got a fan oven). Line a 30x20x3.5 cm cake tin with lightly buttered greaseproof paper. I find that it makes the brownie easier to extract from the tin if you butter the base of the tin as well.

Melt the plain chocolate and butter in a large (preferably metal) mixing bowl over a pan of simmering water. Remove the pan from the heat and stir in the sugar, followed by the eggs and vanilla essence.

Sieve the flour and baking powder into the mixture, and fold in. Fold in the nuts and chocolate chunks.

Pour the mixture into the cake tin, place in the oven and cook for 20-25 mins. The corners will cook fastest; do not allow them to burn! When cooked, a skewer inserted into the centre of the brownie should come out mostly clean, but it's no big deal if you get a squidgy middle.

Allow to cool in the tin. When cool, remove the brownie from the tin and cut into squares (you should be able to get 24 good-sized pieces from this recipe).

Update: Avoid oil-based chocolate and/or HFCS-based chocolate for this recipe. It won't work.

Labels:

Simple unit tests in Scheme

One nice feature of the Scheme programming is the ridiculous, over-the-top power of its "hygienic" macro system, which allows a programmer to effectively redefine the language to suit the task at hand.

A few days ago, I needed to write some simple unit tests for some Scheme code I was in the process of developing. The Guile Scheme implementation doesn't come with a library for unit testing by default, so it was necessary to create one of my own. This is it:

(define *failed-tests* '())
(define *passed-tests* '())

(define (assert-true result)
  (if (not result)
      (throw 'test-failed-exception
             (with-output-to-string
              (lambda ()
                (display "  assert-true: ")
                (display "got: ")
                (write result))))))

(define (%begin-test name test-thunk)
  (let ((test-success #t)
        (test-fail-msg #f))
    (display name) (display "... ")

    (catch #t test-thunk
           (lambda (key . args)
             (set! test-success #f)
             (set! test-fail-msg
             (if (eqv? key 'test-failed-exception)
                 (car args)
                 (with-output-to-string
                  (lambda ()
                    (display "  unexpected exception: ")
                    (write (cons key args))))))))

    (if test-success
        (begin
          (display "passed")
          (set! *passed-tests* (cons name *passed-tests*)))
        (begin
          (display "failed")
          (if test-fail-msg
              (begin
                (newline)
                (display test-fail-msg)))
          (set! *failed-tests* (cons name *failed-tests*))))
    (newline)))

(define-syntax begin-test
    (syntax-rules ()
      ((_ name . test-forms)
       (%begin-test name (lambda () . test-forms)))))

(define (report-tests)
  (display "Test summary")(newline)
  (display "Passed: ") (display (length *passed-tests*)) (newline)
  (display "Failed: ") (display (length *failed-tests*)) (newline))

Note that this effectively adds a keyword (begin-test) to the Scheme language, and this very simple macro has a massive effect on the readability of the resulting testcase code. For example, a trivial unit test using this minimalistic framework might look like:

(begin-test 'SuccessfulTest
  (assert-true #t)
  (assert-true (equal? 1 1)))
(begin-test 'FailTest
  (assert-true (equal? #t "string")))
(report-tests)

The framework is completed with the addition a few more assert- functions (left as an exercise to the reader). This code will form part of a future release of gEDA.

(In case you want to use this code in your own project, it is licensed under the GNU LGPL v3 or later). But there are probably better unit test systems for Scheme out there!

Labels:

Saturday, July 18, 2009

Enchiladas

While I'm on a roll with the recipes, here's my recipe for chicken enchiladas. It's probably not particularly authentic, but I enjoy them! This recipe serves 2 moderately hungry people.

Enchilada sauce

  • 400 g can of chopped tomatoes
  • 1 clove garlic, chopped
  • Fresh chilis, chopped
  • 1 tbsp olive oil

I usually use 2-3 of the normal chilis sold in Tesco or Sainsbury's (with the seeds left in), but I like my echiladas nice and spicy! With those chilis, I find them a bit impotent with the seeds left out.

Fry the chilis and garlic in the olive oil for 2-3 minutes over a medium heat. Add the chopped tomatoes and simmer for 20-30 minutes until most of the excess liquid has evaporated leaving a thick, spicy tomato sauce.

This can easily be made in advance, and freezes well.

Fried chicken filling

This is a very simple filling -- use your imagination and come up with your own! Try other meats, fried peppers or mushrooms, seafood, cheese... Also consider marinating the chicken with spices before frying.

  • 300 g chicken breast, cut into strips
  • 10 g fresh ginger, grated
  • Dried paprika
  • Salt & pepper
  • Half a medium cooking onion, coarsely chopped.
  • 1 tbsp olive oil

Heat the oil over a high heat in a wide-based frying pan. Add the onion, chicken, ginger, and paprika, and season the chicken to taste. Fry until the chicken is cooked through, then set aside.

Like the sauce, this can easily be made in advance.

Putting it all together

  • 4 corn tortilla wraps
  • 150 g grated cheese (cheddar works okay)

Pre-heat the oven to 150°C. Microwave the tortilla wraps for 15-20 seconds until they are warm and flexible. Divide the filling between them, roll them up, and place them together in a small roasting tin. Spread the enchilada sauce generously over the tortillas (making sure to coat them all over). Top with the cheese and salt and pepper to taste.

Bake in the oven for 15-20 minutes, and serve with green salad and spring onions.

Labels:

Friday, July 17, 2009

This will seem like bragging...

This will seem like bragging, but in retrospect I really did rather well at Cambridge. These are the prizes and scholarships I was awarded over my four years:

  • Emily Davies Scholarship (twice)
  • Henry Tompkinson Scholarship
  • Beatrice Mills Prize
  • Rosalind, Lady Carlisle Prize
  • Raemakers Prize
  • Accenture Second Year Computing Prize
  • i2 Ltd. Third Year Computer-Based Project Prize

Of course, those successes paled into insignificance alongside the accomplishments of some of my peers at certain prestigious inner-city colleges, but I think I did okay for a hick from the sticks (i.e. a Girtonian)!

Edit: I forgot to mention that I also blagged a (large) award from the academic funds for a plane ticket to a conference at MIT. But that was more of a success in terms of "social engineering" than actual engineering!

Wednesday, July 01, 2009

Starting my PhD!

As I mentioned in January, I was awarded a PhD studentship at Surrey Space Centre. I graduated from Cambridge last Friday, with I Class honours in my BA and a Distinction in my MEng, moved down to south-west Woking at the weekend, and started at SSC today!

I'm having to fight a bit to get a Linux workstation -- other groups in the same building (and serviced by the same IT staff!) use Fedora on their desktops, but SSC has historically been an all-Windows environment. In a corporate setting, I might put up with Windows -- there, at least, there is often a reasonably well-staffed IT services department to take care of the innumerable things that go wrong -- but in my experience, PhD students don't get quite that level of support. If I'm going to be solving my own problems, I want to do it with more powerful tools. (Also, Emacs on Windows isn't nearly as much fun. How can I possibly survive without a properly-functioning compilation-mode?)

Nevertheless, I think I'm eventually going to win the battle. In the meantime, it looks like I'll have to make do with Cygwin.

As far as the research is concerned, I've barely start to dip my big toe into the scalding bathtub of things I don't know, and it feels like I've got a long, long way to go before I get to the things no-one else knows either!

Update: I managed to persuade the computing folks to give me second PC running Linux and a USB KVM switch. So that's alright, then.

Chorizo and tomato pasta

Another chorizo recipe that I made to use up what was left over from the previous one. Note that I use Spanish chorizo, not Mexican (as most commonly found in the USA).

Ingredients (serves 3-4):

  • 150 g dried chorizo sausage, diced finely
  • 1 medium cooking onion, coarsely chopped
  • 1 clove garlic, chopped
  • 100 g mushrooms, sliced
  • 400 g can chopped tomatoes
  • Olive oil
  • Balsamic vinegar
  • Dried tarragon
  • 2 small bay leaves
  • Black pepper

In a wide-based saucepan, heat a tablespoon of olive oil, and fry the onion and chorizo for 2-3 minutes (or until the onion is translucent). Add the mushrooms and garlic, and continue to fry until the mushrooms begin to darken and shrink. Add the tomatoes, and stir in the dried tarragon, bay leaves, black pepper, and about a tablespoon of balsamic vinegar. Cover and simmer gently for 20-30 minutes.

Serve with pasta and fresh green salad.

Labels:

Page Menu