Weird history

Ada Lovelace - Commonly known as the first programmer

chiefly known for her work on Charles Babbage’s early mechanical general-purpose computer, the analytical engine. Her notes on the engine include what is recognized as the first algorithm intended to be processed by a machine;

fathered by

Lord Byron - Famous poet, "mad, bad and dangerous to know" who used his place in the house of lords to support the Luddites

His first speech before the Lords was loaded with sarcastic references to the “benefits” of automation, which he saw as producing inferior material as well as putting people out of work.

I wonder if daddy was proud? :-)

Behaviour of next in collect

Basically, anyone got a better way to do this? :

irb(main):003:0> [1,2,3,4,5,6].collect { |v| next if v == 3; v * 7 }.compact
=> [7, 14, 28, 35, 42]

Let me know on twitter if you have a better way.

I oversimplified my example, it’s actually more like:

objects.collect do |obj|
  begin
    QueryPredicate.new(obj.parser.parse_internal)
  rescue ParsingException => e
    next
  end
end.compact

Which prevents me using the suggestion of

[1,2,3,4,5,6].reject{|v| v == 3}.map{|v| v * 7}

as I don’t have any way of telling what can be rejected from the set. Still, I learnt the “reject” keyword, which makes me happy.

Suggested improvement from colleague:

objects.collect do |obj|
  begin
    QueryPredicate.new(obj.parser.parse_internal)
  rescue ParsingException => e
    nil
  end
end
objects.compact!

Yeah that’s a bit better

Rails content_for stacks content

Worth remembering, the content_for helper appends subsequent calls rather than replacing.

So would render “Hello world!”.

Seems kind’ve insane to me, if I wanted that behaviour I could always add it to content_for rather than doing it by default.

Video presentation by two of the original SVN developers talking about social good-practices with programming and the way different tools affects that.

Thoughts while watching:

  • "fail early, fail often" - Pretty much a theme throughout, and fair enough
  • code reviews - So many big name places seem to take this dead seriously
  • no code ownership - Code ownership always tends to be bad, liked the suggestions on how to lessen it though, ie
    • assign bugs/features to people with a low knowledge of that area
    • pair program bugs/features for that area low-knowledge/high-knowledge
  • big fish, small pond - No doubt it’s true that working with more skilled people than yourself is good for you, but it can be pretty hard just to recognise what you want to learn let alone find the people/environment that supports that
  • 'bus factor' - heh, awesome name
  • git-rebase - I dunno that lots of people use this to rewrite history? I use it to avoid pointless noisy merge commits
  • documenting failure - Seems pretty obvious that doing this would be helpful, but as with all documentation I have no idea how to do it in a way that would be useful
  • subversion - I understand these guys fondness for svn, but it’s so far behind in so many areas, and I think github-like tools affectively alleviate their problems with distributed version control more than they acknowledged
  • pair programming - I think this is the one core practice detailed by XP that’s still seriously controversial. I have no opinion :-)

People who ask tangential societal questions after a talk drive me nuts. "really in reality" points are seriously annoying as well. “buyer beware”. Piss off, buyer is beware, just assume (as the presenter does) that the audience is as capable of understanding the realities of their own situation as you are.

Update to bash back button

My new .bash_aliases

alias cd="pushd >/dev/null
alias bd="pushd +1 >dev/null"
alias fd="pushd -0 >/dev/null"

My bash prompt now has a “back directory” command, *and* a “forward directory” command!

mongrel_rails, logrotate, and copytruncate

If using logrotate with rails remember to use the copytruncate option. This means that instead of renaming the old file and creating a new one, logrotate will copy the old file to the archive name, and truncate the current file. This means that mongrel_rails doesn’t lose its file handle and your logging doesn’t silently turn off :)