Monday, February 25, 2013

FsCheck is great for for native code too!

I've just had call to write some good old-fashioned 'C' code recently, for use in an environment where my access to anything fancy like external libraries is limited. And a one part needs a simple transcoding function to take data in and manipulate it from the form convenient to provide into a form that's actually useful.

But of course, I want to test that bit before I start wiring it into place. There are, of course a whole slew of 'C' unit test frameworks out there, none of which I've used before, but really I wanted to just soak-test the algorithm quickly and simply, with a maximum of coverage and a minimum of distractions, so, I actually wanted a QuickCheck-equivalent tool that would "just work".

And this is where F#'s easy P/Invoke syntax (almost as simple as cutting and pasting out of the 'C' header file) and FsCheck were just the tools I was looking for -- write a property (or, in fact, a series of properties) that asserted that an input mapped by my function was the same as obtained using an equivalent .net library function already to hand as reference, invoke them with FsCheck.Check.Quick, and then TDD away, starting with the rough outlines as asserted by the early properties, and then filling in details as asserted by the later ones.


Sunday, February 24, 2013

Dear diary

After last week-end showing early promise of spring, with warm sunshine enough to be comfortable in a T-shirt outside, and thoughts turning to gardening, it's now gone back to grey and around freezing again, with three days of light snow flurries, though no perceptible settling.

At least the generally dry cold has meant that I've just had to wrap up well to continue the one day a week cycling to work (on average -- the 1st was washed out so I did the 7th and 8th). The downside of cycling in winter conditions has been picking up a lot of salty mud on the bike, and a chain that, despite drenching with GT-85, was often stiff in places after being parked a few days. That warm spell at least gave me chance to do a good clean and re-grease.

And the car is now at 8008 miles.

Recent Reading

Exaltations by Richard Garfinkle

A strange, almost indescribable, and most inventive meta-fiction, as a narrator of lives gets tangled, along with some of his subjects, into the machinations of the archetypal Quest. And as a tale about telling (or Telling), it scatters the seeds for a small library's worth of tales in passing. As airy ephemera, just to decorate one short scene, we are shown the three different-yet-similar versions of the Trojan War and the founding of Rome that spin from Paris' choice of which goddess to give the apple of Eris; and none of that is really important.

This time, the ending is satisfying if understated, rather than just fading out.

Star Carrier by Ian Douglas

Somewhat a change of pace, a good solid hard mil-SF trilogy that shows that the John Campbell school of SF still lives, as the US Space Force squares off against an ancient Galactic Empire, intent on subjugating the human race.

A solid page-turner of space battles and some seriously alien races in a purely relativistic setting with Alcubierre warps (handwaving away the engineering details involved).


Thursday, January 31, 2013

January round-up

Well, leaving work at around half-past five, the clear sky was still blue. Dark blue, admittedly, but definitely not night-black. The corner is well turned; and as an additional sign of progress, some time in the last few days, the snowdrops have come out in the front garden.

And I close the month with 178 miles cycled, and the promise of a wet Friday morning, which will break my run of cycle to work Fridays.


Monday, January 28, 2013

Numerology

Got home from work today with the car odo reading 7777. Given that the worst of the long nights is well behind us, that's looking to give another very low total for the year.


Sunday, January 27, 2013

We're all going on a Google Holiday...


Having been prompted by a post on the Cycling Holidays Google+ Community asking for pictures, I put up a gallery from my holiday to the Vendée back in 2005. And then I thought to my self to check how Google Maps (and Streetview) had come along since the last time I went to France, to see if I could actually find some of the places I'd taken pictures of.

Back in '06, when I first used Google Maps to provide me with detailed street maps for terminal guidance, the streets were there, aerial photography was very coarse grained, and of course Streetview didn't yet exist. Now, a fair amount of the '05 route was covered, or at least paralleled on the other side of a river or canal; and it was surprising quite how much of the route I remembered while virtually jaunting along it.

Which led me to digging out the paper maps from the '05 and '06 holidays, and retrospectively adding approximate maps to my blogged accounts, after reprising significant sections of the way from the comfort of my study, doing a virtual summer while the snow lay around outside.


Friday, January 18, 2013

Recent Reading

In the Mouth of the Whale, by Paul McAuley

Set in the future of The Quiet War/Gardens of the Sun (either ~1500 years or 3.5 teraseconds, depending on who's telling it; but as there's a factor of 100 difference between those, who can tell?). And, yeah. Three interleaved tours of the balloon factory and a literal dea ex machina ending.


Blue Remembered Earth by Alastair Reynolds

This one justifies its tour of the balloon factory as a scavenger hunt around the Solar System, intermixed with elephants. And the following volumes in the sequence seem likely to be taking the scavenger hunt further afield yet, though I shan't be in any hurry to follow.


EmbassyTown by China MiƩville

This one actually has an interesting idea about language and communication, though it takes its sweet time getting there, with a lot of scene setting that skirts around the really significant features of the eponymous enclave before actually setting up the salient parts of the status quo and its disruption. Easily, however, the best of the bunch.

