Wednesday, January 04, 2017

C# under the covers III

So, you have some code that looks like this


    private static bool Match(int item, int? target)
    {
        if (target.HasValue)
        {
            return item == target;
        }

        return false;
    }

How many tests do you need to write to get 100% branch coverage?

If you answered "two -- one with a value, one without", you'd be as surprised as I was when I tried it.

It turns out that the implicit extraction of the value of the nullable value contains its own HasValue check, and the IL looks like


IL_0000: nop
IL_0001: ldarga.s target
IL_0003: call instance bool valuetype [mscorlib]System.Nullable\u00601::get_HasValue()
IL_0008: ldc.i4.0
IL_0009: ceq
IL_000b: stloc.1
IL_000c: ldloc.1
IL_000d: brtrue.s IL_002b

IL_000f: nop
IL_0010: ldarg.0
IL_0011: stloc.2
IL_0012: ldarg.1
IL_0013: stloc.3
IL_0014: ldloc.2
IL_0015: ldloca.s CS$0$0003
IL_0017: call instance !0 valuetype [mscorlib]System.Nullable\u00601::GetValueOrDefault()
IL_001c: bne.un.s IL_0027

IL_001e: ldloca.s CS$0$0003
IL_0020: call instance bool valuetype [mscorlib]System.Nullable\u00601::get_HasValue()
IL_0025: br.s IL_0028

IL_0027: ldc.i4.0

IL_0028: stloc.0
IL_0029: br.s IL_002f

IL_002b: ldc.i4.0
IL_002c: stloc.0
IL_002d: br.s IL_002f

IL_002f: ldloc.0
IL_0030: ret

Roughly, it goes "get a value, or the default, and test that; if not equal, accept that, otherwise only accept the equality if the nullable had a value."

If you write


    private static bool Match(int item, int? target)
    {
        if (target.HasValue)
        {
            return item == target.Value;
        }

        return false;
    }

then there is no compiler-generated branch for you to be caught by -- and it's probably slightly better coding practise, anyway.


Monday, January 02, 2017

Anime — 2016 in review

In the unfinished business area, I carried on with Symphogear G, which, after a cour and a half at last managed cohere to enough to deliver a decent number of set pieces in the last half-dozen episodes, and Bikki-tan is starting to get the hang of this magical girl business, including a closing move worthy of the White Devil herself. It was the other characters that needed a bit of a talking to, for a change -- "Excuse me, ladies, but why not postpone the emotional reunion scene until after you've stopped the bad guy who's slinking away stage right?"

All in all, trashy fun with cute girls finally figuring out how to punch everything into daijoubu.

I then continued on to Symphogear GX which was an odd mess -- the fights are cool enough, but Hibiki's hard reset every season is getting old -- by now she should be confident in dealing out the Power of Friendship ("with a Determination to Fist", as the season subtitle puts it). While it was not overall as bad as some of the detractors make out, it somehow managed to make what ought to have been a spectacular finale come over as just "meh" -- which is really the problem with the franchise as a whole. It ought to be something that is full of "Hell, yes!" moments, but those end up being restricted to the first episode of the season only; a measure of how flat-footed the delivery is.


One of the things I got as a Christmas 2015 present, for watching during the Winter season (where none of the airing titles grabbed) was the complete Nadia : The Secret of Blue Water, when we watched the first couple of episodes, they were absolutely charming. Despite being a series that gets talked about regularly, it felt like I was coming to the series quite unspoiled, which was an extra bonus.

