Saturday, December 31, 2011

3202.5

That's the cumulative cycling mileage at the end of the year, passing the 3200 target I wanted to hit (~2170 over the year, plus the 90-odd on a hired bike to make over 2250 total). That's omitting those miles where I'd forgotten to put the widget back in place to count the distance; but that is unlikely to be more than about 5 miles total, and could be made up with distances pushed anyway.

I think it goes to show how dry the weather was for much of the year.


Anime -- 2011 in review (part 1)

In total, I have watched all through just 3 series from the last year, am in the middle of two that have completed, one that hasn't and am about to start on one that has. Plus a scattering of older shows finished or in train. This post, old shows considered.


Mobile Suit Gundam


I remember when the future looked like Gundam - O'Neill colonies throughout the Earth-Moon system, but no internet. Now add brutal robot combat, the usual Tomino level of named character futile deaths, mixed with toy commercials. Like the following year's Space Runaway Ideon, this has an element of a treadmill, where each episode the enemy -- here the L2-based Principality of Zeon -- uprates its mobile suits each episode and our guys with their carrier and mobile suits continue to level up to meet them.

After ten episodes of this, the action moves ground-side, with a long meander from south-east Asia, through to the Black Sea (with a number of side trips -- "we need to reprovision with salt"; our hero has an angst attack and has wandered off with the Gundam; ...) thence to Ireland (where we meet a traditional red-headed Irish girl, with the traditional Irish name of Miharu), then across the Atlantic to a Federation base in South America, having circumnavigated the globe rather than going direct.

Then, finally, we return to space for a series of skirmishes, culminating in an escalating final battle where pretty much everything gets destroyed; but the power of Zeon is broken and all seems well (until the next series).

Even after 30 years, and with an indifferent American dub, the series holds up as more than just a piece of history. The anti-war message may be unsubtle, but there is a feeling of how even the significant players like the Gundam team are just a part of a larger concern; and the daring and charismatic recurring antagonist, Char Aznable is in turn just a minor, though equally significant, character on the Zeon side.


Catman


A quirky little flash series about a down-and-out in an alternate Canada peopled by anthropomorphic cats. It's slice of life anime done right. That means without any cute girls, school, or even cake, but with a whole lot of drinking, swearing, bowling, getting beaten up, and freezing to death on the street. And catchy ska BGM from the Planet Smashers.


Hyakko

Images quoted for purpose of review.

A series I passed by back in the busy year of 2008, as another cute girls at school series like Hidamari Sketch or Sketchbook Full Colours; but which turned out to have rather more energy and enthusiasm about what it's doing. We start by having the ditzy bonde Ayumi as the first viewpoint character lost in her vast new school, then accumulate the oujo-sama Tatsuki (also lost), and the core group is then completed by the sudden eruption from an upper storey window of the tomboyish Torako, followed by her constant companion, Suzume (who are solving the navigation problem by heading in a straight line).

