March 2010
60 posts
Mar 31st
7 tags
F*** You Larry Ellison →
Mar 30th
WatchWatch
EventMachine: Scalable Non-Blocking I/O in Ruby
Mar 29th
Mar 29th
7 tags
Mar 29th
9 tags
Proc.new vs lambda vs proc
ruby-doc Proc objects are blocks of code that have been bound to a set of local variables. Once bound, the code may be called in different contexts and still access those variables. def gen_times(factor) return Proc.new { |n| n*factor } end times3 = gen_times(3) times5 = gen_times(5) times3.call(12) #=> 36 times5.call(5) #=> 25 times3.call(times5.call(4)) ...
Mar 28th
2 notes
4 tags
Ruby 1.9.x: j and jj
j & jj the JSON conversant relatives of p & pp, i.e. they output JSON strings on one line or pretty print them over many lines with indentation respectively. ruby-1.9.1-p378 > require 'JSON' => true ruby-1.9.1-p378 > obj = [{:foo => "bar", "baz" => [1,2,3,4,5]}] => [{:foo=>"bar", "baz"=>[1, 2, 3, 4, 5]}] ruby-1.9.1-p378 > j...
Mar 28th
Mar 28th
Mar 26th
1 note
6 tags
class_eval vs instance_eval
In Ruby you may have seen class_eval and instance_eval and thought to yourself “What is the difference?” They both accept a string or a block as an argument, but then they diverge: instance_eval evaluates a string as Ruby code or a block in the context of the object’s singleton class. Effectively it changes the value of self, the implicit receiver, to be that of the...
Mar 26th
1 note
2 tags
To Yield Or Not To Yield? That Is The Question…
Today I was looking quite closely at Rails 3, specifically the changes to the routing API. # Rails 2.x ActionController::Routing::Routes.draw do |map| map.resources :posts end # Rails 3.x AppName::Application.routes do resources :posts end The first thing I noticed was the omission of a block variable. So I thought to myself “WTF? Is the block being instance_eval’ed instead of...
Mar 26th
3 tags
DRY Much?
I’ve been looking through the source of ActiveSupport and Rails in general, and I’ve noticed this particularly verbose style of monkeypatching a multitude of objects with the same behaviour: # Can you safely .dup this object? # False for nil, false, true, symbols, numbers, class and module objects; true otherwise. class NilClass #:nodoc: def duplicable? false end end class...
Mar 26th
MongoDB 1.4 Ready for Production →
Mar 26th
Mar 25th
Mar 25th
Mar 25th
1 note
Mar 24th
Why Behavioral Economists Love Farmville →
newsweek: (Even though we honestly think it’s kind of a waste of time) WOW
Mar 24th
203 notes
“Any new slays?”
– Samuel A. Kochman
Mar 24th
Mar 24th
The Business Model Of The Somali Pirates Of The... →
Mar 23rd
3 tags
Maybe why you don't see recursion used much in...
I’ve become interested in recursion and functional programming lately in the interests of sharpening one’s saw, and was interested to see how recursion performed in Ruby. Consider the following code: require 'benchmark' def recursive_factorial(n) n == 0 ? 1 : n * recursive_factorial(n-1) end def iterative_factorial(n) (1..n).reduce :* end Benchmark.bmbm do |x| ...
Mar 22nd
3 notes
Oh Baby!
Mar 21st
This is what you get when you pay $99 for web... →
Pay peanuts, get monkeys.
Mar 21st
Guy Kawasaki New York Times Interview →
Absolutely worth reading.
Mar 21st
Mar 20th
Mar 20th
Mar 20th
Mar 20th
4 tags
Mar 19th
4 tags
SproutCore Blog: SproutCore and the New Logo →
sproutcore: Just in time for SproutCore 1.0, I’m excited to officially announce that SproutCore has a new logo contributed by community member “endash”. Here’s it is: Download all the logo variations hereAlong with the new logo, we’ve also updated the SproutCore website with a simpler, but I… Great! All we need now is API documentation! :/ P.S endash is a very helpful and knowledgeable...
Mar 19th
1 note
ListenMichael Jackson - Jam I bet this joint would have...
Mar 19th
Mar 18th
Mar 18th
Mar 18th
2 tags
Ruby Quines
A quine is a program that prints out it’s own source code. More on that here. s='s=;puts s[0,2]+39.chr+s+39.chr+s[2,36]';puts s[0,2]+39.chr+s+39.chr+s[2,36] This contains a string which consists of a reference to itself and everything before and after itself. It is assigned to the local variable s so the string can be reused to take substrings that match the code declared before and after...
Mar 18th
WatchWatch
Ryan Leslie European Tour 2010 Recap Shot and edited by my incredibly talented friend Evan Rogers Ev’s new blog coming up next. ;)
Mar 17th
5 tags
ActiveRecord models are bloated.
They handle object persistence, the object graph, business logic, and proxy data to other objects (accepts_nested_attributes_for). accepts_nested_attributes_for was the straw that broke the camel’s back for me. More on this later.
Mar 17th
Mar 16th
Mar 16th
The Dropout Economy - TIME Magazine →
brandonthegreat: “But what if the millions of so-called dropouts are onto something? As conventional high schools and colleges prepare the next generation for jobs that won’t exist, we’re on the cusp of a dropout revolution, one that will spark an era of experimentation in new ways to learn and new ways to live.” college is for peons
Mar 15th
Mar 15th
128 notes
As much as I love thingsthatexciteme. It clearly... →
Mar 14th
Mar 13th
Mar 12th
Mar 12th
54 notes
4 tags
Quick Tip: Ruby Monkeypatch Fail
I’m contracting at the moment, developing an internal CRM application. For authorisation I’m using Ryan Bates excellent CanCan. However, due to application requirements, I can’t control access at the resource level, it has to be done at the controller level. For this I created a little patch to extend ApplicationController: module SG module CanCan module...
Mar 12th
Mar 10th
Math Joke
Q. What’s the integral of 1/cabin? A. A log cabin
Mar 9th
Mar 8th
1 note