Colin's Journal

Colin's Journal: A place for thoughts about politics, software, and daily life.

December 3rd, 2016

Freedom of movement and the single market

So, the Brexit referendum was a disaster with a slim majority voting to leave the EU. While leaving will significantly weaken Britain, there still remains the option of staying in the single market and retaining freedom of movement.

Why is this important? Most descriptions I’ve seen of the benefits of the single market completely focus on the benefits to businesses. While it is certainly a matter of great concern to businesses, I think there is a strong argument for individuals to be concerned about membership.

Here are my top ten reasons why the average person benefits from freedom of movement and the single market:

  1. Go on holiday anywhere in Europe, bring back anything you want to buy.
  2. Retire to your favourite place in Europe.
  3. Work in Dublin, Berlin or anywhere else in the EU for a day, a week, a month or years with no restrictions.
  4. Have the freedom to live anywhere you want in the EU.
  5. Study anywhere in the EU on the same terms as local students – often for free!
  6. Whether an eBay entrepreneur or small business sell to customers all over Europe with no barriers.
  7. Buy the best from wherever it’s made, in Europe or any of the 50+ countries with free trade agreements.
  8. Make your business a success – employ the best workers from across the continent.
  9. Keep your costs low with no import duties from Europe and beyond.
  10. Be safe selling and buying in the EU knowing that everyone is protected by common EU laws enforced by the ECJ.

June 13th, 2014

Golang

Venice

Venetian Boats

It’s been a long time since I set out to learn a new programming language. All of my development recently has been in Java (Android) and Python (Django), both of which I’ve known for years. Although Go hit version 1 in 2012, it is only in the last couple of weeks that I’ve started to pay attention to it.

The number of people talking about moving to Go from Python was a big influence to try it out. I’ve been using Python for a long time and it remains my favourite language at this point. After my first try at Go I can see the attraction to Python programmers. I started by doing a short script to load in some values from a CSV file, process them and write out to another CSV file.

This is the kind of thing that I find Python perfect for. It takes very little time to write thanks to the built in library, no effort to setup the environment as it just requires a single text file, is easy to debug thanks to the edit / run cycle being so short, and so gets you to a result really quickly. The experience with Go was somewhat similar. You do need to setup the environment for the first time, but the go run command means you can still have a short edit / run cycle. Like Python, the CSV library is built in and the resulting code is mostly free of boiler plate variable definitions, etc.

I’ve seen Go described as being 90% as expressive as Python. From my first encounters with it, that seems to hold true. There are a few tedious type casts required that Python avoids, but overall the feel is much closer to Python than to Java or C. The 10% given up buys a compiled, easy to deploy program that executes fast and can be more easily scaled than Python.

My initial experiments with goroutines and building a prototype TCP server resulted in compact code but with more type wrangling than I’d like. Having to think about when you are using values versus references (maps, slices and pointers) resulted in some subtle bugs only found in unit testing. This is probably down to too much time spent in Java and Python.

There are a lot of conveniences in writing Go. The source comments generated documentation system is trivial to use (far simpler than Javadoc) and the builtin unit testing framework is also very easy to use. The ability to have package level variables accessed from multiple files in the same package makes it very easy to build a modular set of code.

I haven’t tried any true OOO programming with Go yet. I’ve read much concern about the lack of generics and limited inheritance support. It’ll be interesting to see how much pain that causes in my code.

May 12th, 2013

Mileage in ExpenseClam

In previous releases of ExpenseClam I’ve introduced two major new features: mileage and attachments. Of the two, mileage proved to be the easier to do within the existing application structure.

When designing the mileage functionality I decided early on that I wanted to make mileage work the same way as other types of expense as closely as possible. Mileage expenses would appear in the same list of unclaimed expenses, be exported in the same spreadsheet file and be moved into claims in the same fashion.

The easiest way to do this would be to have a mileage specific screen that generated expense records using exactly the same format as normal expenses. This approach is used by a number of competitors and is very lightweight to implement.

