Sunday, 4 May 2008

Upgraded to Hardy


Well I've taken the plunge and upgraded my laptop to the 8.04 Ubuntu release (Hardy Heron). Overall the process was very smooth. There are some minor irritations with the way the wireless network works. (To do with the move from the binary ipw3945 driver to the open ipl3945 driver) and a trivial problem with my ML-1610 printer that simply required reselection of the driver to update the appropriate PPD. Other than that I'm here on Firefox 3, printing happily and transmitting over a secure wireless connection and generally enjoying life.

The main reason for upgrading was so I can show presentations on an external screen, and so I can use submodules in git (both in Hardy, but not Gutsy). We'll see if any more irritations pop up over the next few days. However so far, so good.

Sunday, 20 April 2008

Dilbert - probably the worst site redesign of all time.

If you've been to the Dilbert site (http://dilbert.com) recently you'll notice that they have redesigned it so that it has new features. Unfortunately while getting excited about all the new website toys they have completely forgotten about usability.


Faux pas include
  • having to scroll the Sunday strip (can you spot the arrow?)
  • Forcing the Sunday 8 box strip into 3 box format.
  • No way of easily getting to the previous or next strip without going through search.
  • Completely pointless flash tool
  • Even more pointless flash menu
  • Chewing the CPU
  • Crashes frequently on Ubuntu and IE 6 if you flip screens
  • Busy, busy screen.

It works so much better if you turn Javascript off.

Fortunately there is a workaround. Just look at the strips on Yahoo instead http://news.yahoo.com/comics/dilbert

Oh and make a note never to hire the guys at vpi.net if you want a site that people can use on anything less than the latest Redmond specified supercomputer.


Friday, 11 April 2008

Rake quick tip - Getting your dates out into the right format

Rails date formatting leaves a bit to be desired with only a few formats available. You can of course use strftime in all it's glory:
my_record.created_at.strftime("%d-%b-%y")

but it is hardly descriptive.

So there are a couple of ways of getting dates to format as you want them in Rails. The first is to set your own key in the date format table, and select it explicitly.
Time::DATE_FORMATS[:uk] = "%d-%b-%y"
my_record.created_at.to_s(:uk)

But if you want this date format all the time, just overwrite the :default key. Then to_s will use your format by default.
Time::DATE_FORMATS[:default] = "%d-%b-%y"
my_record.created_at.to_s

I stick the command in the ApplicationHelper. It's always a global change.

Thursday, 10 April 2008

Rails and git - clean branch and merge



I've moved over to git recently to take advantage of the new distributed functionality and the various git repository engines that are springing up in the Rails world.

One of the beauties of the new git regime is that creating and deleting test branches of your application is an absolute doddle. For every iteration you simply






neil@neil-laptop:~/test_git$ git checkout -b new_branch
Switched to a new branch "new_branch"
neil@neil-laptop:~/test_git$ *change something*
neil@neil-laptop:~/test_git$ git commit -a -m "let's try this"
Created commit cb3200f: let's try this
1 files changed, 0 insertions(+), 59 deletions(-)
neil@neil-laptop:~/test_git$ *add something else*
neil@neil-laptop:~/test_git$ git add .; git commit -a -m "That didn't work,
let's try something else"
Created commit 0c5f35e: That didn't work, let's try something else
1 files changed, 144 insertions(+), 0 deletions(-)
create mode 100644 FOOBAR
neil@neil-laptop:~/test_git$ *change something again*
neil@neil-laptop:~/test_git$ git commit -a -m "Now we've cracked it"
Created commit 3876936: Now we've cracked it
1 files changed, 0 insertions(+), 144 deletions(-)
delete mode 100644 FOOBAR
neil@neil-laptop:~/test_git$


Which gives you a nice branch with your shiny new functionality in it, but all the hacks and changes are in the log file.


neil@neil-laptop:~/test_git$ git-log --pretty=oneline master..HEAD
3876936d77f6963a5db461fbc013059c84a5e480 Now we've cracked it
0c5f35e7a0386698e57eab0791f5897cb44a0266 That didn't work, let's try something e
cb3200fd16de9bf4a14cbdba1a8abcfa0fcfeb71 let's try this


And that means when you merge down all those log entries get merged as well


neil@neil-laptop:~/test_git$ git checkout try_merge
Switched to branch "try_merge"
neil@neil-laptop:~/test_git$ git merge new_branch
Updating 1b63b7d..3876936

