Monday, July 02, 2012

Strong-naming assemblies using Mono.Cecil

As the Microsoft FxCop libraries are inherently 32-bit (including native code as they do), developing code using them on a 64-bit platform throws up places where the modes get mixed, and an assembly that is generally AnyCPU ends up needing to load an x86 library and barfs. No real problem here, use corflags assembly /32BIT+ /Force, where you need the /Force for a strong-named assembly. And then if later you need that one strong-named... There is the standard technique of ILDasm/ILAsm to rebuild the assembly with strong-naming (as documented e.g. here), but you still end up with the corflags yellow warning in the MSBuild output about breaking the original strong-naming if you need that too.

But when the code I was working on also uses Mono.Cecil to do stuff, it was easier to silently do the whole lot in one script:

Yes, you can do that in PowerShell too, just with more fussing about the path to the Cecil assemblies because of the schizophrenic current directory model it has. And because the rest of the code in this particular project is F#, keeping the build scripts in the same language is just natural.


Dept of "should know better"

Cycling home from doing a little bit of shopping on Saturday morning, I was coming up to a junction where the road makes a nearly blind left turn at the point where another road joins from the right, with a traffic island in the mouth of the joining road (so a T-junction with altered priorities). Checking the mirror, there was a good gap behind me to another cyclist and then a couple of cars.

So arm out to indicate, and move over to near the white line... When suddenly the cyclist passes me, cuts in in front, then blithely bounces out again, entering the wrong side of the island. And never at any time did his hands leave his front tiller -- a piece of kit I really don't think should be road legal. Now, I'm used to the normal run of urban cyclist who usually has an arm down by one side and indicates by a twitch of an index finger or maybe a flex of the wrist; but this chap was too goddamn precious to make even that attempt.

I, of course, advised him of his unfamiliarity with the general rules of the road, but it irks me that someone supposedly serious about it should be such a bad advertisement for cycling as a mode of transport.


4078.2

In the end, the last week of June turned out to be good for cycling -- apart from the one day when I ended up cycling home in rain that hadn't been on the Met Office forecast. I can forgive getting showers wrong, but more organised weather less so -- like on Saturday just gone when they said cloudy for the morning when there was a blatant band of rain visible on the radar (The Weather Outlook is always wet and gloomy, so if I went by them I'd not have cycled at all).

So, over the easy target, and, with the cycling holiday in March, 950 miles for the half year, which is good considering we had a couple of months of almost total washout, above and beyond the normal April showers.

And now July opens wet again...

Wednesday, June 20, 2012

Anime — Leiji Matsumoto's OZMA


This short series had all the look and feel of something restored from the 1980s and texture-mapped onto contemporary CGI for the vehicles traveling on -- or in some cases under -- the desert sands of a future devastated world (which seemed to be the setting for at least two out of three titles from back in the day).

The gimmick this one had is that we had craft that would use quantum magic to submerge, to give an excuse for doing all the standard submarine things (though I guess that should be subharene for things traveling under sand) -- running silent, being depth-charged, like every submarine movie ever.

The passage of time did mean that a lot of the old clichés get to be new again from disuse and as a pure nostalgia binge succeeds on those terms; but did we really need a Char-alike masked antagonist, and an ending that borrowed from Nausicaä the way that Greece has borrowed from the bond markets?


Cycling progress

The continuing wet weather is playing havoc with my attempts to pile in the miles like I did last year. We've had what seem to be the only two days this week that won't be a wash-out; and one of those is a work-from-home day around taking Karen to exercise class.

Currently my odo stands at 3915.6, plus the 75 miles I did on a hire bike back in March. So I have comfortably -- by 80 miles or so -- made the easy target of 2000 miles since the end of last June (i.e. the 2nd year with the odo), most of that with help from the dry warm autumn we had last year. Doing another 85 miles to roll over the 4000 in the next 10 days is looking less and less likely each time I see a weather forecast. And getting from 788 miles so far this year to the 1000 looks right out.

Let's hope we have a fine autumn again this year.

Win32, RAII and C++ lambdas

Back when I was last writing serious amounts of C++ for pay (best part of a decade ago), I would end up with a whole bunch of little classes like this one:

