Archive for Programming

Brighton Python Hack Day – 11 Feb 2012

On Saturday 11th Feb 2012, Nathan Humphreys and myself ran a Python Hack Day for a few people at my flat in Brighton.  This was the first hack day that any of us had run or attended so we didn’t know what to expect.  But we learnt lots of things along the way.

To be fair, the hack day was Nathan’s idea originally but I was immediately interested to help and organise it.  We have plans to run a larger hack day in the future, so we decided to start small and hold one in my flat.  We chose Python as a language to use since plenty of people we knew had a basic knowledge in it – plus Nathan and I have been using it side projects for a while now.

Before the day

So the first thing to do was to invite people.  We decided to just keep it to people we currently work with.  My first surprise was the number of people who initially said they were interested, but then pulled out because they weren’t sure they could write any Python code.  Seriously?  Professional software engineers should be able to pick up new languages – and IMHO be excited to do so.  The whole point of a hack day is to learn something new – and being around smart and fun people is surely the best way to do it.

In the end we had 5 people (including ourselves).

The other thing to sort before the day,  was to come up with some potential projects to work on.  There was generally a lack of ideas around, most people just wanted to come along and code something.

Start of the day

So we are good to go, 10am on a Saturday, most people have arrived and there is kitchen full of snacks.  First item is to decide what to work on. No one was really that bothered so we decided on a project that had the most scope – creating a photomosiac web app.  We decide that we would develop this on Google App Engine and split into two teams – one for the web front end and the other for the image processing backend.

The first thing we ended up doing was setup the development environments.  We must have spent the first 2 hours getting python, git, Python Imaging and the App Engine SDK working correctly on all our machines.

Once we started coding everything went smoothly, with plenty of code being written and pushed to our github repo. I had never used git before in a team environment before – only for my own projects where I have 1 developer and 2 branches. I was amazed at how easy it is to merge files and push your changes across the network to someone else.

Afternoon

Following our lunch of Pizza, we made good progress and was ready to start integrating and testing the algorithm in late afternoon.  Then it was time for intense pair debugging to get this working.  After discovering a few oddities with GAE Image functions, we finally got something basic working by 7pm and continued tweaking it further until 9.

Lessons Learnt

After the first hack day, I learnt quite a few things:

  • A 9 hour day is actually quite short, so maximise the available time.  Next time, we will try and select an idea to work on using email, create a skeleton project and ensure everyone can compile and run the project.  And all this before they arrive on the day.
  • Git and github rocks
  • Even in a single day, 5 people can create code that becomes difficult to debug and test.

What’s Next

Nathan and I have plans for more hack days as they are brilliant fun.  Next up we are going to attend some else’s hackathon – Mark Pearson’s Hackathon London on 23-25th March 2012.

Then our other ideas are perhaps an Android one and, if can get hold of the hardware, Raspberry Pi.

My upgraded development workspace

It was time to upgrade the workspace at home where I do my software development.  It was getting uncomfortable to sit there for many hours at a time and that’s not what you need when trying to code.  So I went off to IKEA.  Here’s my old desk setup – a bog standard dining table with a cheap chair from Rymans.

Chair

As a tall person (6ft 3) I’ve always suffered with chairs and desks being the wrong height for me and suffering neck ache.  So first item up is a new chair that has a high seat and a head rest.  Where I used to work I had an amazing RH Logic 4 chair, but not having a spare £900, I opted for the £125 IKEA MARKUS.  It’s a very comfortable chair with plenty of back support and it reclines too.

Desk

Then to solve the next height related issue of mine: the desk.  So I added four IKEA VIKA KAJ legs that are adjustable between 60-90 cm.  I set them to 80cm which works well for me.  And while I was there I added a IKEA SIGNUM cable tidy to clear up the mess of cables behind the desk.

Monitors

My final update is to my dual monitor setup – a Dell 23″ and a Samsung 20″.  Again, getting the monitors to the correct height is important, and the cheapest option I found before was to use two Ergotron Neo-Flex LCD Stands. But these don’t go very high and they struggle with the weight of the 23″ monitor.  So I ordered an Allcam MDM05 Multi Screen Desk Mount Bracket from Amazon.  Was very impressed with the next day delivery and the couriers (DPD) texted me in the morning to give me an hour slot when the delivery would occur.

The screen mount was very easy to assemble but you have to tighten up all the bolts which makes it difficult to tilt and move the monitors.  This is fine for me as I want them fixed in position.

So here is my dual monitor setup on the stand.  It looks good and leaves the area under them clear.

Complete

So here is the final view with chair, desk and monitors.

What’s Next

I’m not done yet, but this is the first pass.  Having now raised the desk, it is a little unstable and does wobble when I’m typing.  So I need to get a more solid table top – probably an IKEA VIKA AMON.  I might also get some IKEA DIODER lights that change colour to light up behind the monitors.

And then it’s to computer hardware upgrades – a wireless keyboard & mouse and a new laptop.

Undefined subroutine &Scalar::Util::weaken

Ever had the problem in Perl:

Undefined subroutine &Scalar::Util::weaken called at

This is caused by a version of Scalar::Util that is perl only and doesn’t implement the weaken function (ref).  To install the XS version of Scalar::Util use cpan and run:

force install Scalar::Util

Perl “Perl_Gthr_key_ptr” problems

I just upgraded by laptop to Fedora 16 and started to get problems with Perl libraries that were installed via yum.  Errors along the lines of:

perl: symbol lookup error: /usr/local/lib64/perl5/auto/Crypt/Rijndael/Rijndael.so: undefined symbol: Perl_Gthr_key_ptr

Some research suggest this is caused by the shared library being built against a different version of perl.  This is mainly a problem because Fedora provides a number of prebuild perl libraries through yum.  The fix for this is to use cpan to rebuild the libraries. So as root start cpan:

cpan

Then reinstall the libraries causing problems.  In the above example I did:

force install Crypt::Rijndael

This will recreate the .so file against the correct perl version.

CPAN error with vxs.so

There may be problems with cpan failing due to:

perl: symbol lookup error: /usr/local/lib64/perl5/auto/version/vxs/vxs.so: undefined symbol: PerlGthrkey_ptr

I managed to fix this by just deleting the whole folder:

 /usr/local/lib64/perl5/auto/version/

Apache and selinux

If you are calling perl scripts from apache there might be further problems like:

failed to map segment from shared object: Permission denied at /usr/lib64/perl5/DynaLoader.pm

This is an SE linux issue and can be fixed with chcon:

find /usr/local/lib64/perl5/auto -name “*.so” | xargs -n 1 chcon unconfined_u:object_r:lib_t:s0