The series takes a little time finding its feet, and goes thematically all over the place, from out and out comedy, to amped-up melodrama; but as we learn about the quartet and the rest of the class of equally idiosyncratic types, everyone is refreshingly nice (except for the boys in the senior years, who are jerks, and Torako's family, who exist mainly for injecting drama).

Not an undying classic of the ages, but still a nice feel-good series to have watched over the holidays; especially as it was set in early summer, sunny and bright, a perfect antidote to the midwinter blues; the one exception, the April rainstorm that opens the final flashback episode, where the melancholy dawn of the first day of the school year breaks. That scene was the one where the incidental music was most noticeable, and it seemed to fit the bitter-sweet flavour of the whole episode.


Natsume Yuujinchou -- seasons 1 and 2


Another series from 2008 (and then 2009); somewhat like Mushishi, in that Natsume Takashi has the ability to see spirits that pass by normal people unobserved. However, unlike the competent adult Ginko, who has to deal with fungal or insectile mushi, the youkai that highschooler Natsume can see are people of a sort.

This unsettling aspect of his life, reactions to and conversations with the unseen, has left him shuffled from relative to relative. This time he also stumbles across some of his late grandmother's possessions -- including the eponymous book in which she inscribed the true names of many youkai; and into a shrine where a powerful spirit is bound who Natsume accidentally frees.

Having spent many years bound in the form of a lucky cat, the spirit now appears as a human-visible cat most of the time; and sets himself up as Natsume's bodyguard : no-one else is getting that book but him.

So with the rascally Nyanko-sensei to guide and protect him, he starts to find and unbind some of the youkai in the Book of Friends. The series thus starts as a simple monster of the week; but as the extended cast is gathered, it becomes as much about resolving problems amongst the youkai, and Natsume worrying about how his life is balanced between the two worlds.

While being much the typical anime protagonist most of the time, the show avoids getting Natsume into any of the usual romance clichés, without actively excluding girls from his social circle (such as it is). The fact that many of them are spirits, and one explicitly declares that she was much more interested in his grandmother, helps avoid that sort of thing.

So a quiet and delightful little series; and in the new year, I shall move onto the recently aired 3rd season, and the about to air 4th.






Wednesday, December 28, 2011

Film -- The Adventures Of Tintin: Secret Of The Unicorn

Last cinema visit of the year, catching the holiday re-run of the film.

Not having read any of the source material in decades, I didn't worry about anything that might offend purists, but enjoyed the cartoony inter-war era high adventure in the style of what I did recall.

We will know that the CGI medium, especially in its 3D expression, is mature when they stop showing off gratuitous mirrors and lenses.


Tuesday, December 27, 2011

Writing StyleCop rules in F#

Alas not "Writing StyleCop rules for F#" (or should that be StyleFop?), which would be nice, but a true job of work...

I don't see much need for more StyleCop rules for C# (except one to harness the FxCop spellcheck facilities to scan comments, which would have to be done via much dodgy reflection to winkle out internal types, and would anyway give issues for being tied to 32-bit native executables), so haven't tried this before. But, like mountains, it's there...


So, you have StyleCop 4.5 or 4.6 installed, and start by creating an empty class library targeted at the .net 3.5 environment, with added references to the StyleCop and StyleCop.CSharp assemblies. The bare rule class looks like

and to go with it, add an XML file as an Embedded Resource with name My.Namespace.MyRules.xml -- first gotcha : the long name needs to be given in full because the default namespace doesn't get applied in the build like it would for C#. That can then be filled in as per the instructions in the StyleCop SDK documentation. Then just override the AnalyzeDocument method and go wild:

where I'm using the concept from the StyleCop+ rule SP2000 as an example of a new rule not yet present in the core tool.

Unlike FxCop, there is not a "one class = one rule" model here; the classes exist to group related rules, and you control how each scans the current source file of interest, and, indeed, how distinct they are in the code -- a closely related set of rules could be checked off a single scan, and in some ways StyleCop rules are more akin to the distinct named resolutions that can be defined within a single FxCop rule.

Another consequent difference from FxCop is how the object graph is visited. In FxCop, there are VisitXxx methods to override that will be called for every object of type Xxx, in an essentially stateless manner (your rule class is responsible for maintaining state between calls); here the equivalent methods are passed to a WalkXxx graph walker method as a callback, provide a mutable state object argument, and can signal through their return value whether the traversal should continue.

This approach of using a mutable object, needing down-casting, to carry inputs into each call, and contain the resultant outputs, feels a bit odd in a functional environment; fortunately it is possible to bypass this in many cases by representing the tree-walk as a seq and operating on that. For the trailing whitespace rule, where the offending lines are most easily found by scanning the raw source line by line, all we need the traversal for is to find an ICodeElement context object matching that line number. A simple walk of the code element tree looks like

which we apply to the document RootElement and from the result find the last (so most deeply nested, and hence most constrained) item whose Location has a span that includes the line number of interest (skip while the end is before the line of interest, take while the start includes the line, reverse, get head), the line number being a value that the operation can close over.

For deployment onto machines that don't have F# installed, static linkage of the runtime via the --standalone build flag can be used rather than having to explicitly drop the F# runtime assembly into the StyleCop folder (second gotcha).

Monday, December 26, 2011

A mild Christmas, a welcome change

Friday, with the temperature about 5C, and strong sou'westerly blowing, I cycled to work, thinking all the while that I was mad for doing so, with a weather forecast for rain, mainly heavy, in the afternoon. Unlike last year, there wasn't the need to wear anything over my spandex shorts for warmth, so that would be enough to mitigate the worst of cycling in the rain. As it turned out, when I set off home a while after 2, it was starting to sprinkle with rain; eventually getting heavy enough to want a waterproof, but not really uncomfortable at all.

Saturday, a muntjac wandered into the garden, and ate some of the remaining windfall apples, the ones too small or damaged to have harvested. The cats were not amused by this thing invading their territory, and kept a wary eye on it from a distance, and well away as it wandered off again. At least it was too big to fit through the cat-flap, unlike pigeons or the various rodents whose entrails at times have decorated the kitchen floor; more like the pheasant that was left on the doorstep, with just a clear cat-inflicted bare patch on its neck a couple of weeks ago.

Yesterday began with the exchange of presents -- where I got Vinge's latest, novel, The Children of the Sky, the long awaited sequel to 1993 Hugo winner, A Fire Upon the Deep; and Tim Worstall's book of essays on economy and the environment Chasing Rainbows, which metaphorically in text is like suikawari without the blindfold; and then lunch.

Having not thought to book until 5 weeks ago, we had a simple enough choice of places where there were still slots to be had -- lunch at the Carpenters Arms.

This was a leisurely affair, 12:30 for 1, canapés, starters, then buffet style mains, where I was unable to take up the offer of a third helping, before the cheese board, a little Xmas pudding, and coffee with petites-fours; and so home in gentle fashion by not too long after 5pm.

So today could be pure R&R, with just a little bit of pottering in the garden for some fresh air -- clearing the tomato plants out of the greenhouse, hoovering the lawn (to get rid of fallen leaves), trimming where it had straggled over the borders, and clearing the few places where plants had stopped for the winter and obligingly dried up (the marigolds are still in flower, as are the antirrhinums; not just the viburnum which I'd expect to be flowering now); leaving a little space in the green bin for more gardening later in the week.

Some of the sunflower heads that haven't already been stripped of seeds, I hung up for the birds; and the last handful of rosebuds are in a vase by the fireplace. And so the garden remains in a late-autumn limbo, until I really can't postpone pruning the roses and apple trees any more.

Wednesday, December 14, 2011

An approximate type-based solution to the strings problem

As ever, neat ideas coded in Haskell can be almost but not quite ported to F#, foiled at the last moment by the fact that the .net type system cannot represent constructs that are expressed as Haskell type classes : there's always a run-time type coercion and some leakage of abstractions that have to be coded around.

One such is this idea of type-safe strings for representing structured data like XML -- which would require a little more mutually recursive and self-encapsulating type definitions than I think F# can manage. It gets close, though, and could probably be embellished a little further:


Deleting files, keeping a few -- in Python

And the same again, only as a script, just because:

If there wasn't that comparison function to write, it'd be terser...


Tuesday, December 13, 2011

Deleting files, keeping a few

Inspired by this post, how it works in PowerShell:

will delete all but the most recent 3 files ending in ".log"; and it would be the same sort of thing in any scripting language.

Sunday, December 04, 2011

Lovely weather for the time of year

The garden today

The garden today

A year ago

A year ago

Yesterday was a mild and sunny day, so I took a spin out in the countryside, stopping at the Carpenters Arms for a light lunch, of pumpkin and parsnip soup and a ham and cheese toasted sandwich. It was great to enjoy the chance to get out on the bike again -- as it seemed did a number of the lycra crowd, though fortunately they don't seem to hunt in packs at this time of year.

What a contrast with a year ago, when needing to go into town, I wrapped up with long-johns, heavy gloves, multiple layers, goggles, just leaving my nose exposed -- and regretting that for the first couple of miles before getting properly warmed up.