I just got myself an HTC Desire and logged in here It’s interesting how I feel more comfortable using it compared to my now pretty crusty iPhone 3G. Still a bit laborious to type anything long on it but I think I’ll get up to speed quite quickly.
Author: francis
I’m tired of being led – student fees, lies and politicians that can’t count
Leadership
I think less that 20% of the UK population approved of the Iraq war (the Afghan one was unavoidable after 9/11, so let’s leave that out of the discussion). At the time there was a lot of hocus pocus where Tony Blair was said to be taking an unpopular decision for the right reasons and people need to be led in times of crisis. This is code for we don’t give a shit what you think, we’re going to do it anyway – something politicians do lots, but they use code to make it hard to see.
The problem was there was no crisis, and we didn’t need to be led anywhere. The weapons of mass destruction weren’t there, and Saddam, armed with the best former-Soviet technology money could buy, may as well have been waving sticks in the air and banging rocks together for all the good it did him in the end.
Now, however, the political class are trying to run away from their responsibilities. There was no popular movement that could have been helped to create a democratic government with the backing of the Iraqi people, so the coalition had to invent one. If they hadn’t run away at the end of the first intervention then there would probably be a democratic government there that was pro-Western, but they were cowards and didn’t do it. Now, of course, years later, there are a lot of other vested interests that don’t want a stable Iraq and don’t trust the coalition – but who can blame them, after what happened?
If we withdraw, then all those civillian lives, all those brave young men and women who fought for the coalition, all those deaths, all that suffering, will have been for nothing, There will be a blood bath. Now we need to be led, the politicians need to be brave and say uncomfortable things like we were wrong to go in there, but now we have duty to all those who suffered and died to make it right and stop the bloodshed. But they want to run away because that’s what’s easiest.
I’m tired of being led, and I’m sure I’m not the only one. And the running away afterwards, shirking responsibility, makes me puke – it’s an insult to those who have suffered.
Stop pretending to lead us, because you aren’t, and try listening to us.
Student fees
Please, can someone who can count past 10 without having to take their shoes off tell me how raising the fees (which get paid back after graduation if the graduate earns more than a certain amount) will make even the tiniest bit of difference to the deficit now? No significant amounts of money will flow back into government coffers for probably at least 5 years. Who has any idea what state the economy will be in then? The entire argument is bogus and innumerate. No-one is asking this question. If students were paying the fees now, so the government weren’t having to fund them then it would make some sense, but in fact it’s a political thing about not wanting free (or at least subsidised) education – the deficit has nothing to do with it. The deficit is a smoke screen and they should be called on it.
The other thing, which follows on from the last section, is everyone moaning about violence in the students’ protests. Well, matey, we’ve had 25 years of peaceful protest when we were ignored – none of the protesters are stupid enough not to have noticed this. What the hell did you expect? We have a government without a mandate putting up the cost of education without listening to anybody, one half of the coalition signed a pledge (which was in case they were elected remember?) that they would look to abolish the fees, not double them. I think we’re all entitled to be extremely pissed off, and no, don’t try leading us here either. You are full of shit and you haven’t got a mandate – all 3 parties lost the election. So tread with care and be careful not to piss off the 60% of the population who don’t like what you might be trying to do? Too stupid.
If you don’t start listening and actually changing things the 1980’s will look like a dry run.
And Milliband isn’t being an opposition, he’s just waiting around to be elected. This has also been a problem for the last 25 years, or perhaps even longer. Grow a spine, man.
Fun with Cucumber and ActiveRecord after Rails 3 upgrade
I was using Rails 2.3.4 (2.3.10 wouldn’t do logging in as a different user for some annoying reason).
In my data model a story can have many fragments (which in turn can have many gates out)
I had an idiom where I was forcing the ID’s of things to be something I knew, so I could do things like this in my cucumber scenarios:
Given story 1 exists
And story 1 has fragment 1
And I am on story 1 fragment 1
And follow "New Gate"
Then I should see ....
This used to work. I had a helper in my web steps that looked a bit like this:
def create_story(attribs)
force_id = attribs.delete(:force_id)
story = Story.new(attribs)
story.update_attribute(:id,force_id) if force_id
story
end
Plus a similar one for the Fragment. This doesn’t work any more, even though the update_attribute method returns true – it just doesn’t let you update it. Neither can you force the id when you create the record. This is probably a good thing, to be honest, in the general round, but for creating test data it’s a complete pain.
So, how to proceed? I was already creating the stories and fragments with titles like test story 1 anyway. So, instead I use the names of things to get what I want:
def get_story desc_id
Story.find_by_description("test story #{desc_id}")
end
def create_story(attribs)
Story.create!({ :audience_classification => 1, :story_classification => 1,
:owner_id => @current_user.id, :originator_id => @current_user.id}.merge(attribs))
end
When /^story (.*) exists$/ do |desc_id|
@story = get_story(desc_id) || create_story(:description => "test story #{desc_id}",:narrative => "narrative for test story #{desc_id}")
end
And the same for the fragment too, finding the story by its name and then creating the fragment for it alone. This turns the scenario above into the much more natural:
Given story 1 exists
And story 1 has fragment 1
And I am on the list of stories
And I follow "test story 1"
And I follow "test fragment 1"
And follow "New Gate"
Then I should see ....
Instead of jumping straight to the page where I want to test I have to do the navigation and press the named links. I think this is better in the end.
Decided to work on non-software project for a while
I started a comic novel GRTZ way back in the day and have been thinking of adding some more stuff to it, and working on it for a while. I need a break from doing software in the evenings because I can’t concentrate on it.
Here are the existing chapters:
Have a peruse if you want, I will be posting more over the coming few weeks.
New stuff
I suppose this is chapter 3
Imported Comments:
Laurel Wingfield
I enjoyed this. I liked the tone of irony, the ring of reality, in that the Big Corp running the operation were trying to do the whole thing as cheaply as possible, the idea that humans can take the desirable qualities of some animals and use them to modify and augment themselves, and the tongue-in cheek humour.
I found the writing style a bit rough-and-ready, but once polished up and completed, I think this would make a very entertaining novel. It has a sort of ‘Starship Troopers’ ring to it, with a grim humour which might appeal to fans of ‘Firefly’ or ‘Blake’s 7’. It would be difficult to find a publisher who would be prepared to accept this, though, with so much competition out there.
Francis
Thanks, Laurel. I have a huge, far too serious novel I could send you if you want… 🙂
Ruby and Rails 2010: Corey Haines
Thoughts from Software Craftsmanship
Corey Haines
Pair programming started in 1946!
Definitive source of information – googlefight. Says it’s good.
TSA – top secret information. Kept erroring out.
Travel visa for Australia – rejected for a Visa
New term Softwared! Follow Glyn Vanderberg – glad I’ve got the skills feel sorry for the folks who don’t. @glv
This is US!
All written our fair share of things we didn’t test. We’re the ones who are creating all the crap that doesn’t work.
SWC manifesto. Make the world a better place for the people who aren’t developers.
Career ideas – become better at what we do. Business software and web apps aren’t hard but you have to pay attention to the detail.
Alan Kay OOPSLA 1997 talk. Air force tape. Everyone came up with their own formats. Beginning of tape has pointers to code that has the read and write routines. Didn’t have to write code to read any more. All of these ideas slowly started coming in over time. Combined together.
Bruce Tate – most people have never done non OO. Interesting idea most people don’t know what it was like not doing OO.
MongoDB – Document DB – new hotness. .Net only talk about Mongo. Lotus Notes, schema less. Awful job of email. Nothing new about Mongo – had document databases for a long time.
Cuke – inspired by COBOL!
Looking back at the tools can sometimes give us useful insights. Quote: older a program gets the more valuable the readability never hear that this is the value of cuke.
Relishapp.com – all the documentation for rspec. How to use Rspec. Relish takes cucumber features and generates documentation – all doco in the cuke scenarios. If they’re green that’s how rspec work.
Not just code, systems we use. Techniques come from who taught us. Wing Chun teacher focused on interactions between people, fluid interaction. Influenced development style, focues more on interaction – behaviour-oriented. Don’t know where you came from not going to be able to build effectively.
Uncle Bob.
- Professionalism
- Design techniques
- Abstractions
David Chelimsky
RSpec Maintener
- Care for code
- Testing techniques
- Naming
Attention. All of these things very imprtant to him
Continual learning. As we go through our careers always going to have new stuff to learn. Also improtant to get better at what you already do.
Cratsmanship-oriented career model. Don’t spend a lot of time learning from those around us, new people. Just stick with what we know. Feeding the same techniques.
When studied with teacher did what was asked – do what needed to learn, not blind. Respect the person enough to trust that what being taught works. Once studied and become effective, stable point in your career.Most people have other people around them that you can work with, user groups etc.
Knowing what you do know and practicing stuff you don’t : Deliberate Practice
Focus on performing. What would you do if you went to see a band who only play instruments when they’re on stage, but we do it every single day. E.g. write and delete/rewrite? The things you know you should do. Practice – minimise the difference between “get it done” and “do it right”. On stage, you want to just play.
Practice Techniques
Outside of getting it done.
- Code Kata
- Dojo
- Retreats
Randori style. All attack one person and they defend themselves, two people, crowd and then swap one at a time. Get to watch and get to do a little bit. Wonderful. User groups. Pick a small problem.
Kata. Originally Dave T small problems, but broadened out martial arts – a solution. Over and over again, don’t alter them, the goal is to make the motions perfect. When the time comes you won’t be slow. Kata in software, small solution, e.g. string calculator, roman numerals. Solve it. Then do it again, again, again until you don’t have to think about it. Techniques you use will speed you up in day to day work, e.g. flatten array.
Performace Kata – learn it and perform it. At the end feedback. I noticed you did this, better if did that Lots of katas online. katacasts.com
Code retreat. A day where we work on specific problem, e.g. game of life. 45 mins, delete, swap. Can’t finish in 45. Pressure goes away, so look at the process & write perfect code – problem takes too long. Throw away idea of even finishing.
Practice
Being better. Not just the new Gem/DB/banana about being excellent. Fundamentals of s/w development – the heart of s/w craftsmanship
We have the greatest job in the world
Get paid to do things you enjoy.
(Except maybe fighter pilots)
Comes down to happiness. Be happy every single day. If we enjoy what we do then everyone will want a piece of it.
Not going to convince anybody without being happy. People want some of that.
Ruby on Rails 2010 notes part 2
Concurrency: Rubies, plural
Elise Huard
Moore’s Law finally hit in 2002. Multiprocessor response, plus non-uniform memory access. Important to be aware of concurrency.
But … forget all that (mostly)
Concurrent programming != parallel computing
Thread level paralleism vs instruction level
Not orderly more like a stream of cars on a busy road that soldiers in lock step.
Scheduling
- Preemtive → told to yield
- Cooperative → thread yields control
Threads are the unit of execution. Process container/memory space of one or more threads. Context of thread.
Ruby
Process
- 1.8 green
- 1.9 Native threads MRI 1.9, Rubinius
MRI: GIL
Global Interpreter Lock
Only one thread executed at a time, scheduling of threads fair. Main and time. Blocking region to allow limited concurrency. (Blocking IO driver)
Other Rubies
Parallel quicksort
Easy to parallelise, put each tree in its own thread.
Multiprocess
Separate state
disadvantege overhead to cpawinign & context switching
Ruby: for and IPC: IO.pipe Mmap
DRb
Fibers – not parallel. Cooperative scheduling, coroutines – passing between fibers at same point.
MVM
Rubinius – VM per native thread. Looks out of date now and not supported?
Shared state will melt your brain
- non-determinism
- atomicity
- deadlock
- livelock
- fairness/starvation
- race conditions
Actor model
named actors: no shared state – asynchronous message passing fire & forget
CSP
Communication Sequential Processing
- Process calculi
- Events, processes
- Synchronous message passing (rendez-vous)
- named channels – dual to Actor model
Languages
- Erlang
- Clojure
- Go (CSP)
- Haskell (several)
- Scala (Actors)
- …
Ideas
- Functional programming – no side effects, immutable data
- Nothing shared
- message passing
Erlang
- Actor model: Actors, asynch message passing
- actors = “green processes:
- efficient VM (SMP since R12B)
- high reliability
Rubinius
- Actions in the language, threds with inbox
- VM actors (not working at the moment)
Ruby: Revactor
- elrang-like senatics: actor spawn/receive, filter
- Fibers (so coop scheduling)
- Revactor::TCP for non-blocking
Go
- Fairly low-level fit for systems programming
- static typing
- goroutines: parallel execution – sort of async lightweight thread
- channels (sync named)
Clojure
Functional, lisp-like
Concurrency, Sottware Transactional Memory system
- Vars = variable state is thread isolated
- Refs = shared, and mitation within a transaction (atominc. consistent, isolated) – Multiversion concurrency control
Ruby: STM
- @mentalguy
Kernel stuff
Some of these problems have been solved before.
http://www.delicious.com/elisehuard/concurrency
http://github.com/elisehuard/rubyandrails-2010
Rubinius
Dirkjan Bussink, Nedap
1.1 is out! Bug fixes, block inlining, new debugger API and included debugger as a reference, improved GIL (used ideas from Python 3.2)
2006 Ruby interpreter in Ruby, is it possible to write more of Ruby in Ruby?
2010 1.0 release
2 virtual machines (3 if you count the 1st VM in Ruby) new VM in C++ better fits Ruby’s model from C++
1.75 garbage collectors
3 bytecode compilers (based on MRI parser)
1 Ruby core library
2 primitives systems – call into VM to do work for you
2 JIT compilers
Rubyspec
Create a reference for Rubinius and create in Ruby.
Memory
Compacting garbage garbage collector
Generational – long lived objects out the way not scan every object every time
Fast workers die young
Instance variable packing, keeps track of instance variables used in compilation
JIT
InlineCache – simple technique, remember where method was found. But need to invalidate caches if class has been changed. Method calling much faster than MRI. Counts how many times you call the method, and looks at chain of calls. JIT using LLVM – intermediate representation (IR) assembly language for LLVM.
Debugging
Debugger.here – shows backtrace, disassemble into bytecode
The awesome backtrace, proper alignment, different colours for what kind of code
Profiling
Measuring is knowing and guessing is often wrong. Runs twice, warm up to get inlining and optimisations. Profiler graphs too so that you can trace why things take time when they don’t in isolation.
Contributing
One patch accepted == commit access
Rather have a policy of being very open.
rbx my_awesome_code.rb
Future
- 1.9 support new Hash syntax, encodings
- Windows support
- Hydra GIL removed
Audio Synthesizers
Jeff Rose, Sam X
Clojure. Serge modular synth
Modules/patch cables/no save button
Software synths like Circle – can’t get into the guts and rearrange things. Visial programming analogues. Finally found SuperCollider – own language based on Smalltalk. Getting into clojure, connect it to back end audio engine of SuperCollider …
Generate music / hack. Representing a waveform as arrays of numbers and manipulating them. Software – sound card DAC takes sample values and makes smooth waveform. Voltate corresponds to position of an electromagnet.
Crash course in Clojure …
Overtone – library around SuperCollider API
Compile synthesiser in terms of DSP units and function you can call to trigger it.
Live coding session followed. It was ok for a while.
Ruby on Rails 2010 notes part 1
Mildly incoherent, but here they are:
Culture of Testing
Jon Yurek, Thoughtbot, @jyurek
Testing & version control not taught in school, no reason not to. Java testing getters and setters – insane. Culture of Ruby is to test/TDD.
- Coming of age blog
- Then framework
Contrib factory_girl/shoulda. Out the box very limited. Then we found cucumber. Didn’t like at first, but then having a story. 2009 Rumble – pure cuke. Can’t test with just cuke. Fakes – sham-rack. Tiny apps that can run basic API hits. Outside-in the way forward.
Don’t write integration tests like unit tests – cuke stories are not supposed to be code.
Steps not just long-winded method calls.
Don’t have time to test – it will make us faster. Technical debt – won’t be able to refactor or add new features. But if you really need to, go ahead. Once done, and calmed down rewrite it the right way headaches down the line.
Working with the unknown – write stuff to find out what the approach is. Understand problem and then throw it away. Experiments, toss them out. Weren’t writing your best code in the first place.
Code is communication, tests even more so.
Tests are also tests – tests are first client for app. No-one will know how to change, cargo culting. Tests will tell you what the coder was thinking.
Look at tests first.
RSpec & Shoulda have very few watchers on github.
Everybody’s testing, just not very efficiently.
Use the scientific method hypothesis/test/control/results Profit!
Hypotheses – Greatest challeng to any thinker is stating the problem in a way that will allow a solution Bertrand Russel
Test explicitly exposes solvable problem and confirmation. Harder than writing a solution. More time,
All testing in some sense – switching over to TDD – make code better.
Black-box testing. Outside in, refactoring should make no difference.
We owe it to ourselves and our profession to prompte automated testing. Having this culture.
Crazy ideas would like to see –
- Javascript in Ruby (exists, but crazy).
- Automated tests for HTML/CSS
- CPAN tester network for gems
Good testing ==== public shame
Won’t run gems without tests.
Tests are professional – respectful enough of their code to document in code.
All work in topic branch – git pull requests. Code coverage done through review.
Git the stupid NOSQL database
Rick Olson
Github use it more like a database.
git hash-object
(what?)
Send some JSON into a file and get it out again – crazy.
Git also a graph database – Nodes to nodes
Tree – subdirectory of blobs
git update-index
git write-tree
commit-tree
refs (not an object, a tag/pointer)
tags
2 types – lightweight, branch pointer to sha, annotated tags object that points to a commit w custom tag message who/when
gem install grit
gem install gollum
Local wiki clone of the one in git
Hmmmm – git grep
Latest files updated atom feed
diff-tree —name-only master~10 master
Need to know how many commits or will errir
Gollum suited for small to medium projects.
Smoke is grit on the cloud – proxies out to Erlang services.
Rails Admin, The right way of doing data administration
Bogdan Gaza, @hurrycane
Rails Admin Ruby Summer of code 2010
Way you organise & control your data
Admin panels – PITA
Simple, secure & fast – custom error prone not fast or simple.
CMS? Simple but not always flexible. Rails – Plugin/engine, usually secure fast & simple
Choices:
- lipsiaAdmin (R2) ExJS
- Active Scaffold (R2)
- Hobo (R3) includes a lot of non-admin stuff
RailsAdmin sferik/rails_admin
Port Merb-Admin to R3. Merb slice/R3 engine, structure pretty much the same.
Engines similar to plugins, but work like Merb slice.
Namespaced controller/model/routes. Mountable app outside Rails structure
gem ‘devise’
gem ‘rails_admin’, :git => ‘git://github.com/sferik/rails_ad,in.git’
bundle update
rails g rails_admin:install_admin
Not using devise? Override or use another warden-based solution.
authenticate … and current_user
3.1 it will be mountable.
Automatically adds history and search
Will be the admin panel of choice in future.
Seecodez – a code review manager
Seecodez is a project I’m working on in amongst the million other things I’m doing at the moment. I’ve decided to set up a Rails 3 project on my little Evo machine that I can take with me and work on when I’m waiting for things. I use the Evo rather than my MacBook when I don’t want to lug the damn thing about or worry about it getting stolen as the Evo only cost me a few quid.
It’s interesting but you can run Ruby 1.9, Rails 3, Emacs and Google Chrome on an old Pentium 3 with 512MB RAM. It’s not particularly slow, but I am running Ubuntu and not some Microsoft excuse for an operating system.
Discovered that Rails won’t run without open SSL installed on Ubuntu. This is a problem I’ve been through before with Ruby 1.8.6 about a million years ago.
Anyway, I’ve defined my first model. Now need to write some tests and start homing in on the functionality I want.
Progress of a sort.
Moving to a Rails-based blog engine, Enki
Blog City, who used to host this blog, decided that they’d had enough but didn’t seem to tell anyone who had a subscription that was about to lapse. Thanks guys, I’ve been a customer of yours for over 7 years!
I was planning on moving to another site eventually, but not right now because I’ve got too much to do. I was concerned that I was going to lose all that effort, and potentially useful stuff. So went into panic stations mode (I suppose) because I just wanted to get it done and move on to something else.
In the end I did some Unix shell hacking and pulled all of the entries through into a format where I could load them into a Rails application of my choice. I decided to use Xavier Shay’s Enki – it’s minimalist, but there’s enough there to get up and running quickly and it does comments and pages out of the box, which is pretty damn cool. The old blog posts are all now pure HTML and the comments are missing, sorry.
Then the fun started. As it comes out of the box Enki won’t run on the Heroku servers because of some problem with the gems in the Gemfile. I messed about with this for ages and in the end went for the obvious solution.
- Create an empty app with the latest Rails 2 (2.3.10) and see it deploys (tick)
- Copy the migration and app files across and see it still runs (tick)
- Copy in the plugins (tick)
- Let ’er rip and see what gems she needs (tick)
- Put those gems, and those gems only in the Gemfile (tick)
Thar’ she blows!
So I have a version of Enki that isn’t a fork, but a Heroku-friendly pulling across of the core files into 2.3.10. Good news is that moving from this to Rails 3 should be really easy, in fact it might even make sense to repeat the process but with a Rails 3 base. Bad news is that it isn’t a fork and I don’t know how to get it back into Xavier’s main code base.
Imported Comments:
Ruben Berenguel
Congratulations for your move. I have been watching it over twitter. I’m glad it worked out!
Cheers,
Ruben (from mostlymaths.net)
Mac: You don’t have access to / on this server
Posted about my fight with my Mac, so next person might benefit from it on my company site:
http://www.pharmarketeer.com/2010/04/02/apache-strangeness-on-mac.html