Tuesday, January 01, 2013

A journey of a thousand miles begins with...

Well in this case, with the new year having dawned bright, if breezy, it began with a thirty mile bike ride, looping into the more rolling country to the south of Cambridge, having started off into the wind. So that's about 1% of what I want to do this year already accounted for.

And then I did a bit more tidying up in the garden, mainly clearing up dead crocosmia straw; though if the mild weather continues, I shall be wanting to mow the lawn soon (as indeed one of the neighbours was doing today), as well as needing to prune the apple trees. Maybe this weekend


Monday, December 31, 2012

Anime — 2012 in review

A fairly weak year in all, with pretty much no series that grabbed, as can be seen from the gradual slowdown of reviews over the year.

Carrying over from last year, I watched Chihayafuru, and the third season of Natsume Yuujinchou; and on DVD, I started to watch Puella Magi Madoka Magica and House of Five Leaves, but haven't finished either of those yet.

Winter season

New Prince of Tennis I watched as a filler, back when we had enough series on the go to watch a couple of episodes a couple of evenings a week, and was mostly harmless.

I'm also still in the middle of the 4th season of Natsume Yuujinchou, which has lost a measure of the charm that it opened with, but will cover that separately when I'm done.

Last, and the best looking of the season's choices, Moretsu Pirates, which started out in surprisingly good form, with our heroine rising to the challenge of an unwanted inheritance, and showing some decent can-do, by teaching Kzinti Lesson 101 to a mysterious ship that had been dogging the school yacht club cruise exercise. But that potential plot line just got dropped, and as we moved onto the actual space pirates, arc after arc followed where any tension or challenge was undercut into anti-climax, as everything had to end up happy-happy and safe. And so a two cour series dragged out until late November.

Spring season

Ozma, I reviewed at the time.

Saki: Achiga-hen was a spin-off from the earlier school-girl mahjong series, focusing on a different school team battling their way into the national championship, but with only 12 episodes to date (more to air in the new year) covering from years before the events of the first series into the tournament stage beyond where it had reached, it's way more compressed. Three episodes pass before any games are played, and it's even then most of them are done in fast-forward (so no real display of their magical-girl style abilities), until the final match, where the first game is then spread over the last three episodes.

Everything else is unfinished, may not finish.

In arbitrary order -- Space Brothers had an interesting premise, but a mix of slow, slow pacing and Japanese humour ground me to a halt about ten episodes in. One episode of Kuroko no Basuke was enough so soon after New Prince of Tennis (only so many magical boy anime I can take at a run); Folktales of Japan turned into too much of a good (the same) thing, with two tales out of three seeming to involve a bumpkin stumbling onto some magical fortune, and ne'er-do-well neighbours trying and failing to duplicate the trick; Kids on the Slope was a josei series about jazz and school life in the 1960s, but when it got to be an "A likes B likes C likes D likes..." chain, I stopped caring; and while the art style is interesting, Tsuritama's characters failed to engage me.

Summer season

So, I'm in the middle of, and will probably finish Uta Koi, a collection of loosely inspired stories about the Hundred Poems.

Apart from that, I tried an episode of Jinrui wa Suitai Shimashita, which was amusing for starting with the MC saying the terrifying words "I'm from the government, and I'm here to help."; but it laid the satire on without subtlety, and what I saw from threads on /a/, that continued, even beyond the bounds of reason for the apparent setting. So not picked up.

Autumn season

Unfortunately, Crunchyroll didn't pick up JoJo's Bizarre Adventures, which was the only title of the season that would have been a "must watch". I did try the first episode of Shin Sekai Yori, but it also failed to excite; and subsequent reactions didn't help, as it became clear that the adaptation was being done on a shoestring budget and was suffering from having pare down the original material hard to fit into the two cour format ("If you'd read the novel, you'd know that..."), so not picked up either.

Blast from the past — Neon Genesis Evangelion

So I actually rewatched the series that has been eating up a lot of my fanac time for the last nine years, the original DVDs with the as-aired series and none of the later retcons in the so-called Director's Cut revisions, as I did first time around. The main difference was that I watched with Japanese language and subbed all the way, rather than switching from the Texan dub part-way through, which had the effect, inter alia, of making Asuka less annoying in the episodes before she gets clobbered by the plot.

This is a series where you can't really step into the same river twice even if there are always going to be details that elude recollection. The first watching, unspoiled save knowing that if you were going to watch a giant robot anime, NGE should be it, but that the last two episodes were controversial, meant that everything came as a shock. After years of taking it apart almost frame by frame, with reference to the script in the main, less so.

It still falls into the stages of being Shinji, plus some Rei; then a long arc in the middle where it's really Asuka's story so far as I'm concerned, and only at the end, when nobody else is left standing, does it become Shinji's again. But then as is plain to see, it was Asuka whose plight struck me deeply first time around, and still remains the character that I wished the best for.

And, even knowing the orthodox interpretations, typically based on the DC material, there was nothing that on review shook any of the surprisingly heterodox conclusions I came to, from Asuka's lack of any serious interest in Shini through to the completely democratic nature of the upload-style "Gendo wins" Instrumentality at the end.

