Saturday 24 November 2012

Asus USB-N13 with Raspberry Pi

This weekend I set up my Raspberry Pi to connect to my home wireless network using an Asus USB-N13. The process was quite painless:
  • Install debian wheezy on a SD card, boot the Raspberry Pi off it.
  • Plug in a wired network connection.
  • As root (run "sudo -s") run "apt-get update".
  • As root, run "apt-get upgrade".
  • Plug in the Asus USB-N13.
  • Do a "lsusb" and make sure you see an entry for the wireless adaptor (the Bus and Device values may change):
Bus 001 Device 004: ID 0b05:17ab ASUSTek Computer, Inc. USB-N13 802.11n Network Adapter (rev. B1) [Realtek RTL8192CU]

  • As root, run "apt-get install firmware-realtek" to make sure we have the Realtek firmware binaries installed.
  • As root, run "apt-get install wicd" to install Wicd: a network connection manager.
  • Start up the GUI (run "startx" from console if you booted into console).
  • Start "wicd-gtk".
  • Use the UI to configure your wireless adaptor.
  • Disconnect the wired ethernet and reboot your Raspberry Pi.
  • A few minutes after booting, Wicd should do its magic and the Raspberry Pi will appear on your network.

Lamb steaks in beer marinade ver 1

Following up from the last post, I made lamb steaks in beer marinade as well.

Ingredients

  • 1.5kg Lamb steaks
  • A handful of fresh Rosemary (from our garden)
  • One onion
  • Whole grain mustard
  • Half a bottle of Grolsch beer
  • Garlic
  • Lemon juice
  • Olive Oil
Equipment
  • Gas barbecue
Marinade
Make the marinade by chopping the onion finely and then add mustard, garlic, and lemon juice. Lightly rub olive oil onto lamb steaks, and add steaks to marinade. Pour half a bottle of beer into the steaks + marinade and refrigerate for an hour.

Cooking
Start the barbecue, and wait for the temperature to reach about 200 degrees Celsius. Cook the lamb steaks on the hot plate side.

Stuff to try next time
This wasn't too bad for a first time experiment, but the lamb steaks felt like they were missing something: it felt like the meat needed something to develop its flavour. I added some orange verjuice to the lamb before serving and this improved the lamb, but it needs something more cooked into the dish. Next time I'll try roasting some dried paprika on the hot plates before cooking the lamb, or I might try adding some citrus zest.

Slow Cooked Beef Ribs ver 2

It's a summer Sunday, which means I try out some barbecue dishes. Today's experiment is slow cooked barbecue beef ribs.

Ingredients

  • 1 kilogram beef ribs, from the Willetton Bucher in Southlands.
  • Zach's original style barbecue brisket rub, from www.usafoods.com.au or David Jones.
  • 2 tablespoons Chilli Powder
  • Ardmona Pizza sauce (comes in a squirt bottle)
  • 2 tablespoons Apple cider vinegar
  • 1 tablespoon Worcestershire sauce
  • 1 teaspoon Whole grain mustard
  • 2 tablespoons Brown sugar

Equipment
  • Weber barbecue
  • Aluminium pie dish trays for hickory chips and water
  • Hickory chips
  • Water
  • Heat beads

Preparation (on the previous evening)
  1. Remove the membrane from the back of the beef ribs.
  2. Coat evenly in Zach's barbecue rub.
  3. Keep refrigerated overnight.

Slow Cooking
Set up Weber for smoking, aiming for a temperature of between 80 and 100 degrees Celsius. Place a drip catching tray on the lower rack, and place the ribs on the top rack. Cook for about 5 hours.


Barbecue Sauce
Mix brown sugar with apple cider vinegar and then heat in microwave for ~30 seconds. This will warm up the mixture enough to dissolve the sugar. Add chilli powder, worcestershire sauce and mustard and mix. Add  a small amount of pizza sauce (a couple of short squirts).


Finishing
At the 5 hour mark, glaze the ribs with the barbecue sauce. Cook for another 15 minutes, then remove from barbecue and serve.

Notes
Where is version 1? I'll post that another day. :)

Wednesday 21 November 2012

Don't modify an Entity that's under Enumeration

Ran into a problem today with Entity Framework complaining that I was modifying an Entity that was under enumeration elsewhere in code. It's common knowledge that modifying a collection that's being enumerated isn't a good idea, but the EF exception that came out didn't make it very obvious:

New transaction is not allowed because there are other threads running in the session.

The culprit was (class names have been anonymised):

foreach (var other in context.Widgets.Where(widget => widget.Box_ID == ID))
{
  // do something with each Widget
}


What the code should have been was:

foreach (var other in context.Widgets.Where(widget => widget.Box_ID == ID).ToList())
{
  // do something with each Widget
}


EF needs to be asked to fetch the whole result set before starting the enumeration: The IQueryable<T> needs to be converted to an IEnumerable<T>. To do this, call ToList() or ToArray() on the IQueryable<T>. After making this change, the exception won't occur any more!

I think this is occurring because there's a transaction enumerating the result of a query, and another transaction which is modifying an entity. These two transactions eventually collide: In the first transaction, rows are fetched and converted into Entities, and these Entities are tracked by EF. Later on, EF loads one of these tracked entities again and the calling code tries to make some changes to it. As EF is already tracking the entity from the first transaction, you get this exception because it exists in two places and their contents is inconsistent.

At the end of the day, this is the old "don't modify things under enumeration" problem, wrapped up in a database :)