Archives for September, 2007

Performance where not expected or gsub vs sub string


If I were to be asked what is faster, regular sub string operation or a regular expression, I would without hesitation answer that sub string is.
This was the assumption that I approached a simple task with - stripping slashes from beginning and end of a string. Here’s the code:

path = path[1..-1] if path[0, 1] == [...]

Morning Brew #79


Another cup of fresh Rails and not so Rails brew. If you’d like to send in a link, please use this page.

Rails

HTTP Basic Authentication using restful_authentication with Rails 1.2.

Ruby

Even more metaprogramming - dynamic class/instance methods.
scRUBYt 0.3.4 - a hot new release is out.
Managing EC2 Reservations with Ruby.
First, Fully Functional Ruby 1.8 Compiler Now Complete.

Web Development

Web [...]

Morning Brew #78


Another cup of fresh Rails and not so Rails brew. If you’d like to send in a link, please use this page.

Rails

3rdRail newsgroups - if you are one of the 3rdRail users and want moral support, CodeGear has created some newsgroups for you.
David Heinemeier Hansson keynote from RailsConf Europe 2007 - in video.
Streamlined 0.9 Goes [...]

Ruby: get full history (all parents) of a hash node


Nested hashes could be used to represent tree structures. Here’s a code to to find a node by key and get all of its parents:

def hash_history(hash, desired_key, &block)
return false unless Hash === hash

hash.each_pair do |key, value|
if key == desired_key or hash_history(value, desired_key, &block)
[...]

RDoc bug: visiblity of attributes is always public


It would appear that RDoc Ruby parser in Ruby 1.8.6 has a bug which leads to attributes always being public.
Here’s the fix in parser_rb.rb:

def parse_attr(context, single, tk, comment)
args = parse_symbol_arg(1)
if args.size > 0
name = args[0]
rw = “R”
skip_tkspace(false)
[...]

Morning Brew #77


Another cup of fresh Rails and not so Rails brew. If you’d like to send in a link, please use this page.

Rails

RailsConf: The DHH keynote - Rails 2.0 update.
Ruby on Rails Security Guide.

Ruby

Why Ruby’s Mixins Gives Rails an Advantage over Java Frameworks.

Web Development

Top 10 microformats Resources for Web 2.0 Developers.
Efficient Compound Index Usage.

Morning Brew #76


Another cup of fresh Rails and not so Rails brew. If you’d like to send in a link, please use this page.

Ruby

Using Amazon S3 from Amazon EC2 with Ruby
Ruby idioms : Add a method to a concrete instance.
Blocks parameters list and metaprogramming.
SWX Ruby - a remote procedure call protocol for Flash (official PHP implementation).

Web Development

Styling [...]

Quick 3rdRail overview in screenshots


Here’s a quick 3rdRail overview in screenshots (flickr required).

CodeGear releases 3rdRail, a Ruby and Rails IDE


CodeGear released 3rdRail this morning. A few highlights:

Full Rails project support.
Rails specific refactoring, ie renaming a method in a controller will update all references as well as link_to and rename the associated view file.
Console with command completion.
Integrated Gecko browser with request monitor, DOM source, CSS and JavaScript

You can watch a screen cast here and download [...]

Distributed RDoc and a DRb tip


Noobkit is powered at its core by RDoc. Obviously it’s not real time, far from it. In fact, full refresh of Noobkit’s database which includes 26 Gems together with Rails and Ruby Core takes about 25 minutes on a single Core 2 Duo 2.4Ghz with 4GB ram box.
About 20 minutes of that time is taken [...]