Soundcloud page (20 October 2011)
I've decided to start posting music I make here:
MrMonkington's Soundcloud Page
...cos it's not really worth the effort of making a dedicated section on this blog. Also, Soundcloud's quite cute. I just hope it doesn't go the way of all the other music hosting services I've uploaded my crap to!
Right now it's just a few old bits. I have a pretty big collection of unfinished tracks that I'll sift through when I have time.
All of this was made almost entirely with the wonderful Buzz Tracker (for Windows). I'm now using Neil Modular Tracker which is an excellent Buzz clone for Linux. If you want a completely free way to make electronic music give either a go!
Tip: filters in Inkscape (15 September 2011)
Have been trying to get as comfortable working in http://inkscape.org/, the free SVG editor, as I used to be in Adobe Illustrator, which is the marvellous but prohibitively expensive king of vectors. When switching apps, you have to repeatedly remind yourself that different != rubbish, you just have to relearn everything and very complex apps are never going to be completely intuitive.
The first major-ish misunderstanding I've figured out out in version 0.48 concerns transforms and filters, or rather how to stop filters from transforming along with the artwork they're applied to. First some details about Inkscape's transformations.
When using the resize tool you are sometimes actually applying a distortion to an object, not modifying it's basic form. For example, if you draw a 10×10 box and leave it as a 'rect' primitive, and then stretch it to 20×10 (i.e. horizontally) Inkscape will modify the basic parameters of the box to really give you a 20×10 rect primitive.
<rect width="20" height="10" />
However, if you apply a slight rotation first, you don't end up with a 20×10 box, you get a 10×10 box with a rotation and 2× horizontal stretch on it. These things are subtly different. In the latter case, Inkscape is storing the transformation as a separate definition to the geometry of the object.
<rect width="10" height="10"
transform="matrix(0.93834994,0.34568683,-0.59571192,0.80319817,0,0)"
/>
(Enjoy reading the matrix form of the transformation!)
If you expand the rect primitive to a path, then Inkscape will do a better job of applying your transformation to the base nodes of the path. So if you take a 10×10 box, expand to a 4 node path, then rotate 45°ree;, you will have a new 4 node path that traces a diamond.
<path d="M -5,-5 5,-5 5,5 -5,5 z" />
Becomes
<path d="M -7.0710678,0 0,-7.0710678 7.0710678,0 0,7.0710678 z" />
It may seem like Inkscape is being difficult here, but I suppose it's just trying to create the simplest SVG document at all times. And if this seems somewhat indeterministic then, er, perhaps it is. If you do somehow get stuck with a path primitive with a transform applied, you can force Inkscape to attempt to permanently apply the transformation to the underlying nodes by using 'Break apart' from the 'Path' menu. This is equivalent to 'Expand' in Illustrator.
So, back to filters. If you use the very nice (new) drop shadow or outer glow effect on an object, the resulting block becomes 'impenetrable' to Inkscape's transforms and all subsequent transformations apply to the entire group affected by the filter. This includes transforming the output of the filter. So if you apply a drop shadow simulating light from the top-left, and then rotate the whole lot, the light source will rotate with it. If you stretch the box, the drop shadow will stretch with it.
If you don't want this to happen, the solution is to group your geometry and apply the filter to the group. If you need to modify the filtered artwork, enter the group and apply your transforms there.
For example:
- Create a rect.
- Select and then create a group with just the box in it.
- Apply a drop shadow filter to the group.
- Enter the group (right click 'Enter group')
- Rotate the box.
Ta da!
Simple caching patterns for PHP (17 August 2011)
Having built a few projects in Django I've sufficiently adjusted to working with a well developed framework and well designed programming language (Python) that there are several features I really miss when returning to PHP and using light weight framework Eurogamer is built on again.
One of those things was being able to use decorators to implement object/fragment/view caching on top of memcache which lets you build a very terse syntax for optimising you entire web application.
PHP doesn't have decorators and the accepted PHP decorator pattern is little better than subclassing in terms of convenience. The beauty of decorators is that they let component developers interact directly with caching with very little footprint, and in my experience, the easier and more transparent you make caching to developers, the more effectively it's deployed.
So I thought perhaps I could use PHP reflection API to fake decorators for the specific task of caching. The results of my labour are available as this EggCup PHP caching class on Github.
It's not a great deal of code, but I don't think it's an obvious solution to the problem. Usage is very simple (assuming memcache instance running on localhost):
In the component:
class MyExistingClass {
/**
* cache-me
* cache-expiry: 60
*/
public function getSomeDataFromDB( $arg1, $arg2 ) {
// take a long time to generate some data using $args1 and $args2
// as determining vars.
return $someData;
}
}
Invocation:
$cachedclass = new Eggcup(
new MyExistingClass(),
array( array( "host" => "127.0.0.1", "port" => "11216" ) )
);
// this return value will be cached for 60s
// first call will use DB
$cachedclass->getSomeDataFromDB( 1, 2 );
// second call will use memcache
$cachedclass->getSomeDataFromDB( 1, 2 );
// different args so will use DB again (cache key auto constructed from
// args)
$cachedclass->getSomeDataFromDB( 3, 4 );
sleep( 61 );
// will us DB again
$cachedclass->getSomeDataFromDB( 1, 2 );
Yeah that's right, the doc comments for the function control the behaviour of the cache for the method. A component developer can SUGGEST, via comments, how his code should be cached, with the person invoking the component having final say over whether the caching hints are honoured or not. It's a nice arrangement and makes reverse engineering a doddle (the cache info is there right in front of you).
Cache-invalidation is also supported, but memcache's poor support for lists makes it pretty clumsy. I'll be trying this out on a Redis backed cache very soon.
You may have some questions...
Does it break APC? Not sure. You might expect run time reflection to mess with PHP's byte code cache. I'll do some tests...
Is there a lot of overhead? There's a bit, but it's less than running a bunch of slow SQL queries. It's always cheaper to make your app servers do the work!
Does it work from any scope?
No. At object level scope it doesn't work because $this isn't wrapped by EggCup. i.e. you can't do $this->getSomeDataFromDB and expect it to be cached. This is generally not a problem because good caching should always be at the highest level you can afford.
Chicken thighs with mushrooms (Spanish style of course) (25 July 2011)
After empanada for 3 consecutive meals, it was time for change!
This dish is basically pollo al ajillo with mushrooms. The addition of some other solid ingredients makes it a very low maintenance version, especially as chicken thighs stay nice and moist when slow cooked.
You'll need:
- Chicken thighs
- Garlic (at least 3 cloves per person)
- Bay leaves (as many as you like)
- Dry oloroso or palo cortado sherry, or white wine and some solera brandy
- Mushrooms - something a bit meaty and nutty, like chestnut.
Then do this:
- Season the meat very well.
- Preheat over to 160
- Put a heavy, enamel casserole on a medium high heat
- When hot, add lots of olive oil and fry the thighs skin side down till nice and brown
- Flip the thighs on to the meat side and add chopped garlic. Cook until the garlic is mid-brown and nutty.
- Add sliced mushrooms and cook till they're just about done.
- Deglaze with some booze (be generous), boil off alcohol.
- Throw in the bay leaves, top up with a little water (liquid depth about 2cm), put on the lid then put in oven for at least 90mins.
- It will reduce a bit - you'll have to judge if you want to reduce it further once you've removed the meat (and perhaps make it a bit more cheffy by adding a splash of cream).
It's really nice with lightly spiced rice. I'd post a photo, but I never have the presence of mind to take one when there's food to be eaten!
HAMBRE HAMBRE HAMBRE? It's empanada time! (24 July 2011)
I can't get enough of Rick Stein's new series: Spain. Stein's the only 'celebrity' chef who seems to get excited about food in a way I recognise, both in his writing and TV. And I don't just like him because I've been to Padstow.
Anyway, I was inspired to try to make a proper Galician empanada just using whatever I had at home (Rick approves of economy). I'd made smaller versions before, from a Moro recipe, which were recognisably pasty-like and thin shelled. However, the sort I saw in last week's show were huge tray sized affairs, with a much more bready crust, sliced into portions for sharing.
There weren't many clues on how to form the dough other than that it was "like bread, but with lots of olive oil" so I made my best approximation of something that was half bread, half shortcrust.
- 200g plain flour
- 1/2 tsp salt
- 100g strong bread flour
- 100ml olive oil
- 1tsp dried yeast dissolved in 50ml warm water with 1tsp sugar.
- 2tbsp white wine
Assuming you're already familiar with dough making technique:
- Mix the oil, salt and flour to form flakey crumbs
- Add yeast and wine, and form a dough, adding water as necessary and kneading briefly to get a soft, springy consistency.
- Leave for 30 mins to an hour to rise a little.
- Split the dough in half and roll out two sheets about 5mm thick.
- Place one sheet on a tray or in a non-stick baking dish, put a layer of filling on top, then place the other sheet on top of that and crimp the edges well.
- Leave for another 15 minutes to rise a little, glaze with oil, cut some steam slits, and then bake for 20-30mins in a moderate oven.
- Serve warm, or room temp, but not hot.
For the filling this time I used some excess garbanzos con espinacas (chickpeas with spinach, a Spanish classic, here's a good recipe though I add a little thyme). I don't imagine this combination is authentic, but it was very good - the whole thing stratified into crust, bread, gooey filling dough mix, and filling. I have no way of checking this pastry against an authentic Galician one, but I'll stick with it for a while and try some more traditional fillings, like, er, hake.
Here it is the day after when I'd eaten most of it.
I'm leeking dinner (02 February 2011)
What to do with a leek surplus in a hurry:
Sweat the leeks with two big pinches of fennel seeds and a pinch of chilli in butter and olive oil; put some penne on to boil in salty water; when the leeks are nice and soft a starting to sweeten add a small amount of lemon zest, single cream, salt and a rubbery, slightly sharp, mature cheese, like Sussex Yeoman, Manchego or Pecorino. When that's melted stir in the drained (and of course cooked) pasta. Add lemon and pepper to taste (i.e. not too much unless you're the sort of person who puts ketchup on pizza).
BOOM.
Weekend of the living bread (17 January 2011)
Had a fairly successful weekend baking. Don't seem to be able to organise myself to get a sourdough starter going, but that doesn't matter too much as I've been getting some pretty good results with dried yeast for years now.
My tips:
- Wet dough - keep it as wet as possible and add tiny amounts of flour if it becomes unmanageably sticky. You can get some interesting results by keeping the dough mega wet and using a wooden spoon to beat the gluten out.
- Use the best extra strong flour you can afford.
- Use less yeast but prove for ages - 24 hours makes a better loaf with less kneading (put a wet towel over it and don't let it dry out) which won't taste of dried yeast.
- Get a massive bowl and do everything in it - I have an enormous steel bowl I got from Ikea which must be 45cm across and is big enough to mix and knead the dough in. This makes life much easier.
- Humidify your oven with a ramekin of water left in there during baking - this will allow you to bake for longer giving a deeper crust but retaining moisture in the loaf. Also, don't use the fan on your oven.
- Don't get bogged down with recipes - get used to playing with dough and understand that the only really important things are gluten and moisture, the former being a function of time and the second being achieved with good judgement.
Some newdles (02 January 2011)
Added 4 paintings from my honeymoon to the gallery. They're terrible, but watercolour in tropical heat is really tricky.
Fennel risotto = nice arancini (22 August 2010)
I like making risottos that focus on the merit of a single vegetable. In fact I very rarely add meat or seafood to a risotto, as seems to be pretty common in all the barely Italian restaurants I've been to.
The other night I made one with a lovely but smallish fennel that I had which included a lot of stalk and greenery (I don't know why when you buy then from the supermarkets this bit is cut off). The whole thing was about 2 feet long!
I put everything in, including the lovely dill-like fronds, but saved a small amount of the white bulb which I shredded and pickled for about 30 mins in water, vinegar and salt and served alongside for a little contrast.
I used water rather than stock for the liquid, because fennel is easily suppressed, but I did add a pinch of some 'bay seasoning' Nick got me from Baltimore. It's basically celery salt and paprika. A tiny quantity of lemon zest is also a nice addition.
It was good! What was even better though was the arancini I made with the leftovers. I can only make small ones since I don't have a deep fryer, but I think I prefer them this way, shallow fried. I had them with soured cream which was perfick. Is that fusion?
Spag bol (21 August 2010)
I don't believe there really is a dish called Spaghetti Bolognase to be found anywhere in Italy, but it's one of Britain's top 4 or 5 favourite suppers, so its provenance is irrelevant. Here's how I make it.
For every lb of minced beef, fry in lots of good oil a large onion, a stick of celery, a large carrot, and garlic to taste which has all been chopped as fine as one can get it. Add 1/2 lb of bacon and fry this all off. Add a small amount of minced chicken liver, or plain liver pate if that's all you can get, and then the minced beef.
Once it's all browned I drown it in a robust red wine, stock and no more than one tin of chopped tomatoes. It should be pretty soupy at this point. Drop in thyme or any similar herb (I prefer marjoram) and fist-fulls of chopped parsley. Leave unseasoned for now else the beef will seem drier. If you don't mind fishing them out later, the parsley stalks can go in too.
Give it an hour or two of simmering then when it's looking a bit thicker adjust with salt and tomato puree. A spoon of paprika can help emulsify the sauce a little too. Leave it for another few hours at a very low heat until it's glossy and glorious.
I don't think I need to tell you how to serve this. I think I might eat some in the garden.
Lahmacun (sort of) (06 April 2010)
Making pizza is such a pain in the arse, mainly because nobody ever has mozzarella knocking about in their fridge, since it's so unreasonably expensive (in the UK, at any rate). Some may also say that making dough is a pain in the arse, but I think once you've done it a few times, and don't mind having huge balls of fermenting goo kicking around your fridge, you can prepare some dough in advance and put something together in 15 minutes when you feel like it. So those people are wrong.
Anyway, instead of having an Italian style pizza without cheese, try getting a bit Turkish and doing something spicy in the vain of their national street food 'Lahmacun'.
The typical recipe for lahmacun involves frying onions, garlic, minced or finely chopped lamb, tomato, turkish chilli flakes (biber) and perhaps a little allspice into a sauce, then spreading on very thin rolled dough, baking till it's browned but still pliable, then serving with parsely, mint and lemon, and possibly yoghurt, since that seems to turn up everywhere in turkey. You don't want to use too much tomato, since it would swamp all the other flavours.
However, the principle is robust and adaptable, and you can concoct all sorts of dense, spicy, tomato sauces for meats and fish, bake these on a thin bread base to serve with something cooling and fresh, like herbs and yoghurt.
Some examples that I think work:
- Sardines or other oily fish (tuna?) with a pinch of saffron, chilli, allspice and a good spoon of sumac.
- Beef with a little cumin and chilli, with yoghurt flavoured with crushed garlic and salt.
Note: it's worth sourcing some Turkish chilli flakes - there's something totally unique about them, and letting people sprinkle the damp stuff over their own food enhances a meal disproportionately.
Speed up composited Metacity on GMA 500 (06 February 2010)
If you've got a netbook with Intel's useless GMA500 (Pouslbo) chipset, and you've managed to get the closed source Linux drivers working, you'll know that some things work well (libva accelerated video decoding) and some things not so well (2D acceleration). You can mitigate that last problem by using Metacity's composited mode which makes dragging windows around a hell of a lot smoother, and is preferable to trying to use a 3D window manager like Compiz, which is a bit flaky on this chipset.
You can activate composited mode using gconf-editor and activating the options /apps/metacity/general/compositing_manager. You also get some nice shadows around your windows, which I think is good for usability.
Unfortunately you'll now find alt+tab'ing to be un-usably slow (1-2 sec delay before the switcher appears) since in composited mode, Metacity uses little downsampled screenshots of all your apps instead of good, recognisable icons. I don't know about you, but at 100x100 (or whatever) I struggle to tell the difference between a web browser and a wordprocessor.
So I poked around the Metacity source and found that you could hack out this 'feature' trivially. Check out the trunk from the Metacity SVN repos and apply this patch (which also has some minor changes to the constants used for the shadowing since I thought the defaults were a bit heavy handed):
Index: src/compositor/compositor-xrender.c
===================================================================
--- src/compositor/compositor-xrender.c (revision 4239)
+++ src/compositor/compositor-xrender.c (working copy)
@@ -232,11 +232,11 @@
#define SHADOW_LARGE_RADIUS 12.0
#define SHADOW_SMALL_OFFSET_X (SHADOW_SMALL_RADIUS * -3 / 2)
-#define SHADOW_SMALL_OFFSET_Y (SHADOW_SMALL_RADIUS * -3 / 2)
+#define SHADOW_SMALL_OFFSET_Y (SHADOW_SMALL_RADIUS * -3 / 2 + 1)
#define SHADOW_MEDIUM_OFFSET_X (SHADOW_MEDIUM_RADIUS * -3 / 2)
-#define SHADOW_MEDIUM_OFFSET_Y (SHADOW_MEDIUM_RADIUS * -5 / 4)
+#define SHADOW_MEDIUM_OFFSET_Y (SHADOW_MEDIUM_RADIUS * -5 / 4 + 1)
#define SHADOW_LARGE_OFFSET_X -15
-#define SHADOW_LARGE_OFFSET_Y -15
+#define SHADOW_LARGE_OFFSET_Y -12
#define SHADOW_OPACITY 0.66
@@ -2829,6 +2829,7 @@
xrender_get_window_pixmap (MetaCompositor *compositor,
MetaWindow *window)
{
+ return None;
#ifdef HAVE_COMPOSITE_EXTENSIONS
MetaCompWindow *cw = NULL;
MetaScreen *screen = meta_window_get_screen (window);
How to create self signed certificates for multiple domains (25 January 2010)
If you want to host multiple https sites on a single IP using name virtual hosts, then you'll need to use a single certificate due to way SSL works. To make this work you need to either make a wildcard domain, which only works for subdomains of a single domain (e.g. *.mydomain.tld) or set one of the domains as the 'common name' and then the entire list of desired domains in the in the x509v3 extension area.
If you want to use a 'multiple site' (not a subdomain wildcard certificate) for whatever reason (they are cheaper for a start) then the issuing authority will have an interface for specifying the extra domains. If you want to test out your server configuration first, before potentially wasting a lump of cash on the certificate, then you'll want to do a bit of self signing using openssl.
However, the alternative names (formally: 'subject alternative name') stuff isn't well documented. Here's what I did:
Choose a permanent location on disk for your certificates and keys.
In the example, my domain is '''domain.tld''' and I'm setting up two subdomains: www and www2.
cd [that location]
Generate a lovely private key and keep it somewhere safe (safe = private but backed up - if you lose it, you'll have to make a new certificate):
openssl genrsa -out www.domain.tld.key 1024
Don't use a passkey - you'll only have to enter it every time you start up Apache.
Generate a certificate request file:
openssl req -new -key www.domain.tld.key -out www.domain.tld.csr
Answer the questions! For 'Common Name' put the first domain name (www.domain.tld). Be careful to make sure all the info is correct.
Create a extensions config file for the certificate generation (you can throw this away when you're done). This is the important bit for getting the extra domains in. You need to list ALL the domains, since the Common Name you set above is only used in the absence of the subjectAltNames field (I think).
In www.domain.tld.cnf:
subjectAltName=DNS:www.domain.tld,DNS:www2.domain.tld
Then run:
openssl x509 -req -days 365 \
-in www.domain.tld.csr \
-signkey www.domain.tld.key \
-text \
-extfile www.domain.tld.cnf \
-out www.domain.tld.crt
Christmas curry sauce for turkey (29 December 2009)
Gotta use up the turkey, innit. Anyway, keeping it vague:
Fry 1 tsp fennel seed, add chopped onion and garlic and fry till sweet. Add bits from the fridge, like a small quantity of aubergine, courgette, sweet pepper and then mix in 2 tsp of decent, but mild, curry powder, a couple of fistfulls of fresh tomato (any variety - I used cherry) and a good splodge of tomato puree. Dilute with a cup or two of water, at least 1 tsp of salt and simmer down to a thick sauce. Add chilli and salt to taste.
I served in a separate bowl to a plate of sliced turkey, with potato and spinach, rice and some tarka dal. Makes a nice change from cheese and chocolate!
Smoked salmon and cauliflower chowder (22 December 2009)
A cosy winter soup that uses up the sort of things that tend to accumulate in my fridge.
You may need more liquid than I've quoted - you can use extra milk, stock or just water, obviously.
- 50-75g unsalted butter
- 1 onion
- 1 little garlic man (don't go crazy!)
- 1 cauliflower (or romesco) split into small, bitesized florets
- 1 large potato
- 1 large or 2 small carrots
- small stick of celery (or a pinch of ground fennel seed will do - it's what I did last time)
- 1-2 tsp of ground coriander seed
- a good fistful or two of smoked salmon trimmings
- heaped dessertspoon of plain flour
- pint of milk
- pint of homemade, unsalted stock (vege or fish) or half strength instant stock
- pepper
Chop onion, celery, garlic and carrot very finely and soften low-medium for 5-10 mins in plenty of butter. Chop the potato into bitesized pieces and add that. Continue to fry for a minute or two - the potato will start to cook at the edges, and may stick a bit - don't worry.
Add the flour and cook the whole lot (dry) for a couple of minutes as if you were making a roux (you are!).
Take off the heat and pour in the stock slowly, stirring so it all mixes well, then add the milk. Bring to the boil but not too hard, making sure to scrape the bottom of the pan to disolve the stuck bits. Add enough salt so it's just a little underseasoned (the salmon is salty) and some pepp. Also add the pinch of fennel seed, if using.
Simmer for a minute or two, then add the cauliflower and continue to simmer till it's tender enough for you. It's a soup, so you don't want it as crunchy as if you were eating it on its own.
Now, what I did was take my hand blender, and sort of whizz up about half of the soup, so leaving lots of nice chunky cauli and potato, but also giving it a good thick texture.
Then dump in the salmon and the ground coriander and break up the salmon as it cooks with a spoon. Leave it for long enough that you feel the flavour of the salmon has got into the soup and adjust the seasoning, etc.
I just served with a little cream dribbled in, and some extra black pepper. Don't put any fresh coriander on - it's not the right flavour.
Enjoy!
Tethering a Nokia N95 over Bluetooth on Ubuntu 9.10 (03 December 2009)
N95's and certain other Symbian Nokia phones, implement tethering over bluetooth by offering a Dial Up Networking (DUN) service, i.e. a serial modem over bluetooth. You have to use Hayes modem commands and everything! It's a bit fiddly to set up by hand, and isn't supported (yet) by Gnome's built in bluetooth manager. Fortunately, you can just use the Blueman project's applet instead, though this isn't really documented anywhere.
Do the following.
sudo apt-get install blueman
Run System → Preferences → Bluetooth Manager
Hide the Gnome Bluetooth applet icon (you don't have to, it's just confusing otherwise).
Click the new blue Bluetooth systray icon. You should see your phone, assuming Bluetooth is enabled on the phone, and it's visible. Right click it, and bond it.
Once it's bonded, right click and click Serial Ports → Dialup service. 3 small bar graphs should appear by the phone entry once connected.
Right click the network-manager applet systray icon, and edit connections. Add a new mobile broadband entry using whatever settings fit your contract.
Click the network-manager applet icon in the systray — you should now be able to connect to this new connection, listed under Mobile Broadband.
Hooray!
One comment