08 March 2014

Why publish open source when you are commercial?

Why open source your commercial projects?
  • Forces you to decouple them from other internal systems.
  • Encourages thinking in terms of reusable modules, which is better for internal reuse just as much as public reuse.
  • Possibility of contributions to systems useful to your business by others.
  • Easier reuse within your organisation (the public internet is a better search and sharing system than any internal systems).
  • Reputation advantages, the best coders often like to work in open and forward-thinking companies, and having public shared code is a great sign of such an organisation.
Do it early
  • Preferably push your very first commit straight to github.
  • Do it before it has a chance to be tightly coupled to internal systems, otherwise you'll have to unpick it and it will be less decoupled from day one, and inertia might mean that in spite of the best intentions you then never publish it.
  • You'll have it in mind that every commit is public from day one, avoiding adding internal config etc and forcing you to factor it out into config which is all round a good thing.
  • Don't wait for your code to be perfect, there are compromises in all code and sharing something imperfect is better than sharing nothing.

Worried about the brand?
  • Commit under personal email addresses and push to personal github accounts. You can always setup a corporate github account later when you are feeling more confident.

Of course I'm not saying you should open source everything, for example your core product's codebase should probably not go on github if you are a product company!

--

Be brave, be open.
Props to Tom Loosemoore

10 February 2014

Bash command line editing cheat sheet

https://www.gnu.org/software/bash/manual/bashref.html#Readline-Interaction
  • ctrl-a/e start/end of line
  • alt-f/b forward/back a word
  • ctrl-w/alt-d delete to start/end of word
  • ctrl-shift-_ undo (i.e. ctrl-underscore)
  • ctrl-y paste (yank) deleted text
    • alt-y paste older deleted text instead
  • prefix with alt+digit (0-9) to do multiple, e.g. delete two words
    • start with alt-minus to go backwards

Just a few notes I threw together for my own benefit. I finally got around to learning a bit more about editing commands on the Linux shell / terminal.

03 February 2014

Converting kml to gpx with python

Today I wanted to geo-code some of my photos.

I have an SLR digital camera (no gps of course), and an android phone. I recorded a track with My Tracks from google on the phone. (Not entirely recommended but works). I then fired up digikam to run the geo-correlation and add lat-long to the exif of the files only to discover digikam doesn't know how to read kml. Fooey.

 

I looked to gpsbabel, but it apparently can't handle this style of kml file, as differentiated by the coordinates being in the following style of markup:

<gx:Track>
<when>2014-01-25T18:00:13.955Z</when>
<gx:coord>-1.885348 50.769434</gx:coord>
<when>2014-01-25T18:00:14.565Z</when>
<gx:coord>-1.885193 50.769328 53.20000076293945</gx:coord>
<when>2014-01-25T18:00:58.566Z</when>


So I wrote a python script to munge it into gpx shape:

https://gist.github.com/timabell/8791116

This can be run as follows:

./kmlToGpx.py "25-01 12-48.kml" > "25-01 12-48.kml.gpx"

And worked a treat for me.

After I'd done this I discovered my pet tool gpsprune can open the new style kml. (I forked gpsprune a while ago and added a minor feature) However I'm glad to have a command-line tool as I have hundreds of tracks I want to convert.

Incidentally the phone can automatically sync the tracks to google drive, which is kinda handy and then you can download them from the site etc.

07 January 2014

Returning to commercial ASP.NET from Ruby on Rails

Why ASP.NET again after all the noise I made about Ruby on Rails? After a brief stint with commercial Ruby on Rails development I should explain why I've decided my next gig will be an ASP.NET project. In short: currently almost all the Rails work available is in London for digital agencies and start-ups, demanding on-site full time presence, and I burned out doing 3 hours a day commuting in less than half-a-year. This is not a sustainable business plan.