to wrap those fiddly Win32 handle types with RAII behaviour; all much the same, most only being instantiated once, the only real difference being the contained type (which could be templated away) and the destructor behaviour (which isn't so easy).

With modern C++, you could wrap a pointer to the handle in a smart pointer with appropriate custom deleter. Or, avoiding the extra indirection from having to track the HANDLE and a smart-HANDLE*, take a leaf from how shared_ptr is implemented and do:

which directly holds a value (expected to be something pointer-like, like the Win32 HWHATEVERs) with RAII semantics; then in the code:

and apply the same wrapper to different types, injecting the deleter as a lambda:

Wednesday, June 06, 2012

Anime — The New Prince of Tennis

Something of a make-weight series, picked to give us an even number of series on the go; a sequel to a long-running series I'd not watched. But sports anime (even if this has about as much to do with tennis as Saki does mah-jong) are usually at least harmless tosh that don't involve hopelessly herbivore high-schoolers and their romance woes.

And on that level, this short series did not disappoint.

It started off simply enough -- a bunch of middle-school players joining a high-school summer camp, and showing their magical-boy tennis prowess against lads two or three years their senior. And then out of the blue, after a bout of sudden death elimination contests, it's suddenly mountain climbing, survival training and crawling through laser defence system like something out of Mission Impossible, until our heroes win enough karma to go back and face the top high-school squad.

Verdict -- did what it said on the tin.




That British obsession

We expected it to be wet for the Bank Holiday/Jubilee weekend, because it always is, especially after the best part of a fortnight of warm dry weather. But now that's over, you might think that we were going to be back to seasonal sort of weather.

Alas, we have a positively autumnal storm with plenty of wind and rain on the way for the next couple of days. So who knows when I'll next be able to get out on the bike.



Monday, June 04, 2012

The Prohibitionists are at it again

Saw this story in the Daily Wail while on holiday:


Don't drink more than quarter of a pint a DAY: Oxford study claims slashing the official alcohol limit would save 4,500 lives a year

Checking figure on the 'net, with a UK population of 62.3 million and average life expectancy of 80.5, that means 774,000 deaths/year. Subtracting 4500, gives a resultant life expectancy of a whisker under 81 years.


So, the killjoys might not make you live noticeably longer -- but you'd just not enjoy it so much (if the way that this contradicts all earlier findings actually holds up).


And that's before considering the cost/benefit analysis -- drinkers provide more revenue and on average cost less in lifetime medical costs anyway.


Sunday, June 03, 2012

Another sea-side holiday

Guessing in the early New Year that the weather might be getting warmer by the end of May, we booked again to take a week at Netley Waterside -- and despite some headlines mid-month saying that the cold weather would last at least another month, we did get the good weather, but without it being too hot and bright for driving into.

This time, nothing essential got left behind (though I did realise that my strategy for wet weather was not to be caught out in it), and swinging around well west of Reading and (thanks to a closure on the A340 near Aldermaston) Basingstoke too, the drive down was not too stressy, despite the nigh-constant sulking of the satnav when we declined to head for the nearest motorway -- and we got to see all the stationary traffic on the M1 while doing so.

From our window

From our window

The theme for the week was cars and boats and planes; not so immediately interesting as last time's wildlife focus, so we sat out most of the trips, and instead did expeditions at our own pace back to places we had gone last year, only in better weather, and without having to spend the best part of 2 hours in loading and unloading.

Monday we went back to Marwell Wildlife

Chico guards the troupe

and were able to go all around, and see most of the talks, including the penguin feeding, at what would have been queueing up to go on the coach time.

The one organized trip we did go on was to the Beaulieu Motor Museum, somewhere I'd not been for the best part of 50 years, and which Karen had never seen. So there was a lot of stuff that was either not yet built, or still in active service back then.

Extreme customisation

The centrepiece of the museum this year is a Bond in Motion display covering 50 years of cars and other transport gadgets:

A Bondmobile

Even the cars have stunt doubles...


Wednesday we took a rest, and just went down the road for a pub lunch, and then Thursday we went back to the Andover Hawk Conservancy, where again the flexibility of going by ourselves -- and the dry weather this time -- meant that we got to see all the displays, and not just the mass flights of kites and vultures. Even if the fishing eagle managed to splash down every time, rather than skimming its food off the surface of the little pond in the display area.

African Pygmy Owl

African Pygmy Owl -- as seen in ソ•ラ•ノ•ヲ•ト


And then to top-and tail the week, I went for a few exploratory walks, extending beyond where I'd done much less ambitious wandering last year:


View Netley Walks in a larger map

3812.2

So, with a late spell of warm dry weather, I managed to do a bit over 200 miles on the bike this month, and pick up the start of a sun-tan; though that would have been closer to 300 had I not gone on a non-cycling holiday last week.

So, it's a sporting chance to push the odo over the 4000 mile mark this month, but given the wet start to the proceedings (and not looking good for fitting in a long Bank Holiday bike ride), doing a full 1000 miles by the end of the half-year is probably a non-starter.

The Narcissist-in-Chief strikes again

Going on four years ago, I had strong vibes from the US presidential elections that the country was being swept by a "Things can only get better..." mood so reminiscent of what we had seen a decade or so before. After a couple of years, my thoughts on progress so far could be roughly expressed as

But even Cyclops never managed some of the not-fit-for-purpose stunts we've seen from the White House in recent months in terms of violating operational security. First leaking details of deep cover operatives in Yemen, and now boasting about Stuxnet.

I have no words.

Thursday, May 31, 2012

Observation notes

Venus having been a bright evening star all spring, I caught a last glimpse at 21:36 on Saturday, courtesy of clear skies and an unobstructed horizon, nine days before it transits, and 15 minutes before spotting Vega as the first real star of the night. Subsequently the fine weather has been tending to leave cloud in the west at evening, before socking in completely now.


Thursday, May 17, 2012

C# under the covers II

An initialisation problem I hit recently, a null pointer exception when initialising an object via an initialiser statement. This program is a simplified example --

which throws when initializing b.

Putting them together like this, it's obvious what I missed out in the second initializer : I'm not creating a new object to assign. But it's not obvious what the second case is actually doing, even though it compiles -- which in itself initially surprised me. So let's look at the IL and find out what that initialisation is actually doing...

which actually resolves to something like

So if we add a constructor and a sensible ToString to the type being initialised, thus

we see that the initialisation of a replaces the constructed values; whereas b adds to them.

Not sure how useful this is as the dictionary literal form only works in initializers like this, but it's another bit of living and learning.

Wednesday, May 16, 2012

Anime — Chihayafuru

Looking at last Autumn's season listing, this was the one title to really stand out, the one I hoped against hope that would get licensed -- Madhouse escaping from their Marvel phase, adapting a josei sports manga, where the sport is karuta, a curiously Japanese affair, involving memorizing the 100 poems, and capturing cards based on recognising the one bearing the closing lines of the poem being read out.


After a very brief current day set-up, the story flashes back from high-school to junior school, where Chihaya Ayase befriends Arata, the shy transfer student with the regional dialect being bullied by the rest of her class. He introduces her to the game -- she is mesmerized by the way he flicks the cards and such speed, and hooked by finding that one of the poems begins with her name. Both of them play at school and in the local club, and eventually become friends with fellow player and classmate Taichi, until Arata moves away with his family.


Taichi and Arata


Surprisingly enough, the skip forward to high-school does not end up presenting us with a love triangle with occasional card games -- there are more important matters, like recruiting enough players to get an official school club and team, and then it's off to the major tournaments, with Chihaya aiming to become the overall womens' champion or Queen -- the best in Japan, and thus the best in the world. Only this is not Saki (although the first passing encounter with the current Queen is reminiscent of the entry of one of the monsters from that series); older and wiser players can take advantage of Chihaya's over-impulsive speed, she can become unsure of herself, and not adapt to the person she is playing.


Facing off against the Queen


And between all the play, there are the relationships between the bunch of misfits that have been recruited to make up the team, the team with families and other players, and also finding out what happened to Arata -- once tipped to become the Master -- to make him give up the game in the intervening years. And so we end, a year after the start, everyone gearing up to do better in the next season. The manga continues, the anime, well it would be nice to dream.


The production of the series is definitely good Madhouse; and the character design subtle -- characters can be plain, or plump, or middle-aged, and the ones who are meant to be pretty do stand out. The story never becomes mawkish, nor does it sacrifice everything for romance with a flimsy excuse to get the principals together. Very definitely, anime of the year, 2011. Available in many regions on Crunchyroll.