Fast forward
FRED | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
README | 59 --------------------------
2 files changed, 144 insertions(+), 59 deletions(-)
create mode 100644 FRED
neil@neil-laptop:~/test_git$ git branch -d new_branch
Deleted branch new_branch.
neil@neil-laptop:~/test_git$ git-log --pretty=oneline master..HEAD
3876936d77f6963a5db461fbc013059c84a5e480 Now we've cracked it
0c5f35e7a0386698e57eab0791f5897cb44a0266 That didn't work, let's try something
6182c9866e6f4972eb74e873f5d9eff1dd0a272d That didn't work try something else
cb3200fd16de9bf4a14cbdba1a8abcfa0fcfeb71 let's try this


Now recording your twists and turns for posterity probably isn't what you'd want to do. Fortunately there is an alternative. Let's do that again.


neil@neil-laptop:~/test_git$ git checkout try_merge
Switched to branch "try_merge"
neil@neil-laptop:~/test_git$ git-merge --squash new_branch
Updating 1b63b7d..766208c

Fast forward
Squash commit -- not updating HEAD
README | 31 -------------------------------
1 files changed, 0 insertions(+), 31 deletions(-)
neil@neil-laptop:~/test_git$ git commit -a -m 'Shiny new functionality as if by magic'
Created commit 2940a71: Shiny new functionality as if by magic
1 files changed, 0 insertions(+), 31 deletions(-)
neil@neil-laptop:~/test_git$ git-log --pretty=oneline master..
2940a71686d0c618bf39c17d3dd12c8ee02248d7 Shiny new functionality as if by magic
neil@neil-laptop:~/test_git$


Now all the twists and turns of your test branch are banished from history and you can pretend you created the perfect solution first time :-)

The one wrinkle is that you have to force delete the test branch. If you do a normal delete it complains

neil@neil-laptop:~/test_git$ git branch -d new_branch
error: The branch 'new_branch' is not a strict subset of your current HEAD.
If you are sure you want to delete it, run 'git branch -D new_branch'.

However if you take the advice all is well

neil@neil-laptop:~/test_git$ git branch -D new_branch
Deleted branch new_branch.

Git makes it really simple to launch a branch for every iteration you undertake and allows you to keep your mainline commit sequence clean.

Monday, 31 March 2008

Rails Patch accepted!

I came across a Rails problem last week while writing the VAT validation plugin. So based on the open source principle of 'he who finds fixes' I submitted a patch, and it has been accepted!

It's nice to be part of the process.

Saturday, 29 March 2008

Why IT is perennially irritating - and what we can do about it

The levee of early adoption has been breached and the sea of banality is flooding in. It has been for a while, but now some of the pioneers are starting to notice a bit of a smell.

Is it that Web 2.0 has matured like a fine, but overly strong, stilton and is ready to take its place next to dotcom, client-server, outsourcing, windows, PC terminals, 4GLs and probably several others I've forgotten in the pantheon of IT panaceas.

I'm not sure whether I'm fortunate or unfortunate to have seen this process happen several times. Certainly it is very disheartening to see it happen all over again. But that is the way the economics of this business works - as it does for all service businesses. And that's due to a number of factors as I see it
  • The customer and the consumer are very often, if not always, different people. You are writing the software for the person who wants 'Ebay with knobs on' and only superficially for the person who is going to use it. The marketing fluff builds to get the customer to sign. Delivery becomes a matter of doing the minimum possible to get the customer to sign the thing off and pay.

  • Nobody knows if you are any good or not. So customers don't go for the best solution, they go for the one with the least perceived risk. You reduce perceived risk by fluffing up your marketing - hire more PhDs to sit in a corner and twiddle their thumbs, up the impressive graphics, work on your brand, give lots of slick superficial presentations and bridge away from the difficult questions to "The Big Picture (tm)". To pay for this you cut corners at the back-end where nobody will look. After all you will have sold out before the first power cut won't you.

  • Your 'tool' is not as good as you think it is and frankly nobody but you gives a monkeys about it. Why are you so sure it can't be replicated by a keen script-kiddy in a couple of weekends? And if it can, why do you think you have a sustainable business charging £10 per month for the privilege? Fancy graphics? Force of ego?

  • Most of the 'tools' out there are largely superficial. I got into this game to make people's lives easier by automating and eliminating drudgery. Yet the tools created seem to turn people either into Mrs Doyle ("some of us like drudgery"), or human versions of Pavlov's dogs - desperately waiting for the next IM or twitter to give meaning to their existence.

Andy Mitchell makes the points well in his blog post

However the most insidious problem IMHO is The Flip - the standard way of investment and detailed in exquisite form here. Capitalism is driven by those who own the capital, and the bottom line is if you have an external investor then you work for them and they are looking for a profit on the sale of your business - quickly. To quote "The business must be able to generate significant value within 2 years to provide an exit for investor."

