Toblog

1. v. The act of writing a weblog or 2. n. Toby’s weblog.

Defining the English

I’ve just finished reading the excellent Lives of the Engineers by Samuel Smiles. It is well worth a read and is available for free on many ereaders as well as Project Gutenberg. This quote from Chapter XII in particular stood out as a wonderful definition of the English as a people:

The English people, though they may be defective in their capacity for organization, are strong in individualism; and not improbably their admirable qualities in the latter respect detract from their efficiency in the former. Thus, in all times, their greatest enterprises have not been planned by officialism and carried out upon any regular system, but have sprung, like their constitution, their laws, and their entire industrial arrangements, from the force of circumstances and the individual energies of the people.

Published on 2011/03/25 at 12:41 by Toby under . Tags , ,

Nuclear Scaremongering

Does anyone else think that this is disgusting?

At 1501 today:

The EU’s energy chief Guenther Oettinger has said that in the coming hours “there could be further catastrophic events, which could pose a threat to the lives of people on the island”. He told the European Parliament the Fukushima nuclear site was “effectively out of control”. “The cooling systems did not work, and as a result we are somewhere between a disaster and a major disaster.”

This quote caused a large movement on the markets as the ‘effectively out of control’ was rebroadcast by multiple media sources without any context about what he was talking about.

At 1645 today:

A spokeswoman for EU Energy Commissioner Guenther Oettinger has clarified his earlier remarks that “further catastrophic events” were expected. “He just wanted to share his concern and that he was really touched by all the images of people and the victims,” said Marlene Holzner. “In this sense, he said that according to we have seen in the media, it seems that in the nuclear power plants at the moment we do not have technical control.”

So, basically it was rubbish.

UPDATE 2011-03-17: Tim Worstall has commented on this as well.

Published on 2011/03/16 at 17:58 by Toby under . Tags , , , , ,

Pour manger à Paris

A friend of mine is visiting Paris over the New Year and I mentioned a few restaurants that I enjoy going to there. Since then she has asked if I wouldn’t mind if she passed on the list so I thought I’d put it up here!

Café Latéral – it’s very near the Arc de Triomphe but most tourists don’t go down Avenue Mac-Mahon so it’s only French people there and as such the food is really good. It is both a traditional french bar / brasserie but there is a slightly less hectic restaurant in a small room in the back if you prefer something slighly more spacious / quiet :)
4, Avenue Mac-Mahon 75 017 PARIS. Tel: +33 1 43 80 20 96

Le Louchébem – Louchébem is french Butchers’ slang for Butcher. If you really want to eat good meat then this is a great place to go. They serve loads of different cuts from lots of different animals. You may have to book; it was very busy when we went.
Corner of 10, rue des Prouvaires and 31, rue Berger 75001 PARIS. Tel: +33 1 42 33 12 99

La Rotonde Bastille for a funky modern bar serving good snacky food near Bastille. Bastille can be a bit overwhelming and this bar with friendly staff and a chilled out atmosphere (there’s cool art on the walls and funky music in the background) is a good spot to get away from the madness!
No website, but here’s the google info page on it. 17 Rue Roquette, 75011 Paris +33 1 47 00 68 93

Café Grand Corona: it’s a good stopping point if you’re walking towards the Tour Eiffel (and are following the river) and it has amazing hot chocolate – they give you a jug of melted chocolate and a jug of milk. It’s up to you how you mix it!
No website, but here’s the google page on it. 3 Place Alma, 75008 Paris. Tel: +33 1 47 20 70 27

Chez Yanick* for Crêpes. You’re unlikely to see a non-French person here and it’s always packed full of Parisiennes. Make sure (if you like bacon) you have one with Lardons on. Mmmmmm.
No website, but here’s the google page on it. 33 Rue Annonciation, 75016 Paris. Tel: +33 1 46 47 70 34.

Brasserie Bofinger for a good upmarket french dining experience. The food is excellent, the dress code is relatively formal (the waiters are all in black tie) and most people there are french. Booking essential.
3 Rue Bastille, 75004, Paris. Tel: +33 1 42 72 87 82.

Update 2014-05-29 I’ve heard that Chez Yanick has closed.

Pure ruby version of MurmurHash 2.0

I needed a 32bit hash generation function and there appeared to be no such obvious hash in ruby. With a bit of help I found murmurhash 2.0 which appeared to fit the job. Below is the code for a pure ruby version of the endian-neutral version:

