Archive for the ‘General’ Category

Feeding cheese to monkeys

Tuesday, July 28th, 2009

Sometimes you’ve got a monkey and he won’t sit still. How do you manage to take a picture of him? The answer is simple. Feed him cheese. Try our non-patented, copylefted Cheese, now with burst mode support.

Example:



Organising unit tests in Haskell

Sunday, July 5th, 2009

I’ve had a lot on my plate recently so I’ve gone a bit underground. The DTubes stuff is still limping along, but it turns out that I wasn’t the only one with that idea and that others seem to be working on it with much more gusto. Banshee now supports sharing your playlist over DTubes i.e. with all your IM contacts. I don’t use Banshee, but this feature could convert me to their cause. My timelapse patch for Cheese will hopefully be finished today, or at least early next week.

What has been occupying most of my time (apart from Monster and research) is getting into this Haskell thing. I’m coming in through the back door I suppose. I’ve taken over maintenance of a Haskell library for automata theory. I’ve largely given up on libAMoRE, the codebase is featurefull but a nightmare to maintain. It’s time to start over, and in a higher level language than C. Luckily Prof. Simon Thompson from the University of Kent already had an automata library. It’s the minix of automata libraries as it strives for understandable code over micro-optimisation. It is also written in Haskell. He was even happy to relicence it to me under the BSD-new. You can find the code for Mira here.

Which leads me to unit testing. I’ve got a thing for unit testing. Eric has previously blogged about it. However, it didn’t answer one or two of my questions. Actually, it’s more to do with my testing style.

Say I have a file called BuildNfa.hs or alternatively BuildNfa.java, or BuildNfa.py. I like to then have my test file for that unit in a subdirectory called tests with filename TestBuildNfa.hs. Then I want one main file that will run all the tests for the entire project. Furthermore, I tend to just use the xUnit clone for the particular language I’m working with, and the native build system. So for Haskell this means using HUnit as the testing framework and Cabal for the build system.

My source files are in a directory called Mira and the tests are in a subdirectory Mira/Tests. For some reason Haskell insisted that the subdirectory start with a capital letter. Now I’m a total Haskell n00b, so this may simply have been a mistake or a lack of understanding on my part.

I stole/borrowed/attributed the Cabal Setup.hs from some happy hacker called Holden. Thanks Holden. My entire Setup.hs file looks like

import Distribution.Simple
import Distribution.PackageDescription(PackageDescription)
import Distribution.Simple.LocalBuildInfo(LocalBuildInfo)
import System.Cmd(system)
import Distribution.Simple.LocalBuildInfo

main = defaultMainWithHooks (simpleUserHooks {runTests = runzeTests})

runzeTests:: Args -> Bool -> PackageDescription -> LocalBuildInfo -> IO ()
runzeTests a b pd lb = system ( "runhaskell ./Tests/RunTests.hs") >> return()

Which implies that I have the file Tests/RunTests.hs as my mainline for running all my project tests.

Each test in the project has the following form

module Tests.TestBuildNfa
where

import Test.HUnit

.
.
.

suite =
TestList [TestLabel "Simple Nfa Or construction" test_simple_or]

So each Unit test has a function called suite which builds a list of tests.

Thus the runner file

module RunTests
where

import Test.HUnit
import Tests.TestBuildNfa as TestBuildNfa

main =
runTestTT TestBuildNfa.suite

need only import each “test suite” and call the HUnit function runTestTT on it.

Now I’m unsure if this is a good Haskellish way of doing unit testing, but it chimes with my experience from C, C++, Java, Python, Perl and a few other languages. It also sets up a structure for organising unit tests that is a little more extensible than other setups I’ve seen on the Interwebs. Many other people lob all their tests into one file. I simply don’t like that approach. Using this approach a simple runhaskell Setup.hs test will build and run all the tests for your project.

So, still hacking and am interested in two short term code related goals

  1. looking at literal Haskell, and
  2. getting my cheese timelapse feature finished.

And in the more medium term (i.e. over the summer) I have the following goals:

  • Have a look at how C# and F# can be integrated so that C# does the UI and F# the logic.
  • Repackage my spu-gcc, spu-newlib and update my gallium3d package for Fedora 11 on PS3.
  • Package OpenSG for Fedora.
  • That’s on top of trying to finish my Ph.D. and actually have a holiday this year. I’m visiting Vienna with my wife but intend to take my netbook along to hack on thesis.