As time went on, it went to some strange places, especially watched in proximity to Symphogear, where the two apparently very different series display a bizarre overlap in motifs (Finé clearly had something to do with Gargoyle's use of heretical technology). After that arc, though, during the Nautilus episodes, the series began to feel more and more like a French made-for-children series (rather than the "all ages" appeal which even toy commercials like Mobile Suit Gundam managed), and there was much less pull to watch it, especially as we moved into the Spring season and suddenly there were new airing series that caught my attention.

Plus, at past the half-way mark, I still wasn't feeling it -- the characters are irritating at best, fading into just ciphers at worst. Even with a detour past the notorious island and Africa arcs, or even if the quality had been maintained, I was still in the frame of mind to be eyeing the fast forwards button by that point, though I didn't feel as betrayed by it as in other similar cases, such as Madoka. Currently stalled with 4 episodes to go.

On the pure Gainax side, if Electra is a proto-Ritsuko, then Sanson is clearly a proto-Kamina; and Nadia is just an annoying little madam. At least with that as a trial run, NGE handled the "kids caught up in the adults' conspiracy" set-up way more deftly.

Of the spring series, there were three I actually watched through --

  • JJBA : Diamond is not Crash, which provided fabulous Saturday morning cartoons for the rest of the year, fitting surprisingly well into 3 cours despite being many chapters longer than Stardust Crusaders
  • Gundam Unicorn Re:0096, an edit of the earlier OVA into a 2-cour TV show -- plenty of UC Gundam nostalgia, but boy, was that ever a poster-child for "Japan doesn't into endings"! -- having bigged-up Laplace's Box beyond anything reasonable, topping it off with a 2001-style lightshow and Char Full Frontal channelling Keynes and then ... anti-climax when spending just a couple of minutes on an epilogue could have helped, to save it from being full of sound and fury but ultimately seeming to signify nothing; and
  • Flying Witch which turned into the surprise hit of the year, a relaxed, slightly magical, slice of life, the best in the style to come along since Aria, with only a minimum of school intruding on the lives of the teenage characters (the banal effect of the default setting showed in the weak and cliché driven

    > at school
    > anime girl can't cook

    episode that felt phoned in from some other SoL, with even the rather over-magical anime-original final episode being better). I did, however, find the episode where they weeded a substantial plot to bare earth in just a few hours, with no magical assistance, to be a bit stretching of the suspension of disbelief. Props also for having a boy in the cast who isn't any sort of romance self-insert.

There were also a bunch of tried-and-dropped-

  • Phantom World where I watched episode 1, to see the notorious limbo dance in context ... and it's all irritating fanservice all the time, peaking in the bit where MC trips and doesn't FOOSH.
  • Space Patrol Luluco lasted 4 short episodes before the attempt to mix DORAMA and LOLPlot into the off-the-wall stream of consciousness insanity like Inferno Cop was told me it was time to stop.
  • Hai Furi which had promise of being the new Girls und Panzer just went somewhere else. It could have done with just a brief explanation of what the ostensible purpose of the Blue Mermaids is by way of scene setting (not an extended exposition, just something quick and to the point like GaruPan introduced sensha-do), pulling forwards material from the second episode before going about undermining the superficial appearance of being just "cute sailing girls doing cute sailing things". Alas, that mishandling was a sign of things to come, and I dropped at the oh-so-hilarious "we're out of bog rolls" episode.
  • Anne Happy, with its fairly off-the-wall premise, was more entertaining than most of the CGDCT shows that I've tried (they usually feel like a chore to wade through even a first episode), but alas it spiralled through surreal into just downright stupid in very short order.

Summer opened with the promise that Amanchu would take on the cozy/comfy niche, being from the same mangaka as Aria, but it came off the worse in the immediate shift of gears and scenery -- and a lot more school than I'd expected. Flying Witch was comfy, this is irritating, with the "aren't they quirky? Look!!" being played up too much, like Pikari being in face-fault mode so much that when she has a normal face it just looks like "who is this different character? There was a only whistle-blowing muppet around just now" instead. Overall, Pikari is way too over-caffeinated genki, the mascot character Cha is just as bad as President Aria, and Teko is just a doormat.

Two episodes were quite enough -- the figure hugging outfits and fetish boots don't go anywhere near far enough to rescue this from disappointment of the year status.

I watched the "behind the scenes" episode 0 of the Taiwanese puppet show Thunderbolt Fantasy. Having grown up on Supermarionation™, it was both weirdly familiar and at the same time subtly awry (they don't have any strings!) -- but it looks worth going on with, so in the queue for now.

Autumn brought the first episode of The Ancient Magus' Bride OVA which shows promise -- just so long as it's not too much concentrated on the "little girl suffering for being the nail that stands out" part, and is more on the magical Natsume/Mushishi-like side of being able to see the youkai. With the opening shots of Big Ben and fog on the Thames, I was expecting something Victorian -- but then, suddenly, there's the Shard! -- even if the rural English framing does have some "Lol! Japan" touches.

I also sampled the first episode of Flip Flappers, and it felt like FLCL meets Daicon IV in The New World. Papika (the Daicon girl/Haruko fusion in the mix) is one of those infuriating brain dead genki girls just like Pikari, and around her the art style of the show wobbles from Imaishi-style wackiness, to acid flashbacks to Shin Sekai Yori in the respites between the manic bursts. Verdict -- Dropped like a colony.

Faring better, Izetta the Last Witch -- the BUNBUN sameface is quite strong in this one, with Nogi Wakaba-hime getting rescued by Takashima Yuuna in the first episode. Queued for later.

And half-way through ClassicaLoid, which is an odd mix of the whimsical and the dumb -- including the electro-pop renderings of various popular classics. Where it sticks to being SoL/comedy plus rework classical music videos, it's amusing fluff -- and so far it doesn't seem to be suffering too much from the vague plot. Ongoing.

The last couple of months have been marked by a lot of raiding the archives.

It started when, on a whim, I went back and resumed watching Tsuritama (that fishing anime from 4 years ago). First time around, I watched the first episode and said "No thanks!" to the instances of the MC sperging out, however uniquely portrayed, expecting that to be an ongoing thing the whole while. Starting again at episode 2, I was pleased to find that it got throttled back to the occasional goofy face, and the slice-of-life aspects carried it. And even when the plot emerged at about the halfway mark, it didn't do it in a massive change of gear (as so often happens). Even more surprisingly, that deft handling carried through the climax, to an actual satisfying conclusion, and as I remembered from the first time around, I liked the art style.

I then picked up IdolM@cross 7 AKB0048, notionally a promo thing for the AKB48 idol group, but under the influence of Shoji Kawamori (Macross, Aquarion) it cuts the mundane idol shenanigans with mech battles and quasi-magical girl action, under a premise of cute girls doing idol things IN SPAAAACCCCEE! vs the No Fun Police. It was fun enough to follow through to the end, though I'm not sure that I would have kept up with it on a "while airing" basis. The second cour, in particular, sagged a bit in the middle, and the ending was not as good as it could have been -- the opening of what was supposed to be the most impressive live show of all time (in order to activate the plot) was one of the limpest of the AKB numbers used, weakly delivered, and not a patch on their first appearance in the very first episode. Even hauling out the first OP number for the climax was below its use at the end of the first cour, added pyrotechnics notwithstanding.

The ending was not a very tidy one -- leaving an unexplained death, ambiguity as to exactly how along the scale through "A New Hope" to "Return of the Idols" the idol rebellion has come, and one of the in-group character conflicts completely shelved. And given how the show turned out, with only minor adjustments, the use of 3DCG in the group dancing scenes could have been given an in-story justification, as manifesting the original AKB.

Paranoia Agent, at least after 3 episodes, comes over as rather more tedious than I recall, a problem of knowing what is going on in broad that removes the "WTF is going on?" appeal. By contrast, on a third go around, Mouryou no Hako is being even more rewarding, when you can appreciate all the clues laid in plain sight, and the sheer density of the storytelling, and I gulped down the first five episodes in one sitting.

And for a surreal experience, I watched the first episodes of Yuri Bear Storm and Penguindrum one after the other -- so clearly the work of the same man, with all the common stylistic quirks. The former, alas, failed the 3 episode test, being pretty, but very, very tedious, and the stock-footage fanservice doesn't help it, either. I'm not inclined to continue just to find out whether a kitten gets killed at any time in this series, or if Ikuni has given up his Kaworu act.

As a change of pace, I watched the first couple of episodes of Twintail ni narimasu, which were amusing enough trash that I might watch some more, though it doesn't look like I'll be watching it on the strength of the fight choreography.

Finally, I've started my approximately every 4 year rewatch of Neon Genesis Evangelion (last done in the aftermath of the release of Q in theatre in Japan), currently up to episode 6. The material is familiar, but with enough time passing, the details blur into summary, so I can watch with as near new eyes as I can ever manage -- for example, this time around I actually noticed and WTF'd at the blooper about Misato's arrival at the station in episode 4. For the first time I'm watching the Platinum version, rather than the original OA DVDs, which gives the occasional WTF just in itself (the changes in the episode titles, mainly).

Then, with the original fresh in mind, to round off the year, I rewatched Rebuild 1.01, which was indeed a rather more downbeat take on the same material as episodes 1-6, and it wasn't just that the gloomy lighting balance in that version had stuck in my memory -- not only was Re!Shinji more of an introspective misery-guts than the original, even getting in an early hell-train ride, but so were practically everyone else, and the No Fun Police had gone through and removed any of the levity aside from the toothpicks scene, in favour of splashy spectacle.

Sunday, January 01, 2017

Books of 2016

I have a substantial stack of unread books that I've accumulated over the year, because some time in the early part of '16, I got an "if you like Glen Cook, you'll like this" recommendation for Steven Erikson's Gardens of the Moon, and I got sucked into the whole ten volume saga of which that was just the first.

It's addictive, in the sense that there's never any good point to stop, because something is always about to go down in one or other of the many interwoven strands of the narrative, just in time for a "meanwhile, on another continent, half a world away" to put everything in one theatre on hold as we move between books. With book 5 that gets taken to extremes. A character gets introduced at the start of book 4, and their strand of the story has them saying from time to time about it being useful to explain the predicament they were found in, and ends that book getting to a significant place and about to tell their tale -- and book 5 turns out to be that story, starting "long ago, on a continent far, far away,...". And in the scope of it all, times when apparently abandoned plot threads suddenly burst upon the scene again thousands of pages later

Now, 10,000+ pages, hundreds of characters, dozens of battles, many real-time months (only finished in the last few days, with it being my sole fiction reading all year), and several continents later, each volume about 1000 pages of set-up and 100 where the dominoes start to fall, there was a reasonable end to the saga, which I hadn't been expecting when I started the final volume. It should not come as a surprise that few of the characters we meet at the start survive until the end, though for some of those who don't, death, it turns out, is just another career move.

Also, unsurprisingly, there is a degree of padding and waffling, with characters engaging in somewhat sophomoric philosophising, which had me thinking "Oh, come on!" and "Get on with it, for goodness' sake!"; and a fair amount of building up minor characters simply so they can be given a tragic death scene, or can accidentally stumble into the way of some other more powerful actor and screw things up for them.

Still, it was entertaining enough for me to read through for all these months, and I applaud it for its ability to give a feeling of deep mythological time, and in eschewing the all-too-common fantasy clichés -- there are dragons as an ancient threat, but the nearest thing it has to a standard non-human race are the sort-of Dark Elves, which are more like Melnibonéans (in one case) or Vikings (in another) than anything else; the various ogre-ish/demi-giant types don't slot into obvious Monster Manual niches, and the dino-birds with the mole-rat social structure that form a threat that bubbles under for several volumes are definitely their own thing. And you can assume that the main participant race is not-quite-human either, given that the unisex armies actually function.

There are occasional points where the "from notes I was making for a tabletop RPG" origin slightly leaks through, but never offensively so, and occasionally as self-aware humour (the shop in not-AnkhMorpork that sells short lengths of rope and 10 foot poles, for example).

Saturday, December 31, 2016

That was the year that was

This time last year, work, including some extra responsibilities, voluntarily taken on, that had spiralled beyond what I had expected, combined with the commute to the Science Park, and having to keep things functioning on the domestic front, had really ground me down. I didn't even manage to summon up the time and energy for several of the needful gardening chores (woodwork maintenance and apple tree pruning) across the holiday break.

So, sooner than I had planned (meaning to do it this coming year, as a down-shift towards retirement), I applied for reduced working hours, which cut in from the start of May.

That did the trick for the moment -- I've been able to attend more to things that are neither work nor the bare minimum of domestic chores. That included enough time in the garden to do pre-emptive weeding, even suppressing the bindweed as it emerged, as well as time to do more in the kitchen than simply heat up ready-meals every day, while still leaving time to just kick back and unwind. I even managed to do a tiny bit of side-project coding (hence the few posts on Rust in recent months), which is up on the zero I managed in 2015.

In the wider world, what a year it's been, too.

A year ago, we didn't know the date when Cameron (who he?) would call the referendum he'd been bounced into, and I expected it would be late 2017 and the status quo would prevail; and I was expecting that Hillary would comfortably beat whichever of Ted Cruz or Marco Rubio (who they?) won the Republican nomination. At the end of the year, what had transpired was beyond anything I could reasonably have hoped for.

What I hadn't expected was the number of people I follow on the internet who I thought were reasonable and level-headed, yet who completely lost it following the election of a New York liberal to the Presidency, like they actually believed all the "literally Hitler" caricatures.

It all means 2017 is going to be interesting, though I devoutly hope, not too much in the Chinese sense.

December Cycling

Up to 14369.0, ??, 126.1 -- with the odo on my main bike having failed on the last journey home from work for the year, so 19.6 + three commutes, including some long way round + two shopping trips + 4.1, at most being 120-ish miles, or 3340 at year end. There was too much to do in the garden to have spent much time on two wheels over the holiday. But I have fitted a new odo to the main bike and will be counting from 0 rather than making up a number around 4600 for the total miles done so far on that one.

With the likelihood of driving a couple of days most weeks in the coming year, I'm not setting myself any new personal best or even better-than-last-year targets.

Wednesday, December 21, 2016

Bringing your consumer NAS onto a static IP or non-standard DHCP subnet

Having gone through this again recently, as I upgraded from the Seagate Central I bought a couple of years back to a later and bigger version, a note to self for when I go through the exercise again in a couple of years, to save having to put it together again --

  1. This is the Secret Sauce : with a dual-NIC computer (e.g. one that's on the home subnet on WiFi but also has an unused ethernet port) set up Internet Connection Sharing of the WiFi to the ethernet. That makes that PC act as a DHCP server on the default 192.168.0/8 subnet on the ethernet link, which is where we can bootstrap the process.
  2. Connect the NAS and the PC to a switch.
  3. Now administer the NAS from the PC to configure its network settings to your main home subnet.
  4. Do not panic if the NAS admin page tells you the reconfigure has not been saved because contact has been lost with the device.
  5. Unplug the NAS from the switch and connect to your router.
  6. Now breathe a sigh of relief as you can now see the NAS on the main network, then complete the NAS set-up.

The presence of known vulnerabilities in consumer NAS software means that it is also advisable, after a first firmware update, to close all outbound connections from the device, apart from DNS (which tends to be the protocol used for connection liveness testing), so it doesn't go calling out to any remote access server. You do block all the inbound connections already, don't you?

Yes, this means you can't watch your movies while on holiday, but if that's what you want to do, why ever go anywhere in the first place?


Wednesday, November 30, 2016

November Cycling

Up to 14,349.4, 4,113.0, 122.0, meaning 20.4 + 71.4 + 12.2 = 104.4 miles, a real collapse as I tried to maximise daylight hours in the garden, and also attend meetings ending at 3pm. That's 3219.6 miles YTD, and maybe 3350 at year end at most, depending on weather.


Tuesday, November 29, 2016

Winter is coming

The car was telling me it was -4C this morning at a quarter to seven, dipping to -6C in the country lanes, and only recovering to -3C by the time I got to the office. Brrr!

Sunday, November 27, 2016

Fixing SMB access in recent Windows 10 updates

One of the updates that came down the wire to the machine I'm running on the insider slow ring in the last few weeks had the effect that trying to access the SMB share on my router gave a message like

\\Remote-Server\Path is not accessible. You might not have permission to use this network resource. Contact the administrator of this server to find out if you have access permissions. etc.

Breaking out Wireshark and comparing a machine still on build 1607 (local account login) with the test machine (MSFT login) showed that the SMB handshake would perform the initial exchange of Session Setup AndX Request, NTLMSSP_NEGOTIATE and Session Setup AndX Response, NTLMSSP_CHALLENGE, Error: STATUS_MORE_PROCESSING_REQUIRED, but the test machine would not then emit a Session Setup AndX Request, NTLMSSP_AUTH, User: Machine\User packet. Further experiment would be needed to tell whether this is because I'm running that machine with a MSFT login rather than a local account, rather than it being an insider build, but in the end, the fix turned out to be going to Control Panel\User Accounts\Credential Manager and creating a new Windows credential just for the Remote-Server address, with username and password sufficient to log on to the share (so for a wide-open read-only share, any username and an empty password will do).

Friday, November 25, 2016

Down Under Comes Up LIVE

Fifty years ago today, due to a launch malfunction of a communications satellite, the BBC ran an opportunistic program with the first live TV broadcast from the UK to the Satellite Tracking Station in Carnarvon, WA. And so I got to appear on live TV.

Me third from left in the front row.

UPDATE: More at honeysucklecreek.net, including a tidied up summary video. I'm on screen about the 3:50 mark.

UPDATE 2: Now in colour, me in the middle with the shadow of the microphone on my chest.

Tuesday, November 01, 2016

October cycling

Up to 14,329.0, 4,041.6, 109.8, meaning 104.9 + 11.7 = 116.6 miles, a real collapse as I tried to maximise daylight hours in the garden. That's 3115.6 miles YTD, and maybe 3500 at year end, depending on weather. And no late cycle holiday this year, as I had kittens to look after as well.

Friday, September 30, 2016

September Cycling

Up to 14,329.0, 3,936.7, 98.1 and 1.7 off meter, meaning 86.9 + 116.2 + 11.6 + 1.7 = 216.4 (2999.0 YTD, well behind last year) after a month where extremes of heat and wet, and the closing in of the evenings, meant more incentive to drive early to work, and, more importantly, get home early, after a full day's work done. And as the days get shorter, and remembering how draining cycling through last winter was, I suspect I shall drive more, and will probably fall well short of 4000 miles this year.

What I didn't realise until totting the numbers up this evening, was how few miles this month, the Cycle Challenge website having vanished at the end of August, and so no daily logs.

Wednesday, August 31, 2016

August Cycling

Up to 14,242.1, 3,820.5 and 128.8 off meter, meaning 19.3 + 183.4 + 128.8 = 331.5 miles (2782.6 YTD -- slightly up on last year, with its dreadful summer, but behind the pace for 4200 whole year, even at a steady rate).

I did manage a cycling break over the Bank Holiday weekend, with no worse than a few spots of rain on the Sunday, and glorious weather thereafter. No really long days, 50 miles being the longest, from Framlingham, up Route 1 to Beccles, then Route 31 to a very busy Southwold, a stop for rehydration, and then the last leg to Westleton, taking advantage of the dry weather to use the by-way from Walberswick where I came a cropper a few years ago -- only this time with only sand to worry about.

Town sign

I even managed to do a fair amount of new terrain, like the Route 1 off-road into Halesworth (which ought to have been the first day's destination, but once again there was no room at the inn), then everything north of Brampton on the Monday, then on the homeward leg, crossing the A12 just north of Saxmundham. OTOH, some bits I thought would have been new, near Gt Glemham, I had in fact already covered, even if only once and as recently this spring, taking a long route back from Framlingham to Woodbridge -- but this time the weather was glorious.

Saturday, August 13, 2016

A cycling anniversary

Today concludes my second year logging my journeys on the Cambridgeshire Cycle Challenge website, over which span I've logged 1137 (up from 601 = 538) journeys covering 8166 (up from 4204 = 3962) miles; supposedly 1302 kg CO2 saved (ignoring my increased respiration when burning the 147, 556 calories it tells me I have spent doing so) and saving £910.03 on fuel (ignoring the costs of fuelling me or running through consumables like chains).

Those wet spring and summer months are really showing on the numbers, now; as does an increasing dislike of the cycling conditions (= other road users) on any route to the Science Park.

Sunday, July 31, 2016

July Cycling

Up to 14,222.8, 3637.1 and 86.5, meaning 4.4 + 288.0 + 64.2 = 356.6 miles (2451.1 YTD -- and slightly behind where I was last year at this time).


The month started better than June had been, so inspiring me to start the month by filling in the wedge at Burwell, but was overall somewhat so-so, despite the real heatwave around the 20th. A week away at the end of the month meant no commuting miles, but just a few shortish rides for pub lunches, on the folding bike, around what became disappointingly wet weather.