module Digest
  def self.murmur_hash2( string, seed )
    # seed _must_ be an integer, but I do try to enforce that.
    # m and r are mixing constants generated offline.
    # They are not really magic, they just happen to work well.

    raise "seed isn't an integer, and I can't convert it either." unless 
      seed.is_a?( Integer ) or seed.respond_to?( 'to_i' )

    seed = seed.to_i unless seed.is_a?( Integer )

    m = 0x5bd1e995
    r = 24
    len = string.length

    h = ( seed ^ len )

    while len >= 4
      string.scan( /..../ ) do |data|
        k = data[0]
        k |= data[1] << 8
        k |= data[2] << 16
        k |= data[3] << 24

        k = ( k * m ) % 0x100000000
        k ^= k >> r
        k = ( k * m ) % 0x100000000

        h = ( h * m ) % 0x100000000
        h ^= k

        len -= 4
      end
    end

    if len == 3 then
      h ^= string[-1] << 16
      h ^= string[-2] << 8
      h ^= string[-3]
    end
    if len == 2 then
      h ^= string[-1] << 8
      h ^= string[-2]
    end
    if len == 1 then
      h ^= string[-1]
    end

    h = ( h * m ) % 0x100000000
    h ^= h >> 13
    h = ( h * m ) % 0x100000000
    h ^= h >> 15

    return h
  end
end

To use it copy the above into a separate .rb file (say murmurhash2.rb) and:

require 'murmerhash2.rb'

string = "the string to be hashed"
seed = an integer
result = Digest::murmur_hash2( string, seed )

I note that MurmurHash 3.0 is currently in beta so I shall have a go at coding that up once it becomes stable. I also would quite like to get this into a gem but before I do if anyone has any comments on the above code please let me know!

Published on 2010/12/14 at 18:18 by Toby under . Tags , , ,

A message from the past

Whilst going through my Grandmother’s affairs after she passed away earlier this year my family found part of a letter that she wrote to her parents in November 1940. I showed it to friends with an interest in war history and they asked if they could use it in their work. I think it is a fascinating insight into the life of a remarkable woman and the conditions in London during World War II so, with the agreement of my family, I’m publishing it here so it can be cited in the future.

Wednesday

To continue this interrupted letter – I’d got, I believe, to the stage where we couldn’t get on with our work because we got taken to the pub next door for drinks. We heard a few bombs around then, but in the shelters here you can’t hear a thing — guns or planes, and everybody is very jolly and helpful. Betty and I finally finished work last night at 1.30, when we changed into slacks, and wrapped ourselves on our stretchers. The ARP man on duty knocked us up at 4.30, and after a cup of soup four of us sallied forth in a WVS car up the Holloway Road to one of the shelters holding about 1500 people. We also went to Finsbury Park tube station where they were all just beginning to pack up their mattresses etc and leave for home, although the “All Clear” hadn’t gone. These were both reputed to be of the better type of shelter, so what the others are like I don’t like to think, although some of the stories are quite unbelievable. But their cheerfulness through it all is amazing. One dear old soul of 82 was sitting on a bench recounting her bomb story to a neighbour, and enjoying every moment of it. We went down to the Corner House afterwards for a large breakfast of bacon and eggs, but those poor blighters had to go back to cold houses and start off on another day of endless work — and then back to the shelters again.

Tomorrow (the others have gone back) I’m going to see some of the communal feeding centres in N. Kensington, where the person running it wants some advice on what food to sell. Then I shall either go back to Colwyn or I may stay another night if I can get a pass for the Minister’s train. They are starting an Underground train which is to go around delivering food etc at a lot of the stations. Tomorrow evening Lord Woolton and the Lord Mayor etc are going on its first trip, and I’ve been offered a ticket. So if it comes off I shall certainly go.

London is marvellous — there’s quite a lot of damage, of course, but it’s amazing what a lot of bombs seem to have dropped in the streets, and only broken windows and scarred the fronts of the houses. The actual blitzkrieg is not nearly as bad as it sounds from the papers — I expected to be scared stiff, but I find myself as calm as blazes — most people just don’t worry a scrap and carry on, during the daytime anyway, as if nothing were happening. We go to earth soon after six, and stay there until next morning.

Monday

Sorry this never got finished, but as usual there hasn’t been much time. I went on the Minister’s train with all the press and had a great time. It was most interesting to see the people in the stations – we went by car to Notting Hill Gate, and from there by train to Bank station where everyone forgathered . The Refreshment special came along, and we went non-stop back to N.H.G. where the Lord Mayor presented the cheque to Lord Woolton (incidentally it was in the bank weeks before) and everyone had a look at the food and drink and had their photos taken. Four of us finally went back to the Strand and had drinks in one basement and supper in the Corner House brasserie. Then affairs overhead being inactive, we went to the Press Club.