The downside to this design is that once a mileage record has been entered it loses mileage specific fields (such as distance, mileage rate, etc).  I decided on a slightly more involved way of solving the problem: extending the expenses records to have mileage specific fields and creating a specific set of screens for creating and editing mileage records.

The code that lists expenses required only minor tweaking in order to distinguish between the two record types. The export code required additional columns in the spreadsheet output for mileage records, and code for managing expenses in claims was unchanged.

When a new or existing expense is opened ExpenseClam determines which UI is required and launches the appropriate Activity. Both sets of screens have a common super class that contains all the common logic for managing the life cycle of creating, discarding and saving expenses. Code for handling receipts is restricted to the expense handling class, while distance calculation logic is restricted to the mileage class, hopefully making maintenance easy.

If I had dropped support for Android versions earlier than Honeycomb I could probably have maintained a common activity and used separate fragments to achieve the same effect. However to support Gingerbread and earlier I have most of the Actionbar logic in the Activities, along with code for coordinating interactions between other Activities.

November 26th, 2012

Android device compatibility

It took me two days of digging around to finally figure out why ExpenseClam was not working properly on the HTC One X. The symptoms were straightforward enough: taking a picture would show a blank result, and the expense record showed a warning icon saying that the image file could not be loaded.

By adding some debug cpde, and with the help of a friend who owns the device, I was able to confirm that the camera code was creating an image file and that it was successfully saved. By signing up to testdroid.com I could get access to the logcat output of a real device on the cloud, which gave me the next breakthrough. My call to BitmapFactory.decodeFile was failing to return a bitmap, in turn caused by SkImageDecoder returning null.

Searching online sent me chasing a few red herrings, but eventually I had the idea of removing the code which sets the thumbnail size before taking the photo. Suddenly it worked, the bitmap correctly loads. So what went wrong?

The API documentation for setJpegThumbnailSize is fairly unambiguous “If applications set both width and height to 0, EXIF will not contain thumbnail.” Further to this the method getSupportedJpegThumbnailSizes states “This method will always return a list with at least two elements. Size 0,0 (no thumbnail) is always supported.” Based on this I had chosen to disable thumbnails in order to reduce image file sizes.

It turns out that only most devices support this. The HTC One X accepts setting the thumbnail size to 0, but then produces a file that the BitmapFactory cannot read. Leaving the thumbnail settings to the device defaults works.

Hopefully this post will save someone else a couple of days investigation.

August 12th, 2012

Nexus 7

It’s been a long time since my last post, with the birth of our daughter taking up all of my nonworking time. I have however purchased a Nexus 7, now being able to see how the 7″ tablet running android compares to the playbook.

I haven’t yet tried travelling with the tablet, but for use at home, it blows away the playbook for usefulness. The experience is not perfect by any stretch. The BBC are yet to provide an iPlayer app that works without flash, so you have to use workarounds to watch TV. The Economist, fantastic publication though it is, have produced a rubbish android app that doesn’t support ICS, never mind Jelly Bean.

Putting to one side these niggles, most of the important apps are there and work well. The chrome web browser provides a good experience, with rendering much faster than the playbook. Games play fluidly on the Tegra 3 powered machine, with the vibrant screen providing an almost SciFi feel in such a slim form factor.

The keyboard is good, certainly the best soft keyboard I’ve used. It is a little sluggish at times, with some key taps not registering as well as you would hope. Strangely tapping quickly seems to work better than trying for accuracy.

While the bundled Transformers movie is a terrible film, it does show off the tablet to good effect, with the movie streamed in HD, and looking very crisp on the high resolution screen. It also further justifies having an unlimited broadband package as the one film weighed in at over 5GB of streamed data. Uploading my own DVDs was fiddly from Linux, but should be straightforward from windows or Mac OS.

