Author: francis

Email sent in response to the vision thing geekup email

Start here to see what this is i response to

… how many of you go back to the pre-web days? I do – graduated in 1987, I’ve had to practically start again 3 or 4 times in the last 20 years – Unix before Linux, X-windows, dumb terminal to client-server, pre-javascript web tech, javascript, hand crafting your own stuff in raw html, Java, PHP, Java again, Rails. All I’ve ever wanted to do was deliver systems that work and meet real-world problems in a usable way. Be able to go home at the end of the day feeling I’ve achieved something and the people who use the stuff I wrote can do their jobs more effectively and not be dehumanised by it, hence my dislike for techie arrogance, which I see all the time.

2.0 is a Tim O’Reilly marketing thing, because he saw a lot of problems with the current technology and wanted to have some kind of dividing line to help people distinguish between things. But like the man at ucov says: no business model, no idea what people want, groovy idea that recycles some stuff other people have already failed at = failure. I’m with Paul Graham on this one – work on something boring and painful (for the punters) and you will see the rewards. Shiny is’t necessarily good1. You seem to have bought the marketing hype.

I applaud people’s enthusiasm – I want technology to work and help us get out of the social and cultural ruts we’re beginning to die from (a rut is a grave that has’t had the ends filled in yet). Debate is healthy and really useful. The best “manifesto” is something people find useful and the culture that coheres around it. I’d rather work on that than an essay, any day.

F

1 for some reason line from “venus in furs” started going through my head when I wrote that, must get new prescription for meds.

Phorm are those 121 timewasters? Great! Now I know who to send the bill to!

Comment left here  

Did’t realise that phorm were the timewasting bastards who were behind 121 – spent many a happy hour trying to get rid of their viral nonsense from a machine my then 10 year old son was using (no idea how they got past him not being an administrator).

Can I send them a bill? I think they also managed to hijack firefox a while ago by putting in a bogus (and invisible) add on so I had to trash everybody’s settings directory to get rid of it.

DEFINITELY send them a bill, and then a summons through the county court for my time. Anyone else want to join in?

The Met have gone mad – glad I live in Merseyside

Comment left here 

Bloody hell! Although I suppose it might save us from tourists (joke, definitely joke, I hope). Is there any forum you can have a go at them about wasting public money? There’s an idea – why not get off your backsides and do your job preventing it? Maybe pay for some police officers with the cash you just threw down the bog?

It’s like the “ID cards stop terrorism” argument – how exactly? Unless you are going to start something like the pass laws like they had in South Africa under apartheid? And we all know who will have their movements restricted, don’t we? All of the guys on 7/7 were UK citizens and would have had valid ID. No-one suspected anything or they would have done something about it. Gah!

The authorities have to be seen to be doing something so they spend money on paranoid crap like this.

DHH the windows hater – or maybe needs to think a bit before he spouts off?

Comment left here  

I am a Rails developer who uses a proper IDE (Netbeans for Ruby) and Windows. Installed Cygwin to give me the bash shell and the other tools I need to talk to our Linux server backbones. I started on Unix/Sun workstations, went to client/server stuff then on to web. DHH is a kid, bless him, and has’t yet lived through the next big change that will make him realise he has to start again. I’ve done it maybe 5 times in the last 20 years. Experience of one’s own ignorance makes one humble. He’s on a high now. Losing your job is a great and unwelcome teacher, believe me.

I don’t get the Mac thing, either. If you don’t want windows Ubuntu is fine, has the sexy desktop thing and runs on more powerful kit that costs a quarter of the price.

Don’t get me started about TextMate – it’s a word processor with a bunch of arcane key combinations to run a pile of bundled bash shell scripts. I could probably do something similar with Vim or Emacs but don’t need to because the nice guys from Sun have written very good free tool. Can’t split a view of the same file – just like a word processor all you can see is the few lines around where you are working. http://francis.blog-city.com/debugging_rails_applications.htm

Java is bad for your brain talk at Barcamp Manchester

Following on from the talk I gave on why Java is bad for your brain at Barcamp I thought I’d dig out some of my old blog posts and present them here – try and explain the argument (which is more of a feeling of disquiet tha anything else) better.

download mind map here (save as)

I tried to embed the map in an applet – but the downloaded applet does’t work and locks the site up. There is a Flash reader but I lost the will to live Java, eh?

You ca get freemind here. 

Defensive programming

http://francis.blog-city.com/what_defensive_programming_is_and_isnt_logging_the_right_t.htm

This one’s about ‘C’:

http://francis.blog-city.com/at_the_feet_of_the_master.htm

Java is the new ‘C’ parts 1 & 2 

http://francis.blog-city.com/at_the_feet_of_the_master_1.htm

http://francis.blog-city.com/at_the_feet_of_the_master_1htm.htm 

J2EE is incoherent

http://francis.blog-city.com/cohesive_libraries.htm 

Java schools

http://francis.blog-city.com/java_schools.htm 

Java as a text processing language – note the comment about merely trying to ope a file

http://francis.blog-city.com/java_as_a_text_processing_language.htm 

Java and XML

http://francis.blog-city.com/java_finding_nodes_with_xpath_and_how_to_dump_out_xml_dom_as.htm 

SOAP calls make activerecord stop working, oh my

