January 2012
1 post
OS X Multitouch view →
I played around with this a few years back, and deleted it. But recently my trackpad(s) have been playing up, and it took me a while to find it again. So linking here for reference
Jan 11th
November 2011
1 post
Install Open-VM-tools on Debian 6 squeeze →
I’ve had to jump through these hoops twice now, so saving the link here for posterity.
Nov 27th
January 2011
1 post
1 tag
Embedding IRB into your Ruby application
I needed to play around with Capybara/Selenium, but it’s a pain waiting for Firefox to start up every time you make a small change. Fortunately, I’m not the only one with the problem. Drop this somewhere: require 'irb' module IRB # :nodoc: def self.start_session(binding) unless @__initialized args = ARGV ARGV.replace(ARGV.dup) IRB.setup(nil) ...
Jan 16th
November 2010
1 post
“As of Emacs 20.3, there is indeed a repeat command (C-x z) that repeats the last...”
– GNU Emacs FAQ
Nov 19th
July 2010
1 post
Jul 5th
May 2010
2 posts
4 tags
Mocha doesn't play nice with Rails 3 & Bundler
Using mocha with edge beta Rails 3, I added Mocha to the Gemfile gem "mocha" All was going swimmingly until I ran into a problem. I reduced it to: The result of running this test was: #test_mock_doesnt_fail should fail, but doesn’t. Changing the require lines at the top of the file to not load Rails and only load Mocha (+Rubygems+Test::Unit): require "rubygems" require...
May 26th
May 15th
April 2010
3 posts
“‘Now will this be everything, or…’ ‘Well, I might need...”
– JRM at Abstract Heresies
Apr 21st
Be mindful of array copying
Trying irb> d = [1,2,3,4] => [1,2,3,4] irb> d[0..-2].each_with_index {|k,i| d[i+1] = "x"; puts k } 1 2 3 => [1,2,3] irb> d [1, "x", "x", "x"] Reasonable, d[0..-2] would make a copy of d irb> d.each_with_index {|k,i| d[i+1] = "x" if i < 3; puts k } 1 x x x => [1,2,3] irb> d [1, "x", "x", "x"]
Apr 12th
"Best Writing Advice for Engineers I've Ever Seen.... →
How to make engineers write concisely with sentences? [combine] journalism with the technical report format.
Apr 6th
March 2010
1 post
4 tags
Y Combinations
I found myself needing to use a Y-combinator last night, while playing with regular expressions. I wanted to recursively scan a string, finding matches inside other matches. Of course it could have been done by defining a function and calling it recursively, but that seemed unnecessary. I had a vague understanding of what a Y combinator was and what it could do, which allowed me to realise that it...
Mar 30th
February 2010
2 posts
Date manipulation
rubyquicktips: You can add or subtract days or month from a Date object: +(n): add n number of days -(n): subtract n number of days >>(n): add n number of months <<(n): subtract n number of months Here are some examples: $ irb >> date = Date.today # => #<Date: ...> >> date.to_s => "2010-01-26" >> tomorrow = date + 1 # => #<Date:...
Feb 12th
46 notes
Feb 10th
January 2010
2 posts
Raganwald's favourite interview question →
A discussion about interview questions from Raganwald: How might you design a program that lets people play Monopoly with each other over the internet?
Jan 12th
Researching how javascript prototype inheritance works. Methods defined in the constructor are copied for each instance, whereas methods on the prototype are shared. When you set the prototype of a “class”, you need to reset the constructor: B.prototype = new A; // Define sub-class B.prototype.constructor = B; And to call the parent class’s...
Jan 12th