In conclusion, while the Nexus 7 may not be a substitute for a laptop in the way that an Asus Transformer could be, it makes a great content consumption device. If the alternative for content creation is your phone, the 7 inch screen works far better, while retaining a lot of portability that a large device sacrifices.

The killer feature for me is the weight. Holding the tablet for extended periods is as comfortable as holding a paperback book, possibly more so. The Nexus is the first device for which I reach for most online tasks, with the desktop relegated to development and photo editing.

August 3rd, 2009

Old photos

Cat sitting in the sunshine on a grave

Cat sitting in the sunshine on a grave

I usually wait a while, often months, before going through my photos to pick out the good ones.  This has a number of disadvantages, particularly when it comes to remembering the names of places, but it does allow me to forget which photos I thought would be good at the time I took them.  This is particularly useful as I otherwise have a tendency to not really look at the photos critically, but rather to skim through them looking for the one that I thought would work.

I’ve started working through 2008’s collection now, and having made it to September I’ve rediscovered a number of nice shots.  The one attached to this post to my eye works really well, but at the time I was discounting it (and a few others like it) as not being ideal because I could not find a way to get the cat to look at the camera.  Now that I can see the results I’m glad that the picture has turned out this way.  It feels a much more natural shot than it would otherwise be.

There are still another 760 or so photos to go through before I’ve cleared the backlog.  I really do need to catch up as I’ve already skipped ahead a number of occasions, making it easy to forget which photos I’ve been through and which still need sorting.  I could start marking them to keep track I suppose, but then I’d have greater excuse to postpone going through them properly.

About a year ago my small camera bag developed a broken zip, which has resulted in me having to use my backpack for carrying the camera around.  This made carrying the camera a serious commitment, which resulted in fewer photos being taken.  For my birthday I’ve been given a new small camera bag, so I now need to get back into the habit of carrying my camera with me again.

July 31st, 2009

Owlfish on the move

Small green lizard

Resident green lizard at Kew.

The owlfish.com domain has moved hosts.  Up until now the site has run on a shared hosting service.  After 9 years like this it’s finally grown up and moved to a virtual server, hosted by slicehost.  The slice is actually the one that runs Splash of Wine, but as this is very lightly used it makes sense to host Owlfish on the same virtual machine.

One of the main motivators for doing this was to upgrade my weblog software.  I’ve been running this site on PubTal for a long time now, and while it’s easy to use, it does mean certain features are not available.  In particular I wanted to add comment facilities to my weblog, something that’s impossible to do with static HTML file generation.  I’m still using PubTal for the rest of the site, but the weblog has been migrated into WordPress.

The DNS change is still propagating through the system, so for the new next few hours there will be periodic glitches and possibly delayed email.  Looking at the initial set of logs the transition seems to have worked smoothly with no broken links – if something isn’t working please let me know.

March 2nd, 2009

First Post!

Purple Orchids at Kew GardensThe first post of the year, and so far it’s been a busy one. January and February charged past in a blur of social engagements and work. Progress on the house has been halting, but I’ve finally started the redecoration of my study. We’ve picked out the wood burning stove that we want, and have got one quote it and the associated work. The plan is to get another quote and then get the work lined up.

Stoves are still in great demand it would seem. Not just are show rooms still busy, despite the economic gloom, but they are often back-ordered for months. We had always expected to have the work completed only in time for next autumn, so it’s not too much of an inconvenience.

Last weekend we had a trip to Kew Gardens, my first time there. It’s a fabulous place for photography, even this early in the year (although none of my outdoor photos made the cut for the new album).

I’ll be shuttling between Manchester and London for the rest of the month by the looks of things, which will only serve to delay any future posts even further! As an aside for any Wii owners who read this – have a look for the World of Goo on Wiiware, it comes highly recommended.

December 27th, 2008

The authority of Wikipedia