Ghosts in DTubes

Sunday, April 26th, 2009

I’ve been playing around with an idea for a few weeks. It’s evolved into something that I can actually hack on. The idea solves two problems

  • sharing my photos with my wife, and
  • to select only a subset of my files on my netbook.

It may be complete UI-crack, but you’ll be the judge of that.

A ghost is a set of metadata about a file. For example, a photo has a thumbnail and a set of tags. I can download all the meta-data for my wife’s photo collection onto my laptop. Ghosts are represented graphically in some manner. For example, in the F-Spot UI ghosts of my wife’s photos could show up in greyscale at 50% transparency. You can imagine a similar UI for music files in rhythmbox. I imagine the actual files, that the ghosts represent, are downloaded on-demand by me. This solves my netbook probem (a problem I call “the subset problem”) by allowing me to easily download images and music to my netbook from my laptop.

Both of these problems can be solved by putting a server between me and my wife. But life’s too short for that. And there’s an existing set of cool technologies in Gnome which can be used to implement a p2p(ish) solution.

Maybe I’m not great at explaining the high-level stuff. If you don’t have a wife it may be difficult to understand that her photo collection and mine are actually the same collection. We just use our laptops to “interface” with the collection. We could use a site like Flickr to combine our collection. However, Flickr doesn’t allow me to share gigs of data. And the upload/download bandwidth is generally slower than our LAN speeds that we would achieve when we’re both on our home network. Also, if you don’t have a netbook it’s hard to understand what I’m talking about. Sometimes I’ll want to travel home to my parents and bring my netbook with only photos of my son and some Bach to listen to on the journey. I can’t fit my entire photo collection and music collection on the netbook.

Anyway…the solution currently passes Ghosts (only F-Spot photos at the moment) over a DTube. A DTube can be opened between two XMPP users (think Jabber or Google Talk) and you can pass arbitrary DBus objects over it. I’ve implemented Alice who shares her photo collection with the Hatter. The Hatter has a very crude Clutter based presentation of the Ghosts. The code is at the experimental-proof-of-concept stage. I’m now wondering how to further this. Should I implement a “ghost://” GVFS backend?

Code is here. It’s not pretty, and you’ll have to change the jabber id’s in the source. Helping to put the Network back into GNOME, one idea at a time :)

Reintereact looks interesting

Friday, March 27th, 2009

As a long time octave user I was intrigued when I came across Reinteract. Reinteract appears to leverage the power of mathplotlib in an easy-to-use interface. Where easy-to-use is a very relative term for an advanced maths graphing package. You obviously still have to understand the underlying maths.

Twecipe day 17: The end of the line

Tuesday, March 17th, 2009

Happy Paddys day. I’m in a strange and distant land, so I have to work through it. I’d really love to be in a decent pub with a pint of plain.

I’ve not finished this Twecipe challenge that I’ve set myself, but I think I’m going to leave it at day 17. I’m beginning to find it a bit limiting – in a strange kind of way. I want to go more down the route of a poor-man’s haute cuisine for a while. To this end I cooked steak with sautee potatoes with a mayonnaise last night. I made bruschetta for two for starter aswel.

My presentation needs to be improved a lot. And I need to put a lot more effort into being precise. But the dish was nice and the basic mayonnaise was tasty.

Twecipe day 15: Rugby interrupts food

Sunday, March 15th, 2009

The Ireland victory was great. Saturday was a long day of rugby so we started with a decent breakfast. Dinner was the leftover Normandy Pork from Friday. And, I broke a Twecipe challenge rule. When passing the fishmonger I spotted some whitebait and I had seen a simple chilli-dipping sauce on a food program on the BBC earlier that day. So, I decided to fry the whitebait with a little lime and some salt and serve them as a starter with the chilli sauce (reduction of rice wine vinegar, sugar and chilli). So the recipe wasn’t from twecipe. However, why let rules stand in the way of good food :)