There is no doubt it works, and as a side effect it actually does occasionally create something wonderful, but it is ultimately not fulfilling for those looking for a deeper meaning from what they do. As 37Signals point out - rightly in my view: "The sad fact is cashing in often begins to trump building a quality product."

So what can we do about it?

  • Get away from the focus on the product. In a modern development world products are easily replicable. Any product is merely an enabler for creating a service - a set of people and connections - and it is these people and connections that have the value, not the product. Concentrate on the people and their philosophy not the product.

  • Try to automate the process. One of the disturbing trends I see is humans used as the ultimate flexible middleware between niche point web applications. Find a way of getting the machines to do the hard work.

  • Start charging for what you are actually selling. Why do we sell the products with free support? The product has an incremental cost of zero, and the support involves expensive people. So charge for the support and give the product away for free. That way you can move to 'branded' individuals or branded small teams of individuals and they can charge more. Any decent architect could have designed The Gherkin, so why did they pay for Norman Foster?

  • Merge your customer and consumer. Try and make sure the person laying out the cash (or at least making the buying decision) is the one using your services. Concentrate on those markets where this applies.

  • Build your FY fund. It worked for Humphrey Bogart, it can work for you. If you have to earn something today then you are not in control of your destiny. You have no capital in a capitalist society and once again those that own it will be telling you what you can and can't do - whether you are employed, freelance or whatever. So if you're in an area where there is a rich seam of cash to be mined, then grit your teeth and mine it. Then put it to one side. The world will wait until you are ready.

  • Get good with money. It's always amazed me the number of people who are quite happy to do several hours overtime, but won't spend fifteen minutes to change their utility suppliers to a vastly cheaper offering. If you are building a capital sum so you can control your destiny then obviously it builds faster if it doesn't leak. Go learn how to plug your leaks. You probably don't have to go as far as I did (by training in accountancy) and I admit I have a genetic advantage when it comes to cost efficiency :-), but if you remember one thing, remember this: £15 saved is as much as £25 earned when you account for tax. (£33 if you access tax credits - seriously!).

  • Be the Investor. He who pays the piper calls the tune - always.

Getting round The Flip is a harder problem to solve. There has to be a model of operation that gets away from the short-termism inherent in The Flip with its obsession about capital value. There has to be some way of getting back to concentrating on income, cash flow and customers and making equity patient again. Thoughts:

  • Founders as partners, where partner is more an ownership mindset than a legal structure. In all other professional fields partnership is the primary model, where capital value is owned directly by the individual. Few in IT understand the partnership approach and the way capital value accrues in such a structure. Often what you find in IT is a pseudo partnership approach sat under a Limited Company.

  • Build one to throw away. Where you get involved in a capital project and use the proceeds of that to do what you really want to do - an income project. Ubuntu falls into this category.

  • Internal project. Where you build your product alongside your standard agency work and gradually convert over to an income business. 37Signals worked this way. I'm just not convinced that the 'tenner a month' software leasing model is sustainable in the medium term.

The one I like most at the moment is the Free Software network idea, where you get over the idea that you must hide the product from the world if you are to profit from it. Make it easy for those who are good at the partnering and branding thing to do their stuff in whatever niche they fancy. Sell the setup and the backup preferably on a branded individual basis; put development down as a marketing cost. White-Box Web 2 if you like.

It may be that the Flip and the OTT marketing it generates is the only way that works in IT. In which case you've just got to put up with it, or get out. Unfortunately it is not any better anywhere else, so I rather hope that something will drop out of this debate.

Let me know what you think.

Thursday, 27 March 2008

Checking for Active EU Vat Numbers in Rails with SOAP and REST

Rather than implementing checksums and the like for VAT numbers I've decided to go straight to the Internet database and check the number there. It is exposed as a soap service and the ActiveRecord code looks like this:

  #Use the SOAP checker on the Internet to see if the VAT number is live
#The driver is created on first use and cached
def active?
if valid?
@@vat_check_driver ||= create_vat_check_driver
result = @@vat_check_driver.checkVat(
:countryCode => country_code,
:vatNumber => identifier
)
end
result && result.valid == "true"
end

private

require "soap/wsdlDriver"
def create_vat_check_driver
wsdl = "http://ec.europa.eu/taxation_customs/vies/api/checkVatPort?wsdl"
SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
end


'countrycode' and 'identifier' are the names of the ActiveRecord attributes containing respectively the 2 character ISO country code and the Vat number.

For a bit of mild amusement I translated this into a REST based collection sat on http://3accounts.co.uk/active_eu_vat_numbers so that you can get them using ActiveResource.

class ActiveEuVatNumber < ActiveResource::Base
self.site = "http://3accounts.co.uk"
end

ActiveEuVatNumber.find("gb123456789")


You'll get an ActiveResource exception if the record doesn't exist.