The relationship between the European Commission and the member states can be a fraught one. Having agreed (usually jointly with the European Parliament) a course of action, it’s not uncommon for the member states to find that actual implementation of such agreements is difficult. This is a common situation with international agreements (see Canada’s ratification of the Kyoto Protocol), but with the EU there’s a built in mechanism to deal with it. The European Commission, among it’s many other duties, can take a member state to court (“infringement proceedings”) and force it to change national law to be compatible with European law. The European courts have pre-eminence over national courts, so individuals as well as the commission can achieve redress (although it’s a long job – multiple years for resolution).

Statue in the grounds of Hambleton Hall, Rutland WaterIt’s within this context that the report on the implementation of the Free movement of Persons and Residence: Directive 2004/38/EC needs to be read. The directive itself is mostly a clean up exercise, consolidating the existing fundamental right of freedom of movement for EU citizens and some of the more tricky questions that this right raises (when can an EU citizen be deported? can family members that are non-EU citizen’s travel without a visa?) The report on the implementation of the directive paints a fairly poor picture in terms of implementation.

The tactics adopted by the EC in “steps to be taken” reveal an approach I’ve not seen before. As expected the threat of further action against member states is particularly strongly worded: The Commission will step up its efforts to ensure that the Directive is correctly transposed and implemented across the EU. In order to achieve this result, the Commission will use fully its powers under the Treaty and launch infringement proceedings when necessary. However, the next step that particularly caught my eye is the use of Wikipedia to directly communicate out the right of freedom of movement:

Member States and the European Parliament are not the only stakeholders with whom the Commission must work intensively. EU citizens must continue to be informed about their rights under the Directive. To this end, the Commission will continue to treat provision of information on the Directive as a priority and will continue to distribute a simplified guide for EU citizens, making the best use of the Internet, mainly through Your Europe portal, the creation of an article on Wikipedia on the right of free movement and simple “factsheets” explaining citizens’ rights.

A search for “Europe freedom of movement” in Google brings up an official Europa site as the second hit, with Wikipedia’s entry 7th in the list. The commission’s decision to create an article in Wikipedia is therefore not simply a matter of addressing the usually poor web presence of the EU’s official bodies. Indeed the information available on the Europa site regarding freedom of movement is easier to read, and summarises the situation far better, than the multiple Wikipedia articles that touch on the subject.

I think this decision to communicate to Europe’s citizens through a US based charity is a reflection of the perceived accessibility of Wikipedia as a source of information. Even though the content is likely to be very similar, an article on Wikipedia penned by the European Commission is deemed to be more accessible than the same material hosted on Europa.


The picture was taken at Hambleton Hall in Rutland.

April 20th, 2008

Wii thoughts

Cave on the Cornish coast near TintagelI’ve recently tried out the BBC iPlayer on our Wii. Overall it’s pretty promising, but not quite there yet. The main good point is the most obvious: being able to watch TV on a TV screen from a comfortable chair at a good distance.

The are, however, several downsides. The quality of the codec (Flash 7 at 820Kbit/s rather an Flash 8 at 500Kbit/s) is definitely not as good as under Linux. The lack of full screen support is also annoying, but the top complaint is reserved for the screen saver on the Wii kicking in every 10 mins or so.

A better solution will hopefully come in the form of a dedicated Wii channel, rather than simply supporting play back through the Opera web browser (known as the Internet Channel). The BBC developed free codec Dirac looks like a great candidate for such a deployment (especially following on from the announcement of a fast implementation hitting a 1.0 version). Hopefully the Wii’s processor and graphics are going to be enough to host a good implementation of this (or some other codec) in the future.

In other Wii related news I’ve recently received Zak & Wiki. So far I’ve only made it through the first stage, but things are starting to get interesting. The first few levels were really about introducing the controls (which are simple), but the puzzles later on get more interesting and varied. Having multiple ways of completing a level is also a refreshing feature in a puzzle game.


The picture was taken at Tintagel as the tide came in, thankfully we didn’t stay around long enough to be trapped!

Copyright 2015 Colin Stewart

Email: colin at owlfish.com