Being evil with DTrace

Sunday, April 6th, 2008

Many people who know me know that I like Ruby and DTrace very much, and I sometimes take an interest in security. This article made me very happy, by combining all three of those: Being evil with DTrace

Via Ben Rockwood.

Round trip

Wednesday, November 14th, 2007

Slowest infinite-regress ever: Java-on-Ruby on Ruby-on-Java on Java-on-Ruby on…

Rushi on language clarity

Friday, October 27th, 2006

<ben> Write it out in pseudo-C, then test it.
<rushi> Pseudo-Ruby.
<ben> What the hell is pseudo-Ruby? English?!
<rushi> Ruby.

Ruby conditionals are cool

Tuesday, May 16th, 2006

This is a fairly basic Ruby thing, but it was new to me, and it might pique some interest among all the non-Ruby-loving heathen out there. Seriously guys, how can you not love this language already?

Did you know that in Ruby, you can use if/else anywhere you could use the ternary (?:), with no other changes? Every block returns (by default) the value of its last statement; the overall if returns the value of the successful block. Returning different values based on a condition is effectively the behavior of the ternary.

Gape in awe at something you cannot do in C-based languages.

var = if(1 == 2) then "a" else "b" end

This is identical to var = (1 == 2) ? "a" : "b";

Unfortunately, you cannot do something like this:

(true) ? (something; something; something;) : something else;

Using parentheses around compound statements, it will not group correctly, and just get a bit confused. Using braces, it will treat the contents as a hash literal (which a pretty cool thing to do, though). do/end generates a compile error.

In conclusion, the ternary is a limited special case of if/else, providing a nicer way to write code using a conditional to produce a value. You can use if/else anywhere you’d use a ternary, but not vice versa.

Using a Proxy class for debugging in Ruby

Monday, March 6th, 2006

caboo.se: Using a Proxy class for debugging

The basic idea is, the Proxy object owns some other kind of object, passes through all method calls to it, and optionally does auditing/profiling as it does so. Good for debugging, profiling, watching where data goes, etc.

The next logical step is to replace the class object with a proxy to it.

>> Article = Proxy.new(Article)

(irb):1: warning: already initialized constant Article

It should be trivial to add some code to Proxy so that when it’s used in this way, all its instance objects will themselves be proxied. This seems to me much more elegant than monkeypatching the class’s initialize, and it can be enabled/disabled with only the line above.

Is this even remotely possible in anything but Ruby?

Daigo Moriwaki

Sunday, December 18th, 2005

The word of programming jobs has wide definition like, imagine, ‘working for driving a car’ means from a Taxi driver to an F1 driver. Ruby is a skill for F1 driving.

Daigo Moriwaki

Just another WordPress weblog