Ansible is Stringly Typed

Summary

Ansible is weakly typed, but in particular variables set on the command line are stringly typed. If a string is used in a condition (e.g. when: skip_build) it leads to surprising results, because any non-empty string (e.g. "false") evaluate as truthy. I recommend casting all variables in conditionals, or other calculations.

»
Author's profile picture Alex Willmer

Verbose regular expressions, now you have one and a bit problems

Regular expressions (regexes) are famously hard to read or write. There are some techniques you can use to improve this. Like any other code you write, your regular expression patterns should

»
Author's profile picture Alex Willmer

Taste testing for fun and profit

Last week I ran three blind taste tests at a local meetup. They covered cola, diet cola, and chocolate sandwich bars. I wanted to find out what goes into running a taste test, how peoeple react and to get some measurable results.

»
Author's profile picture Alex Willmer

Excel tables, structured references and OpenOffice

In Microsoft Excel and OpenOffice Calc one can name a range of cells and refer to the name in a formula. So rather than writing =SUM(C2:C7) one can write =SUM(SaleAmt). Excel calls this a “Defined Name”. In Excel 2007 one can also create a “table”, which is a region of cells that store records and fields in the rows and columns. The first row of a table is used by excel to name the fields (columns). Once a table is named Excel calls this a “table name”. In Excel a table allows one to write formulas with a syntax called a “structured reference”. To sum the values in the SaleAmt field of the DeptSales table one would write the formula as =SUM(DeptSales[SaleAmt]). If new columns or rows are added to the table Excel should automatically track this and recalculate the formula appropriately. OpenOffice Calc does not support these, they are a proprietary feature of Excel. So please don’t use named tables or structured references if you will be interoperating with people who aren’t fellow MS Office users, or if you will be publishing your Spreadsheet to the public. If you have already used structure references, and you are running Excel 2010 you can save your Spreadsheet in OpenDocument Format (.ods) and all structured references should be converted to explicit cell ranges. If you open an Excel Office OpenXML (.xlsx) spreadsheet in OpenOffice Calc, and it contains structured references then it is likely you will see Err:508 and Err:509 in the cells. To my knowledge there is no way to fix this in Calc, you should ask whoever created the spreadsheet to send you a copy in OpenDocument (.ods) format. Attached for reference are two example spreadsheets.

»
Author's profile picture Alex Willmer

I Want My New EV (with apologies to Dire Straits)

I’ve hit a wall with this, so please take it and do with it as you will.

»
Author's profile picture Alex Willmer

MPGe of an electric car, revisited

Last year in MPGe of an electric car I attempted to compare the carbon emissions of the BMW Mini-E, and my own Ford Sport Ka. The result was 212 g/km (30 MPGe) for the Mini-E charged from coal, and 172 g/km for my Sport Ka (37 MPGe). In retrospect, the comparison was far too rough to draw conclusions from. This post is an attempt to correct that. This morning the Today Programme on Radio 4 covered the news that the Nissan Leaf electric car is to be built in Sunderland. In a piece Evan Davis asked the BBC Business Reporter whether the electric car would really reduce carbon emissions. Here is a partial transcript:

»
Author's profile picture Alex Willmer

Hacker Culture and geek groups in Birmingham, West Midlands

Birmingham has a vibrant community of geek/enthusiast groups, of which I’m proud to be a part. That said, it’s sometimes hard to find or even know about all of them, without the right. So collected here are the groups I know of:

»
Author's profile picture Alex Willmer

MPGe of an electric car

Does an electric car gets better or worse mileage than a conventional petrol or diesel car? To a large extent, it depends on what we choose to include or exclude in the calculation. We can measure the whole chain, accounting for every step in the process of extraction, refinement, transportation and use - a well to wheel model. Or more easily, and less accurately, we can account only for burning the fuel - a tank to wheel model. A tank to wheel module is what I shall use here to compare 2 cars (one petrol and one electric) on:

»
Author's profile picture Alex Willmer

Electric vehicle forums and websites

There are quite a few forums on the net for electric bikes, scooters, motorcycles and cars. Mostly they cover early adopter issues, tinkering, advocacy and DIY conversions. Here are the ones I’ve been drawn to:

»
Author's profile picture Alex Willmer

A new twist on spam?

These two messages appeared on the Spatialite mailing list today:

»
Author's profile picture Alex Willmer

Electric scooter

Petrol is fantastic stuff. It’s driven modern society, to the point of defining it: dirty, but very effective. Petrol has been so popular because of it’s convenience - as a liquid it’s easy to handle; and the fantastic amount of energy it holds - about 10 kilowatt hours in each litre. That’s an amazing amount of energy, in a very small space If the chemical energy in petrol could be be turned directly into electricity:

»
Author's profile picture Alex Willmer

Some LocalView Intranet performance tips

LocalView Intranet is a web mapping product developed and sold by ESRI UK, predominantly to local councils. The current version (as of August 2009) is 2.1 SP2, supported on ArcGIS Server 9.2 SP5. The following are some straight forward tips for improving it’s performance:

»
Author's profile picture Alex Willmer

Back on the air

Apologies if your email to me has bounced these last few days. My domain was due for renewal, and neither I nor my calendar went bing. Everything should be back now, if you’ve sent me something and I haven’t reacted or replied please resend it.

»
Author's profile picture Alex Willmer

Make a Windows installer for your python module

To help you build and distribute your Python packges, Python provides distutils. This library knows how to bring together your modules, where to put scripts and how to compile C extensions. The process is driven by a setup.py file, written by the package author or maintainer. Depending on what argument is passed, setup.py can install the package, build an archive or build an installer. To create a Windows installer for a module called wibble.py proceeed as follows. Create a setup.py file in the same directory as your existing module(s), describing what is to be installed:

»
Author's profile picture Alex Willmer

EuroPython 2009 open for registration

If you’ve enjoyed PyCon UK the last 2 years, the bad news is that it won’t be happening this year. The good news is that EuroPython 2009 is coming to sunny Birmingham instead, for 3 days from Tues 30th June to Thurs 2nd July and registration is now open. The even better news is that until 14th March it’s really cheap, like 50% off cheap making the 3 day conference only £95. As a warm up, from Sunday we have 2 days of tutorials at the bargain price of £70. To close there will be sprints from Friday 3rd July, and in case any Django coders get home sick it all coincides with the Birmingham International Jazz Festival. My talk on ArcGIS and IronPython has been approved. So I’ll see you there.

»
Author's profile picture Alex Willmer