Today I made the butternut squash soup that I made in the first week. I intend to do the shopping for week three tomorrow evening. Hopefully I’ll stick to the £40 limit but it’ll be difficult as we have overseas visitors next weekend. So I’ll be cooking for six. I want to make something slightly special for our visitors. Special in the sense that I would like something of slightly restaurant quality. I want to attempt some fine-dining stuff.

Twecipe day 13: A three day update

Friday, March 13th, 2009

No updates on Tuesday, Wednesday or Thursday as Lord Vader caught himself another bug. I think he’s over everything now. Meh.

I didn’t cook on Tuesday. We spent the evening in hospital. Too tired and all that. On Wednesday I made Pork and Mushroom Crespilini. They were really, really nice and surprisingly easy to make. I made one mistake in using self-rasing flour for the pancakes rather than plain flour. I simply didn’t have any plain flour. Also, I don’t have a photo either. I’ll get one as soon as my wife lets me use her netbook. It has bluetooth-foo and the picture is on my mobile phone.

Last night, Thursday, I made Beef Ragu with Gnochi. Again, surprisingly easy to make. The Gnochi are similar to dumplings or potato bread. I made them a little too big and was inconsistent in size. I think they’d be much better if I made them about 1cm to 1.5cm square.

The picture doesn’t show the pure joy of this dish. It’s simple, hearty and can be customised to your tastes. I added some chilli to give it a bit of lift.

I also made some more white yeast bread. I asked Lori to buy some strong white flour. She came home with a bag of organic yada, yada strong white flour. It’s three times the price of a non-organic bag. But in context that’s only £1.50. Add in some yeast which is 50p for seven sachets and you get 500g loaves for a total cost of 60p. A 500g loaf in a shop costs £1.09 and an organic loaf costs £1.15. However, my bread contains flour, water, lard (50% lard, 50% olive-oil) and yeast. No preservatives, no crap and no junk. And. Lord Vader likes it.

Update:
Normandy pork with a bread crust :) Using the bread I made yesterday. It probably should cover the entire top, but I want some toast for the morning.

I think this would be much nicer if I made my own cream of mushroom soup rather than using it from a can (as the twecipe said). Tasty, and still have some for lunch tomorrow.

Twecipe day 9: Lord Vader reborn

Monday, March 9th, 2009

He’s feeling better now. But confused, because there’s a sticker on his head.

Cillian with a sticker on his head

Twecipe day 8: Starting a new week

Sunday, March 8th, 2009

Day 7 was rather uneventful. It consisted of cleaning up baby puke and eating leftovers from day 6. But I did get a shopping list together for today. A task that was achieved for the sum total of £38.39. So we came in under the £40 rule this week.

We had spiced pork with sweet potato. It was a little sweet as one of the ingredients is orange marmalade. I thought I had some, but I didn’t. So I substituted honey. A little too much honey. It would be a lot better with the bittersweet of marmalade. However, it was very tasty. Certainly something I wouldn’t normally make, as I’d normally steer clear of star anise. I’m going to make the fennel soup again tomorrow. And I got some smoked haddock to add some depth to the flavour.

Oh! And my bread making has also improved. I switched from the dodgy yeast I had in my cupboard (we’d call it a press in Ireland, but my wife’s student’s don’t understand the word – so I’ll use international English) to an instant yeast. I can’t see myself trying fresh yeast….unless….I start brewing beer. Now there’s an idea :)

Pictorial evidence:
Spiced pork and sweet potato

Twecipe day 6: A surprising success

Friday, March 6th, 2009

Yesterday’s lentils tasted great. Unfortunately they looked purple, the carrots looked purple and the plate looked purple. Obviously my substitution of red cabbage for sprouts purplified everything (yes I just made that word up). Which made me think that cooking cannot be a zen process. You can’t simply concentrate on the here and now. Like developing software, you have to have a vision of the end product. Imagine: Puy lentils, crispy bacon, bright orange carrot and green sprout leaves. That sounds like it looks great. And I should have taken the aesthetic into account when making my substitution.

Today I made what twecipe called Curry Puffs. I’m not a great curry cook. I do one Thai style coconut curry well enough for my tastes. However, I find the complexity of flavour of Indian curries to be, currently, beyond me. I added some carrot to the recipe to account for the aesthetic (my one Mexican reader may be impressed). The result was surprisingly presentable and tasted great. I think it needs a salad to go with it though.