The emphasis on start-ups and agencies bodes well for the commercial future of Rails as many of these projects will bloom into large systems needing continuing development. I will continue to use Rails for my own projects (such as the in-progress https://github.com/timabell/symbol-library ). But for me the market in the Reading area seems too quiet to make a business success from just Rails. The final straw was being formally offered a rare local permanent Rails job working with all my favourite open source technologies (Rails, Postgres, Linux etc) only to be handed an employment contract with less job security, rights and benefits than a contractor would have. This confirmed my growing understanding of the local market not being suitable at this time.

So my updated plan of action is to return to providing programming services to the vibrant .NET market in the local area, whilst also working on a database migration product for the same market (still in the research phase), but to keep my hand in with Ruby on Rails with personal projects.


This article is for my Linked In audience, if you want to become part of my network or learn more about my professional services send me a message or invite here: http://www.linkedin.com/in/timabell

04 December 2013

Getting rails 4 up and running with rbenv on Ubuntu 13.10

Brain dump warning!

This is a follow up to http://timwise.blogspot.co.uk/2013/05/installing-ruby-2-rails-4-on-ubuntu.html and is just a list of steps needed to get a clean install of Ubuntu up to speed with an existing site.
  • get a project (includes a .ruby-version file for rbenv, and a Gemfile for bundle)
    • git clone git@github.com:timabell/symbol-library.git
  • sudo apt-get install libssl-dev libreadline-dev
  • rbenv install x.x.x-xxxx
    • autocompletes, yay!
    • .. or better still reads from .ruby-version I think so you can just run `rbenv install` if you are in the project folder
  • gem install bundler
    • from the right directory so done for right ruby version
    • rbenv rehash
  • bundle
    • will install all the gems for the project
  • don't sudo apt-get install rbenv ~ doesn't provide sufficiently up to date ruby
  • gem install rails --version 4.0.2 --no-ri --no-rdoc ~ don't need this when you have a gem file with rails in it, bundle will do it for you
  • sudo apt-get install nodejs
    • for javascript runtime (rails server throwing an error without this)
  • bundle exec rails server
  • bundle exec rails console
    • needs readline (see above)
Other stuff I like in my install
This is mostly for my own reference but maybe it'll help someone else out.

25 May 2013

Unfinished hyperlinks - add a todo

Just a quick post;

href="#"   ==>   href="#todo"

I'd like to promote a change to the habit of using '#' as the placeholder for a the url of a new hyperlink when you don't yet know where it'll link to: instead set the href to "#todo". This follows the //todo pattern recognised for unfinished code, and means you can now search your codebase for any links you forgot to finish off.

<a href="#">new link</a>
   becomes
<a href="#todo">new link</a>

eg: new link becomes new link

It will also give clues to any sharp-eyed testers / users that they should report a bug for you as the url will change to #todo when the unfinished link is clicked. It can often be seen in the status bar too.

This has the handy side-effect of avoiding the annoying jump to the top of the page that is the default behaviour when you click on a # link that's a placeholder.


For bonus points another little trick I like is to add a click handler with an alert to make it really obvious to any early users / testers that this is not done yet, and I've found this saves a lot of questions when you genuinely haven't finished, and also guarantees a quick bug report when you should have (not that I ever forget any of course :-D)

<a href="#">new link</a>
   becomes
<a href="#todo" onclick="alert('Not Implemented');">new link</a>

eg: new link becomes new link  <= click this to see the alert

Simple and effective.

If you agree, please help spread the word. Perhaps by retweeting my tweet



P.S. This goes hand in hand with a technique of picking points during development at which there should be no todo's left in your codebase with the exception of those with references to outstanding user story / bug numbers. I suggest before marking a user story as done, and at the end of each sprint as good points to review all todos in your codebase.

Further reading:

13 May 2013

Installing ruby 2 + Rails 4 on Ubuntu 12.04 LTS

Installing Ruby 2 + Rails 4 on Ubuntu 12.04 LTS

Update Dec 2013: You may also wish to read benkwok's blog post on installing ruby and rails. I've also posted my notes from installing for an existing project which doesn't entirely replace this post but reflects my more recent learnings.

There's a few of these blog posts around, but here's mine for my own benefit (I'm sure this won't be the last time I do it!).

If you have a packaged ruby / rails / rvm / rbenv etc installed, get rid of them all, eg:

$ ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
$ sudo apt-get remove ruby

Don't use rvm; and make sure it's been literally purged from your system. It's a pain to remove as it gets into all sorts of places and even apt-get purge doesn't undo changes to the profile etc. If you want to know more about the reason for not using it then read the rbenv "why" page, it's persuasive stuff.

My recommendation from experience so far is to use rbenv to install the latest and greatest RoR (Ruby on Rails). Don't bother with the ubuntu packaged version of rbenv (from apt etc) as you'll be off the beaten track and will have to figure out the ruby-build plugin installation yourself. The local user install is painless and works well. The instructions say to make sure rvm is removed first as it's incompatible.

rbenv installation

Install rbenv into your home directory:
$ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv

Set up the environment as per the (ubuntu specific) rbenv installation instructions:

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.profile
$ echo 'eval "$(rbenv init -)"' >> ~/.profile

Unless you've done anything before, there is no ~/.profile file before hand, so the contents will then be:

$ cat ~/.profile
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Restart the login shell:

$ exec $SHELL -l

Check rbenv is now available:

$ rbenv
rbenv 0.4.0-45-g060f141
Usage: rbenv <command> [<args>]
...

Set up the ruby-build plugin (as linked in the rbenv readme)

$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

Install the necessary ssl library:

$ sudo apt-get install libssl-dev

If you don't install the openssl development libraries you get this:

BUILD FAILED
...
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?




Ruby installation

Install the latest ruby (version name obtained from release info on ruby blog), takes 5-10 mins

$ rbenv install 2.0.0-p0

Now select the installed ruby as the default for your user (ref: https://github.com/sstephenson/rbenv#choosing-the-ruby-version)

$ rbenv global 2.0.0-p0 
tim@atom:~$ ruby --version
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]


Rails installation

Now as per the Rails 4 RC1 announcement install the release candidate of Rails 4 (this was the latest at time of writing). Takes 5-10 mins.
$ gem install rails --version 4.0.0.rc1 --no-ri --no-rdoc

Tell rbenv to create the new shims and see the installed rails:
$ rbenv rehash
$ rails --version
Rails 4.0.0.rc1



All done! That wasn't so hard, it was all the blind alleys that took the time.

Now use bundler as recommended in the rbenv readme to set up an app etc.

Thanks for listening :-)

Footnote: It pains me somewhat to have to use installations outside of the Ubuntu package manager, however it seems there are some grumblings about the packaged versions of the above software. Add into this that I wish to use the latest RoR on an LTS release of Ubuntu which seeing as the Rails community don't seem to provide debs / repos etc leaves a packaged version out of the question for now. I've learned previously the hard way the destructive effect of randomly installing everything you find outside the package management system of a distro so have tread carefully when creating the above information.