The next morning the same four got up at 4.30-ish again and went down to Aldgate. The report had already come through to Neville House from the Home Office about Coventry. We first went to the shelter in Aldgate where 14,000 people shelter in a railway warehouse. This was the one about which there was so much talk at the beginning of the Blitz because it was so indescribably appalling. But we were very pleased to see that it has all been very much cleared up, and 3-tiered bunks provided, and the whole place has been lit. So then we went on down to Stepney, where Father Groser, who is the really big man down there took us all round his parish. It is all rather grim when you see the roofs of the shelters dripping damp and hundreds of people huddled in the corners trying to keep warm and dry. The buildings, many of them in ruins or gutted shells, look all very eerie in the dawning light, and the poor old people trudging home with their bundles on their backs made me wish that every member of Parliament could be sent down there to spend a night in one of those shelters, and then perhaps something would get done quickly. One feels so helpless, but I sent a pretty hot report into Drummond about the feeding question in the shelters which I hope will be effective.

After all that we betook ourselves baths in the Minister’s bathroom which is all very luxurious, and then to breakfast in the local Express Dairy. Later in the morning I called at Devonshire Place on my way to the train to find both John and Connie there, both very cheerful they had a landmine near his hospital, which wrecked the whole place, but fortunately he had just gone over the road to the Nurse’s home to see if Connie was all right. She did first aid on all the minor cuts and bruises.

The journey back here was pretty grim – 1.5 to 12.30 am – 6 hours late at Crewe owing to a trip round the country to avoid damaged lines. Fortunately I got into the Luncheon car as soon as I got to the station, because that was the last thing I got to eat before I got back here, except for a slab of chocolate shared round. Luckily I had a couple of Canadian soldiers at the same table – it was that sort of carriage, and they kept us amused and interested all the way. They are great lads, these Canadians. There’s not much chance of our losing the war while they are around. They’ve got such a refreshing outlook on life. That together with the fact that I was feeling so sleepy, didn’t make the journey seem so long. I slept the clock round on Saturday night, and felt quite recovered.

Many thanks for your letter which arrived this morning. This question of whether I should tell you whether I’m going to London is a very debatable one. You worry if you know I’m there, and you worry if you think I might be there — so what is one to do! We’ll try it’s the other way this time. I’ve got to go up again on Friday for a meeting with Drummond and a lot of Industrial Welfare people on Saturday morning. I shall stay Friday night at Neville House as before, and I’m aiming at going down to Dorking for the weekend to see Peggie, if she is at home; I’ve written but haven’t heard yet. Let me know your reactions to knowing I’ll be there!

I don’t travel by night unless absolutely essential — as it was coming back from Edinburgh, or we’d never have got the stuff ready for London. As it was, that turned out to be one of my best wartime journeys.

Who was it Mrs Comfort knows whom I have met? It intrigues me, but I’ve met so many people up here that I can’t figure it out from this end.

I’m so sorry to hear about Eric Blackwell. Have you heard anything from Coventry — let me know as soon as you do.

I’ve lost for the moment your letter with all my bills added up. So I am enclosing a round check for £11, which should cover everything plus all the little things you haven’t put down.

With very much love to you all,
Margaret

Published on 2010/09/26 at 18:34 by Toby under . Tags , , , ,

ruby net-sftp uninitialized constant

I’m currently writing some code that fetches a file from an sftp server. Using ruby 1.8.7 / net-sftp 2.0.4 the following code triggers an exception:

Net::SFTP.start( sftpHost, sftpUser, :password => sftpPass ) do |sftp|
  $stderr.puts "Downloading: #{sftpPath}#{sftpFile}"
  xml = sftp.download!( "#{sftpPath}#{sftpFile}" )
end

The exception is:

/usr/lib64/ruby/gems/1.8/gems/net-sftp-2.0.4/lib/net/sftp/session.rb:123:in `download!': uninitialized constant Net::SFTP::Session::StringIO (NameError)

The solution is to add:

require 'stringio'

to the top of the session.rb file mentioned in the exception message.

Update: 2010-08-19 16:00 I’ve just heard back from the developer having emailed him this blog entry. He is hopefully pushing a fix this evening. Now that’s service!

Update: 2010-08-20 Last night version 2.0.5 was released which has the fix in it.

Published on 2010/08/19 at 14:25 by Toby under . Tags , , ,

Ruby BigDecimal Performance

I have a query against an Oracle database that returns a decimal value for a price. Ruby’s Oracle connector returns that as a BigDecimal object.

Once I have got all the items I have to aggregate them. As part of the aggregation I run this code:

@hash[id].price = ( ( @hash[id].price * @hash[id].fill_volume ) +
                    ( item.price * item.fill_volume ) ) /
                  ( @hash[id].fill_volume + item.fill_volume )


Each time it runs this code it gets slower. After about 250 loops of this code it gets really slow. Here’s the time it takes to do the 269th loop (the times are UNIX time with microseconds):

269
1281710074.568992
1281710075.574573
270

…just over a second! This seems to happen more if the id is the same over many loops.

A very simple solution is to make the price be a Float rather than a BigDecimal. When I do that, I get the following times:

269
1281710378.886902
1281710378.886920
270

Significantly faster (and given I have 10000s of lines to parse this is a big thing) worth the potential loss of accuracy. What I’d like to know is why BigDecimal behaves like this (at least in ruby 1.8.6). Any ideas?

UPDATE 20101221: Matt Patterson has had a look into it and it looks like BigDecimal is O(n2) (or worse) as the size of the BigDecimal gets larger. It looks like I’m going to have to have a look at BigDecimal#limit and BigDecimal#round.

Published on 2010/08/13 at 15:31 by Toby under . Tags , ,

Regulate

Much as I don’t like to rely on memes to populate this blog I have to say that this is possibly the best thing on wikipedia ever. If you want the original lyrics for reference they are available here.

Highlights as far as I’m concerned:

This article may contain original research. Please improve it by verifying the claims made and adding references.

The perpetrators have taken jewelry and a name brand designer watch from Warren, who is so incredulous that he asks what else the robbers intend to steal. This is most likely a rhetorical question.

Putting congratulations aside, Nate quickly reminds himself that he has committed multiple homicides to save Warren before letting his friend know that there are females nearby if he wishes to fornicate with them.

Nate goes on to note that if any third party smokes as he does, they would find themselves in a state of intoxication daily (from Nate’s other works, it can be inferred that the substance referenced is marijuana).

Nate concludes his delineation of the night by issuing a vague threat to “busters,” suggesting that he and Warren will further “regulate” any potential incidents in the future (presumably by engaging their enemies with small arms fire).

If only wikipedia had been around when the song originally came out; we could have been jealous of the humour of our elders rather than the humour of our youngers.

That said, today has clearly been the day for discovering excellent websites as how can you turn down a website about Tom Selleck, Waterfalls and Sandwiches particularly when each photo has a caption describing the featured sandwich.

Wonderful.

Published on 2010/08/06 at 00:03 by Toby under , , . Tags , , , , , , ,

Moving Forward from Digital Economy Bill Passing Last Night

Many others have written and created more than I can right now so here’s a collection of the posts that say what I want to say but better:

I’m sure there will be more as the day goes on.

Finally, comments from me: suffice to say, I am very disappointed with the result and disgusted with Parliament. In particular I’d like to single out Ed Vaisey and his colleague Adam Afriyie for using the debate to score political points and not actually debate the bill. It was an example of the ‘change’ and ‘hope’ the Conservative Party offers. It was repellent. The bill was opposed from all sides of the house and then forced through by a three line whip and a compliant front bench from both the major parties. The stench that has dogged this last parliament just got more foul and does not bode well for the next. We need to seriously examine how our parliament works and how we can improve it. Whipping should be one of the first things we look at.

Huge thanks to all those such as Tom Watson who risked their future by breaking the whip and voted against the bill and actually represented their constituents rather than the interests of large lobbying organisations. It’s hard for MPs to break a three line whip in particular so they should be praised through the roof. Thanks should also go to all of the Liberal Democrats who voted against for whatever reason. The way the ‘game’ is played meant that it looked like they wouldn’t at some points so it was a big relief to see it happen. They have all given us a base that means that…

…the fight continues.

One final push against the Digital Economy Bill via Jim Fitzpatrick MP

It’s been quiet around here I know, but here for the record is the contents of the letter than I sent to my MP, Jim Fitzpatrick today:

Dear Jim,

I apologise up front if this email comes over as sounding frustrated but last night spoke for itself.

The Digital Economy Bill Debate last night was, frankly, embarrassing for Parliament. This is an issue of confidence in our democratic process for a lot of people. Some stats from http://debillitated.heroku.com/

Out of 646 MPs only 40 turned up and only 10 stayed for the whole debate.

In contrast there were 5251 individuals discussing it on twitter, with 16180 tweets published. At peak it was one of the top 10 topics globally and has 20x more tweets/minute than any tweets to do with the UK election. People do care about this and to see the scorn that parliament is treating this issue is damning.

Some quotes from the debate last night to save you looking it up in Hansard:

Austin Mitchell said:

“What would a delay of another three months or so in order to discuss the Bill properly and give it full consideration do? There would be no danger in taking such an approach. A delay of three months would not produce the collapse of the creative industries, which has been held up as the threat hanging over us. This needs to be settled and discussed by the Commons through its full procedures; this should not be a rushed Bill, carried on the basis of the half attention of a discredited, dying and distracted Parliament.”

John Redwood said:

“It is a disgrace that the House is not treated with courtesy by the Government. It is quite wrong that a Bill of such importance and magnitude was not tabled earlier. It is quite wrong that there is an attempt to rush through all parts of the Bill without proper scrutiny and debate.”

John Grogan observed:

“I looked at all the Bills that received a Second Reading after a Prime Minister had gone to the palace-I went back as far as 1987… I managed to find the Diplomatic and Consular Premises Bill in 1987, the Architects Bill in 1997, the Lieutenancies Bill in 1997 and the International Organisations Bill in 2005. What they all shared in common was that there was no dispute between hon. Members in respect of them. It really is shameful that we are proceeding in this way.”

Tom Watson said:

“It is a very great pity that the Bill cannot be tested in Committee in the light of some of those questions. As a twice ex-Whip, I am rather embarrassed by the fact that the Bill is being railroaded through in the wash-up. Frankly, there has been a squalid deal between the three Front Benches, and they should be ashamed of themselves. The people who care about this Bill-and there are many out there-will see that for what it is.”

Please, take the time to vote against this horrendously badly draughted bill, or at least push to have it delayed for full scrutiny in the next Parliament. If you feel you can’t do that then please talk to the whips about it to explain that there is a significant groundswell of opinion about this and that it very much is a voting issue.

What happened to the Court of Public Opinion that Harriet Harman relied on so much over Fred Goodwin? Doesn’t it matter now? Does the lobbying and discredited statistics of the BPI matter more?

I have also signed the open letter here which you may find a worthwhile read: http://nevali.net/post/501647501/an-open-letter-to-sion-simon-pete-wishart-david

I will be publishing this letter on my blog at http://toblog.bryans.org/.

Many thanks once again for taking the time to read this, I do appreciate it.

Best wishes,

Toby

UPDATE 2010-04-07 11:20: Jim Fitzpatrick’s reply:

Like many MPs Toby, I was watching much of the debate in my office here at Westminster until the close. The debate resumes today and I will update you with the outcome. It will be interesting to see what changes are made today but there is a lot of consensus that much of the Bill is needed as I read in Hansard from some of the speeches I missed. I’ll let you know the outcome,

Best Wishes, Jim

UPDATE 2010-04-07 11:40: My reply to Jim Fitzpatrick:

Jim,

Thank you for your reply as always.

Unfortunately the statistics that the pro consensus are based on are incorrect or based on a flawed basis:

The entertainment industry as a whole has seen record revenues. The period from January until October 2009 saw record singles sales within the UK, according to the British Phonographic Industry. So much so that the number of singles sold in that period was nearly three times the number sold for the whole of 2002. The statistics presented to Parliament are a simplistic measure of losses, based upon estimates of file-sharing supplied by the British Phonographic Industry (themselves extrapolated from a survey of a small group of people, and was widely debunked in June 2009). Indeed, the sectors of industry which the referenced report claims could suffer three hundred thousand job losses in the UK employs only marginally more than that to begin with. Is it really the case that legitimate sales will cease altogether, despite rising steadily for the past ten years?

I should also note that the consensus on the pro side consisted of the same number of the consensus against in the debate.

There are an awful lot of creative people who do not want this bill. It is only the large companies that have not moved quickly with technology that want it. As always increased regulation will only serve to shore up the market incumbants and make it more difficult for independents and new startups to enter the industry. I consider this a bad thing. Do you? This will also apply to the ISPs that the burden of cost will fall on for the (technological unfeasable) measures the bill forces on them.

Please, at the least, ask your whips to drop clause 11 to 18 which are by far the most damaging clauses in this bill.

Many thanks again for reading,

Best wishes,

Toby

UPDATE 2010-04-07 14:28: Jim Fitzpatrick’s reply:

Thanks Toby, I’ll let you know what happens,
Jim

UPDATE 2010-04-08 12:16: Jim Fitzpatrick was one of the Ayes.

Published on 2010/04/07 at 10:44 by Toby under , . Tags , , ,

Powered by Publify – Thème Frédéric de Villamil | Photo Glenn