Create an active record object, retrieve some stuff from a soap service and then get this:

NoMethodError: You have a nil object when you did’t expect it!
The error occurred while evaluating nil.has_key?
        from /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2172:in `has_attribute?’
 

If you’re having trouble with active record suddenly throwing exceptions it’s probably because of a namespace collision with your Soap classes defined in the generated file called default.rb, or YourClassName.rb depending upon what arguments you gave to the wsdl2ruby command.

You need to put the data transfer classes into their own module by adding

—module_path MySoap

to the end of the command line. So you have something like this:

wsdl2ruby.rb —wsdl my.wsdl —type client —classdef My —module_path MySoap 

(remember to delete the old files!) 

I last fixed this by hand editing the files and adding in the module definition – so this is by far the easier way.  

Another problem is you get this:

NameError: uninitialized constant SOAP::Mapping::EncodedRegistry 

Just put

gem ‘soap4r’

in the mapping registry file 

SQL is dead?

Comment left here. 

XML – sigh

I read Oracle’s early papers on XML DB – “we store the schema and the data separately, with pointers into the data”

Codasyl in disguise. The same with the o-o databases, hierarchical databases – none of this is new at all.

Personally I can write SQL, I understand the syntax and have been using it for over 20 years. Once you realise you’re really working with sets it’s pretty easy to understand.

RDBMS is now just another commodity. I’m happy to use whatever comes next, I currently develop in Ruby on Rails / MySQL and hardly ever have to see the database directly. Interestingly, the people who designed Active Record made 90% stuff really easy and then allow you to drop into raw SQL for the complex, instead of retrofitting the kitchen sink.

I’ll use whatever comes down the pipe, as long as it meets my needs – that’s it.

Deep merge a Ruby hash, the joys of recursion

I was doing some hacking with lists of valid phone number codes (3,4,5 digits depending upon various factors). I used hashes that could be walked down because of the key lengths. Now we’ve decided to do it  differently because the data file was’t up to date …

This gets the phone number as an array of integers:

      code_pieces = code.to_s.split(//).collect(&:to_i) rescue []

(note the Rails &: thing)

This takes a list of keys and a value, pops the value off the beginning of the array and when the array is done then puts the value in with a hash key of -1:

    def hash_for_digits(n_array,value)
      n = n_array.delete_at(0)
      if n
        the_hash = {}
        the_hash.merge({ n => hash_for_digits(n_array,value) })
      else
        { -1 => value}
      end
    end

This is a merge of a hash of hashes with another – warning – it blows up  without the -1 markers from the previous function.

    def deep_merge_hash(hash1,hash2)
       hash2.each_key do |k1|
        if hash1.key?(k1)
          deep_merge_hash(hash1[k1],hash2[k1])
        else
          hash1[k1] = hash2[k1]
        end
      end
    end
 

Hope others find this some use – I might return to this another day and make it work with arbitrary hashes but now too busy and did’t want to throw the code away … 

The return from the function looked like this:

      top_number = get_code_ref[code_pieces0][code_pieces1][code_pieces2] rescue nil
      if top_number
        ok = top_number[code_pieces3][code_pieces4][-1] rescue nil
        ok = top_number[code_pieces3][-1] unless ok rescue nil
        ok = top_number[-1] unless ok rescue nil
      end
      ok

I realised I could probably have speeded things up by having the first 3 as a hash key in their own right but too late now – reimplementation with a different data set on the way … 

Global Warming – the problem with it

Insightful few paragraphs here.  

If John and others are right, the climate change folks look like tools, if they are wrong we might be in deep trouble.

That’s the problem.

That said, I agree that we can overcome difficulties with technology and ingenuity, and the Green fascist types (who want at least 60% of the human race dead and the rest living on cardboard) tend to see the world as static and unchanging don’t get this. But then the whole racist Malthusian project always becomes fashionable when the economy’s in trouble. It’s quite likely that global warming will become another one of their arguments for sterilising people who happen to have a skin colour they don’t like.

I was sent a “reasons to go veggie” leaflet by someone who seemed to think that forcing subsistence farmers to grow and eat what vegetarians think is a good idea is ok. Another complacent fat westerner telling people what to do and what they can and can’t eat. It was sickening, and the author of the pamphlet did’t even realise how racist it was. I think the global warming thing is going the same way – there’s a lot of anti-Chinese and Indian sub currents when you read the articles. Interesting, eh?

Labelling young people – sigh

Response to one of the comments left here by Stuart Luscombe  

“when I was a teenager a mere 10 years ago there just were’t the kind of problems you keep seeing today. If anything I think school’s, parents and the law in general is still too soft on young people who think that because of their age they can get away with anything they like.”

I left school in the late 70’s with 7 ‘O’ levels and a broken nose. Stuff just did’t get reported then. If anything things are better now because schools at least try to deal with bullying, even if they sometimes fail.

My wife is a Guide leader, and I also used do a lot of work helping her and friends who run scouts. Most youngsters are decent, hard working folk just like their parents. They dislike the chav scallywags as much as you obviously do, we’re talking about maybe 5% of the population here, but they get the headlines because it suits our lords and masters to demonise them and frighten the rest of us.

Stuff gets into the Daily Mail because it does’t happen very often – if it were happening all the time then it would’t be news, d’oh?

Get a grip.