"Rebuild of Evangelion"

Yeah, the third of the remake movies came out about six weeks ago in Japan. After having been somewhat jaundiced by the first apart from the updated eye-candy, I still haven't watched the second yet. Where I said back then that it looked to be heading into bad fanfic territory based on the "Next Episode Preview", things panned out much that way in the end by all accounts, with all the characters reworked, in the new episode of the Shinji Ikari Show.

So, yeah.

Meanwhile the latest episode, Evangelion:Q seems to have discarded everything from its preceding "Next Episode Preview", and would be a whole new super-robot franchise, were it not that it's actually yet another Shinji movie, and one driven by an idiot plot to boot.

I wouldn't say that I liked the original despite Shinji, but back then he was just a harmless nebbish most of the time, despite his own self-denigration. The revised version from EoE was one who lived down to that evaluation, and this third version seems worse, if anything.

So, unless the concluding episode, Evangelion:||, pulls off something remarkable to redeem the preceding films, I doubt I shall be bothering with those, either.

5592.9

is what the bike odo reads now; or just over 2390 miles in the year, 2688 total when adding in all the holiday cycling on hired bikes. Almost 600 miles in the last quarter, and 135 miles in December alone, only about a third of which came from unexpected journeys.

Having made the experiment of cycling home after lunch and working from home on the last working Friday of the year, I might do that again for other winter weeks, if there is good weather. It will help keep me from getting quite so out of condition for the spring.


Wednesday, December 26, 2012

Fifty years ago, today...

It snowed, and the snow didn't shift; temperatures staying below zero for more than a month. It was the winter where I got put off drinking milk, because our 1/3 pint bottles of school milk were delivered frozen before school and then jammed under radiators until break, resulting in lukewarm cream with blue icebergs floating in it.

Today by contrast, it is above freezing, and started bright, so I went out for a spin on the bike, passing through the one remaining flooded bit in the vicinity, where a village duckpond has annexed the road nearby; though rain has now set in again.


Saturday, December 22, 2012

Wet, wet wet!

It has been chucking it down these last few days, and looks to be continuing that way.

Thursday morning when driving to work, there were a few very large pools on the roads where water was collecting after draining from the surrounding fields, though the Bourn Brook didn't seem to have risen significantly, so I went home at lunch time, to remote work for the rest of the day, by a longer route, to be able to see and avoid water hazards.

Friday's forecast being for a respite, I cycled to work (Monday's forecast showing wet), and there were road closures for flooding around Caldecote then, though they were gone when I headed home mid-afternoon.

Dreaming of a wet Christmas is all very well, though the mild weather means I really need to go mow the lawn, but it's far too wet for that -- or much of the other midwinter tidying that I would normally do over the break.

Sunday, December 16, 2012

Powershell 3 -- automatic variable gotcha

PowerShell automatic variables are useful for giving a way in to system state, but oh, how I wish that they had been sigilled rather than looking like user-definable names that one might actually wish to define. And worse when the behaviour of the variable name changes between revisions.

Here's an example that bit me the other day, in the wake of WinRM 3 being pushed out on automatic update into an environment that had previously been .net 4, PowerShell 2 only. It was a script a bit like this (but without the $host reference):

In Powershell 2

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1
System.Xml.XmlDocument

xml            : version="1.0" encoding="utf-8"
xml-stylesheet : type="text/xsl" href="path\to\microsoft fxcop
                 1.36\Xml\FxCopReport.xsl"
FxCopReport    : FxCopReport

But in PowerShell 3

Major  Minor  Build  Revision
-----  -----  -----  --------
3      0      -1     -1      
System.Object[]
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="path\to\microsoft fxcop 1.36\Xml\FxCopReport.xsl"?>
<FxCopReport ...

All because $input is an automatic variable rather than a user definable name -- and, worse, one that has had some semantic change between revisions. Now, if it had been $$input with the extra $ being a reserved character, this sort of unwitting name clash could never have happened. And there's no real penalty in having to type $$host to get the PowerShell host data, or similar.

Friday, November 30, 2012

43 miles to go

Due to some unforeseen opportunities for cycling. including a wonderful ride by the light of the full moon, to and from dinner out on Wednesday, I'm now closer than I had expected to my stretch goal for the year (making a total 5500 miles on my bike alone in 2.5 years) with a month to go. And with things to do over the weekend, and dry if cold weather, doing the best part of that remaining 43 miles in the next two days seems quite plausible.

Might I have to aim at 5555 rather than 5500? That would be pushing it, trying to fit in just under a hundred miles in the next month.

48 Hours Later: Two thirds of that 43 miles achieved, running errands in cold and dry (except where the sun had thawed things out by Sunday afternoon) conditions.

Tuesday, November 27, 2012

.Net under the covers

An interesting little oddity I stumbled across the other day, involving StringBuilder.AppendFormat, and a string which it turned out had had a GUID already expanded into it, and an unexpected exception result

so it looks like the parse for a number is run before checking that the format is even sane; not what one would have expected.