August 2012
1 post
'(:cell) REPL →
Cell is a toy language based on the original Lisp specification.
June 2012
4 posts
SnowPlow →
SnowPlow does three things:
Identifies users, and tracks the way they engage with one or more websites
Stores the associated data in a scalable “clickstream” data warehouse
Makes it possible to leverage a big data toolset (e.g. Hadoop, Pig, Hive) to analyse that data
Brakeman →
[…] a static analysis tool which checks Ruby on Rails applications for security vulnerabilities.
Ampex →
The ampex library takes the idea from &:symbol, and adds a little more flexibility. This means that you can get all the punctuation-free, variable-free goodness, but more often!
A few examples of how cool this can be:
# when you want to pass an argument to a method
[10, 11, 12].map(&X.to_s(16))
=> ["a", "b", "c"]
# when you want to parse some JSON
owners = [{'name' =>...
YouAreDaChef →
[…] a utility for meta-programming Object-Oriented JavaScript.
This library adds before, after, around, and guard method combinations to underscore.js projects, in much the same style as the Common Lisp Object System or Ruby on Rails controllers.
May 2012
1 post
For when you realise that the file you want to edit is owned by root.
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
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.
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)
...
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
July 2010
1 post
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...
April 2010
3 posts
‘Now will this be everything, or…’
‘Well, I might need...
– JRM at Abstract Heresies
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"]
"Best Writing Advice for Engineers I've Ever Seen.... →
How to make engineers write concisely with sentences? [combine] journalism with the technical report format.
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...
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:...
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?
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...