Beware of Ruby namespaces

Posted by Paolo Fri, 17 Aug 2007 20:02:00 GMT

X=100

module A 
  module B
    X=200
  end
end

# ------- Case 1 ------------
module A
  module B
    class C
      p X
      p self.class.nesting
    end
  end
end

# this produces:
# 200
#[A::B::C, A::B, A]

# ------- Case 2 ------------
class A::B::C
  p X
  p self.class.nesting
end

# this produces:
# 100
#[A::B::C]

This post is basically a note to myself: the :: notation in Ruby is NOT a shortcut for nesting modules. In the second case class C is not able to see the X constant inside B (and shows the value of the outer one).

Socialize it: Add to del.icio.us Digg it! Technorati: Beware of Ruby namespaces Add to reddit.com

Posted in  | Tags , , ,  | no comments | no trackbacks

Microsoft and Ruby...

Posted by Paolo Tue, 24 Jul 2007 16:35:00 GMT

Hey, it seems Microsoft is someway dipping feet into Ruby water…

A friend at LRUG wrote:

Microsoft made the first “pre-alpha” release of IronRuby (Ruby on .NET) yesterday. A comment from one of the developers says they’ve seen “3-6x performance wins in many cases for standard benchmarks” compared to plain Ruby.

http://weblogs.asp.net/scottgu/archive/2007/07/23/first-look-at-ironruby.aspx

http://www.iunknown.com/2007/07/a-first-look-at.html

It also runs under the latest svn trunk version of Mono (a cross-platform open source .NET):

http://tirania.org/blog/archive/2007/Jul-23-1.html http://sparcs.kaist.ac.kr/~tinuviel/download/IronRuby/

Socialize it: Add to del.icio.us Digg it! Technorati: Microsoft and Ruby... Add to reddit.com

Posted in  | Tags , ,  | no comments | no trackbacks

Tabnav at the European RailsConf

Posted by Paolo Mon, 18 Jun 2007 14:41:00 GMT

Hi guys, I’m very proud to announce our Tabnav talk has been accepted for the RailsConf Europe! I’ll probably be speaking on Tuesday 18 as stated in this sessions panel. I’ll get this chance to refactor our beloved plugin a bit and introduce a few juicy features. I’m sure we’ll have a lot of fun… it seems many italian rubysts are attending the event too.

See you there then, and wish me good luck!

Socialize it: Add to del.icio.us Digg it! Technorati: Tabnav at the European RailsConf Add to reddit.com

Posted in  | Tags , , , , , , ,  | no comments | no trackbacks

How to check if an image exists on the web

Posted by Paolo Sat, 09 Jun 2007 10:32:00 GMT

require 'net/http'
require 'uri'

def exist?(image_url)
  Timeout::timeout(5) do
    url = URI.parse(image_url)
    req = Net::HTTP::Head.new(url.path)
    res = Net::HTTP.start(url.host, url.port) do |h| 
      h.request(req)
    end
    return res.message.strip.downcase == "ok"
  end
rescue Exception
  false
end

# usage:
exist? 'http://www.seesaw.it/images/logo.png' #=> true
exist? 'http://foo.com/bar.gif' #=> false

Socialize it: Add to del.icio.us Digg it! Technorati: How to check if an image exists on the web Add to reddit.com

Posted in  | Tags , , , ,  | no comments | no trackbacks

Tabnav speech video online

Posted by Paolo Fri, 20 Apr 2007 02:35:00 GMT

Here’s the video of my speech at LRUG, and the discussion about REST. Thanks to skillsmatter for making it available in such a short time.

Enjoy it! Suggestions and comments are always appreciated as usual…

Socialize it: Add to del.icio.us Digg it! Technorati: Tabnav speech video online Add to reddit.com

Posted in  | Tags , , , ,  | 2 comments | no trackbacks

Tabnav speech at London Ruby User Group's April meeting

Posted by Paolo Wed, 18 Apr 2007 01:07:00 GMT

Hi guys, I just got back from my one-day trip to London where I’ve just given a speech about our little Tabnav plugin. I had a chance to talk at the April LRUG meeting and I have to admit it’s been a beautiful experience. It seems that Ruby and Rails are getting momentum in London, the meeting was well organized and really interesting and the conference room (kindly offered by skillsmatter) was a perfect fit for the event.

We started with my talk, I had the difficult task to warm up the crowd… and you know what I mean if you’re not a native English speaker. Luckily enough I made it pretty decently and started explaining how to use our beloved plugin, interleaving the speech with some mind-refreshing gag… (Mr.Monkey knows what I mean). At first I was kind of worried about the crowd reaction.. It’s been my first speech inEnglish and didn’t know if I could really express myself clearly. Laughs in response to my gags and questions after the speech confirmed me that everything went very well, and in the end I could gather suggestions on various ways to improve the Tabnav. Then we continued with a discussion about REST and how it’s been implemented in Rails 1.2. I already discussed this topic with a few co-workers and we’re using it extensively here at SeeSaw so I was aware of the fact that’s a topic that would need more than and hour to be properly dissected and analyzed. My feeling was right, the discussion generated a nice debate but was impossible to get to a conclusion. It’s really difficult to say if all this RESTful stuff in good or not. For sure the REST implementation is not giving programmers that “right feeling” we were used to have with ActiveRecords or RJS. I’d like to see that topic not only under the technical point of view but also from the “programmer happiness and sustainable productivity” perspective. Does REST make programmers happier? Is my productivity more sustainable using this approach? I think these questions will still remain unanswered for a while.

A good tradition about LRUG meetings is the “after-meeting” also known as “the pub around the corner”... You can imagine what happens when you mix passionate geeks and beer. You can find a few pictures of the event here, the slideshow and the video of the event will be online soon. I want to personally thank Murray, Jonathan, Dan, James, Eleanor, Piers, Daniel, Paul, Alec and all those guys whose name I cannot remember.

A special mention to my friend Jason Lee who let me surf his couch last night, after a 2am banana split (He is also the author of http://big.first.name, the software LRUG uses to print tag names during their meetings).

Hope to see the LRUG guys soon again…

Do you want some more links? here we are: http://www.lrug.org, LRUG Mailing list, Skillsmatter RLUG page.

Socialize it: Add to del.icio.us Digg it! Technorati: Tabnav speech at London Ruby User Group's April meeting Add to reddit.com

Posted in  | Tags , , , ,  | 4 comments | no trackbacks

Older posts: 1 2 3 ... 5


SeeSaw srl - Via Monte Pasubio, 8 37126 Verona - tel +39 045 4857457 fax 045 4851151 P.Iva 03609790237