• Shortcuts : 'n' next unread feed - 'p' previous unread feed • Styles : 1 2

» Publishers, Monetize your RSS feeds with FeedShow:  More infos  (Show/Hide Ads)


Date: Wednesday, 02 May 2007 00:16
It appears some breaking news came out that IronRuby was unveiled at MIX07. This means ruby support for SilverLight CTP. As shown an the article,
Meanwhile, the Microsoft Silverlight 1.1 CTP was disclosed, said to support JavaScript, C#, VB, Ruby, and Python.
The way the ruby support came about apparently was this:
Once Iron Python was created, Microsoft teams looked to see what other languages could be supported, and what aspects of the Iron Python experience “could be factored out into a set of libraries that could be useful to other people trying to build other dynamic languages,” said Lam, now program manager on the Common Language Runtime team at Microsoft.
So what this actually means as far as the potential could be great but that will be later down the line. The important thing here is that Microsoft is making steps towards supporting the ruby programming language. Ruby is getting some well deserved attention and this will surely aid in continuing its growth and development for years to come.
Author: "Benjamin" Tags: "silverlight, ruby, ironruby"
Send by mail Print  Save  Delicious 
Date: Wednesday, 02 May 2007 00:16
It appears some breaking news came out that IronRuby was unveiled at MIX07. This means ruby support for SilverLight CTP. As shown an the article,
Meanwhile, the Microsoft Silverlight 1.1 CTP was disclosed, said to support JavaScript, C#, VB, Ruby, and Python.
The way the ruby support came about apparently was this:
Once Iron Python was created, Microsoft teams looked to see what other languages could be supported, and what aspects of the Iron Python experience “could be factored out into a set of libraries that could be useful to other people trying to build other dynamic languages,” said Lam, now program manager on the Common Language Runtime team at Microsoft.
So what this actually means as far as the potential could be great but that will be later down the line. The important thing here is that Microsoft is making steps towards supporting the ruby programming language. Ruby is getting some well deserved attention and this will surely aid in continuing its growth and development for years to come.
Author: "Benjamin" Tags: "silverlight, ruby, ironruby"
Send by mail Print  Save  Delicious 
Date: Monday, 30 Apr 2007 20:14
There is an active IRC channel called #hobo on the freenode IRC network for users of Hobo for Rails, the web application builder. This is a courtesy message to encourage stray hobo's out there to come together by the fire lit barrel and exchange some stories.
Author: "Benjamin" Tags: "hobo, rails, webapp"
Send by mail Print  Save  Delicious 
Date: Wednesday, 25 Apr 2007 22:39

This is offtopic but I have been watching some great movies lately and wanted to share some of my absolute favorite titles with all of you readers. This may not help your ruby on rails coding but some of these may definetely alter the way you think and perceive the world. If nothing else they can be enjoyed and thought about. I've included several foreign films as well so if you've never seen a foreign film check out some of the ones listed below. A personal favorite is Cidade de Deus. Share any in the comments that you might add to this list.

More Recently Added:
American History X
American Pie
American Psycho
Boondock Saints
Coach Carter
Good Will Hunting
Layer Cake
Saving Private Ryan
Scarface
Terminator
The Matrix
The Usual Suspects
V for Vendetta
Recently Added:
Accattone
Dangerous Liaisons
Goodfellas
Head, The Monkees
LA Confidential
Kelly's Heroes
Night Of The Hunter
Once Upon A Time In America
One Flew Over The Cuckoos Nest
Raging Bull
The Last Picture Show
The Pursuit of Happyness
Vanilla Sky

Original List:
12 Angry Men
8 1/2 - Federico Fellini
A Clockwork Orange
Akira Kurosawa - Seven Samurai
Alfie
Amores Perros
A Streetcar Named Desire
Awakenings
Baraka
Blues Brothers
Blue Velvet
Carandiru
Cidade de Deus (City of God)
Cinema Paradiso
Cool Hand Luke
Dark City
Doctor Zhivago
Dogma
Donnie Darko
Dreams (Akira Kurosawa)
Dr. Strangelove
Earth (Deepa Metha)
Eternal Sunshine of The Spotless Mind
Fahrenheit 451
Fear and Loathing in Las Vegas
Forrest Gump
Furyo Anego Den
Heart of Darkness
Ichi The Killer (Artsy Japanese Film)
Irreversible

JAWS
La Dolce Vita (Federico Fellini)
La Meglio Gioventu (Italian)
Leaving Las Vegas
Let Him Have It
Los Gritos Del Silencio (The Killing Fields)
Machuca
Memphis Belle
Mindwalk
Monster (2003)
Naked Lunch
Needful Things
On the Waterfront
Out of Sight
Philadelphia
Requiem For a Dream
Roger Dodger
Samotari
Serenity
Shane
Shawshank Redemption
Silence of the Lambs
Sunset Blvd (1950)
Swimming with Sharks
The Basketball Diaries
The Bicycle Thief
The Boondock Saints
The City of Lost Children
The Day the Earth Stood Still
The Deer Hunter
The Departed
The Devil's Advocate
The Devil's Rejects
The Fountain
The Great Escape
The Great Santini
THX 1138
Tre Colori (Kieslowski)
Tsotsi
Videodrome
Visitor Q
What Dreams May Come
Whipped
Wings of Desire

Author: "Benjamin" Tags: "movies, offtopic"
Send by mail Print  Save  Delicious 
Date: Monday, 16 Apr 2007 20:47

There are numerous advantages to learning about the scope plugins available today for ruby on rails development. They can make your code DRYer and more readable and actually save you quite a bit af actual code. As you'll see when visiting the links I am providing with this post, the plugin scope_out for example can provide you with additional methods.

His sites example shows doing:

class Person < ActiveRecord::Base
    scope_out :women, :conditions => ['people.sex = ?', 'F']
  end

The above code creates three class methods: findwomen, withwomen, and calculate_women. It is equivalent to doing the following:

class Person < ActiveRecord::Base
    def Person.with_women
      with_scope :find => {:conditions => ['people.sex => ?', 'F']} do
        yield
      end
    end

    def Person.find_women(*args)
      with_women {find(*args)}
    end

    def Person.calculate_women(*args)
      with_women {calculate(*args)}
    end
  end

There is more to scopeing issues in ruby on rails then what is presented in scope_out.

If your with_scope cases are in controllers as opposed to models, you can do for example:

class Movie < ActiveRecord::Base

    def self.with_playing 
     with_scope :find => { :conditions => [ state = ? AND visible = ?’, NOW_PLAYING, true ] } 
    do yield 
    end 

  end 
end

class MovieController < ApplicationController 

def director 
   Movie.with_playing do 
  @director = Movie.find(params[:movie_id]).director 
   end 

  end 
end

The following sites will open up a wide range of possibilites for you for best use cases for scope in ruby on rails:

The Scope Out Code and Project scope_out

Hobo creator insists you check out scope out... Here's why

Scoped Proxy Plugin for Ruby on Rails

Dynamic Scope

Advantages of using scope_out

Global Scope

Association Scope Plugin on Ruby on Rails Wiki

How to scope your controller without around_ filter (scope_out will allow you to do what this post explains in detail)

Here's an example using scoped_proxy.

class User < ActiveRecord::Base
   scoped_proxy :admins, :find => { :conditions => ['role = ?', 'super_user'] }
   scoped_proxy :has_login do |login|
     { :find => { :conditions => ['login = ?', login] } }
   end
   scoped_proxy :no_op do 
     nil
   end
 end

 # This gives you the first administrator of the system
 User.admins.find(:first)
 # This counts the administrators
 User.admins.count

 # All users with a given login
 User.has_login('foo').count
 User.has_login('foo').find(:all, :order => 'created_at desc')

 # And finally, I give you the no op
 User.no_op.find(:all) # => User.find(:all)
Author: "Benjamin" Tags: "scope, plugins"
Send by mail Print  Save  Delicious 
Date: Thursday, 15 Mar 2007 05:38

Remember that blog named Typo, the one that was really active under development and a lot of us got our start with when rails first became known as the hip framework that it is? Well, they’ve been plugging away for six months or so in the back of seedy bars and diners on their laptops to finally release their 4.1 version with talk of 4.2 soonafter. I even have to upgrade myself for the ruby on rails blog which is still running typo for those of you curios enough to ask…

Here’s the scoop on what’s new:

The changelog is quite impressive, but I’ll only deal with the visible part of the iceberg :

* Ruby on Rails 1.2 support.
* Complete functionnal revamping of the back office, and partial ergonomic rebuild.
* Internationalization and localization support using localization plugin. The application now runs in French.
* Comment and trackback default moderation.
* Lots of bugfixes and code improvement.
* RSS support for tags and categories.
* Plugins now use Rails plugin engine. We’re gonna release packed plugins soon.

Typo 4.2 is due in 2 months, and the roadmap is quite impressive :

* Support of a publishing workflow and users roles.
* Multiple blogs support with a single Typo instance.
* Switch from Localization to Globalization.
* Integrate proposed patchs as plugins.
* Finish the admin revamping.
* Support more languages.
* Stop doing stupid things like starting to support localization the day before the planned release date.

The project is looking for translators a designer to work with me on the admin while I’m doing the ergonomic stuffs.

You can download the source or install Typo via the gem :

laptop # gem install -y typo laptop # typo install /some/path

[edit] There’s a bug in the migration process if you come from the 4.0 version. Before doing the migration, edit db/migrate/056createnotifications.rb and comment the following line : drop_table :notifications

If you have already started the migration, comment both lines : renametable :notifications, :oldnotifications drop_table :notifications

Author: "Benjamin" Tags: "typo, upgrade, improvement"
Send by mail Print  Save  Delicious 
Date: Wednesday, 14 Mar 2007 20:26

The Ruby on Rails team is at it again with another update to… you guessed it, Ruby on Rails. According to the administration, this release irons out the few wrinkles there was between Ruby 1.8.6 and Rails 1.2.2. Not a critical upgrade for most but a useful one for all of us using Ruby 1.8.6.

On another note, why stop at upgrading rails.

Check out the latest version of mongrel as well. That fine piece of software has really gone a distance. That isn’t to say I haven’t had some unexplainable issues lately with session freezes but that could be config issues on my part. I’ll actually be posting about it once Tommy or I figure it out.

To upgrade both of them, simply do: gem update rails mongrel -y

And there you have it! Have fun and try not to lose your wrench!

Author: "Benjamin"
Send by mail Print  Save  Delicious 
Date: Thursday, 08 Mar 2007 03:06
I was hanging out in #radrails on IRC when Kyle Shank (lead developer of RadRails) came in the room and announced that RadRails will be moving over to the Aptana project (http://aptana.com). This will mean that developers will have the power of Aptana's HTML, JS and CSS editors along with the features they have already grown to love from RadRails such as templates, database view, code generators, rake tasks view, etc. This appears to be a win win situation. I would like to take this time to thank Kyle Shank and Matt Kent for getting RadRails to the point it is today. I have used RadRails since the first version and have high hopes for its future in the hands of the Aptana developers. Please join us in #aptana on IRC (freenode) to help get the community started.
Author: "tshine"
Send by mail Print  Save  Delicious 
Date: Friday, 16 Feb 2007 03:23
For those of you who love staying on the very latest rails (aside from dev of course), go grab your copy of rails 1.2.2 with the standard $ gem update rails -y Also here's a useful ruby trick that will let you get all the filenames in a directory into $. Take a look at the code snippet below:
irb> $".inject([]){|s,v| s + [File.join($:.find{|pa| File.file?(File.join(pa, v))}, v)]}
=> ["/usr/lib/ruby/1.8/irb.rb", "/usr/lib/ruby/1.8/e2mmap.rb", 
"/usr/lib/ruby/1.8/irb/init.rb", "/usr/lib/ruby/1.8/irb/context.rb", 
"/usr/lib/ruby/1.8/irb/workspace.rb", "/usr/lib/ruby/1.8/irb/extend-command.rb", 
"/usr/lib/ruby/1.8/irb/ruby-lex.rb", "/usr/lib/ruby/1.8/irb/slex.rb", 
"/usr/lib/ruby/1.8/irb/notifier.rb", "/usr/lib/ruby/1.8/irb/output-method.rb", 
"/usr/lib/ruby/1.8/irb/ruby-token.rb", "/usr/lib/ruby/1.8/irb/input-method.rb", 
"/usr/lib/ruby/1.8/i486-linux/readline.so", "/usr/lib/ruby/1.8/irb/locale.rb", 
"/usr/lib/ruby/1.8/irb/completion.rb", "/usr/lib/ruby/1.8/irb/ext/history.rb", 
"/usr/lib/ruby/1.8/irb/ext/save-history.rb", "/usr/lib/ruby/1.8/benchmark.rb"]
Author: "Benjamin" Tags: "ruby, code, rails"
Send by mail Print  Save  Delicious 
Date: Saturday, 20 Jan 2007 03:09
Before most of you even had a chance to probably snag the release candidate 2 I mentioned a few days ago, the Official rails team has released Ruby on Rails 1.2 in all its glory. For many this means showing our clients the very latest in innovative web2.0 technology and also a chance to refactor our code to make it much more DRY and RESTful as i'm sure you're all familiar with by now.. right? Ultimately we can design our projects and code faster and more cleanly than ever and I will be talking more about how in the posts to come. In the mean time, read the Announcement of Rails 1.2 post and grab your copy by doing:
gem install rails --include-dependencies

...or if you prefer to freeze it:

rake rails:freeze:edge TAG=rel_1-2-1
Author: "Benjamin" Tags: "rails, upgrade, gem, announcement"
Send by mail Print  Save  Delicious 
Date: Monday, 15 Jan 2007 19:12
Rails has made many changes from 1.1.6 to 1.2rc2 which will be listed in a followup post to this one. In the meantime, you ought to know how to update to the latest version. It is fairly simple: You can update your working copy by going to your command prompt and entering:
gem install rails --source http://gems.rubyonrails.org -y
Author: "Benjamin" Tags: "rails, update"
Send by mail Print  Save  Delicious 
Date: Thursday, 07 Dec 2006 19:06
I am still using a Dvorak keyboard layout and have made it up to a solid 76WPM now from 65WPM about a month ago. I think with another year of practice I may regain my old speeds of 100WPM+! Go Dvorak!
Author: "Benjamin"
Send by mail Print  Save  Delicious 
Date: Monday, 27 Nov 2006 20:36
For those of you in the US of A, most of you are probably returning to your jobs or school this week after the Thanksgiving break. I had a delicious turkey day of thanksgiving that was spent with family and am finally well rested and ready to return to making some updates here on the Ruby on Rails blog. We're gearing up for another year soon with a new site design that is nearly finished and several articles coming up including a rails 1.2 primer. Thank you for sticking with us during the last two weeks of quiet time, alas the show must go on.
Author: "Benjamin"
Send by mail Print  Save  Delicious 
Date: Monday, 13 Nov 2006 17:45

In an application where a user is given the ability to upload or edit a css file, you may want to allow them to validate it against the better known css validatation standards. This ruby script can do just that, although it should be mentioned that it depends on curl and thus is only going to run under windows if you use something akin to CYGwin.

Here is the ruby script.

#!/usr/bin/env ruby

curl = `which curl 2>/dev/null`.chomp
validator = 'http://jigsaw.w3.org/css-validator/validator'

# All warnings, CSS2, all mediums
options = 'warning=2&profile=css2&usermedium=all'

base = File.expand_path("#{File.dirname(__FILE__)}/../../public/stylesheets")

# Got curl?
raise "Curl not found" if curl.empty?

# Get path to stylesheets
if ARGV.size > 0
  base = ARGV.shift
end

# All css files or just one?
glob = base =~ /css$/ ? base : "#{base}/*.css"

# Do files
Dir.glob(glob) do |file|

  next unless File.exists?( file )

  errors, warnings = [ ], [ ]

  # Send the css file to the validator
  results = `#{curl} -s -F "file=@#{file}" -F "#{options}" #{validator}`

  # Validator couldn't find the file
  #
  # OR the file didn't have _any_ valid css content before
  # the errors <- little gotcha
  #
  results.grep(/No style sheet found/) do |line|
    STDERR << "#{$&}\n"
    exit
  end

  # Add new lines to <li></li> tags so grep can find them easier
  results.gsub!(/\n/,'').gsub!(/<li>/,"\n<li>").gsub!(/<\/li>/,"</li>\n")

  results.grep(/<li>.*<\/li>/) do |line|

    # collect errors
    line.grep(/<span class='error'>/) do |error|
      errors << error.gsub!(/(<p>|<\/p>)/,"\n").gsub!(/<(.|\n)*?>/, '')
    end

  end

  # collect warnings
  results.grep(/<span class='warning'>/) do |line|
    warnings << line.gsub!(/<(.|\n)*?>/, '')
  end

  # Dump information to STDERR
  STDERR << "CSS File #{file}:\n\n"

  { 'Errors' => errors, 'Warnings' => warnings }.each do |k,v|

    if v.empty?
      STDERR << "No #{k.downcase} found\n---------------\n\n"
    else
      STDERR << "#{k} found:\n-------------\n\n"
      v.each {|line| STDERR << line}
    end

  end

end
Author: "Benjamin"
Send by mail Print  Save  Delicious 
Date: Tuesday, 07 Nov 2006 18:54

Rubyzip

Rubyzip is a gem you can use to zip and unzip files and directories. Here is a very simple piece of code for zipping multiple directories into a single zip file.
Zip::ZipFile::open("filename.zip", true) {|zf| Dir['{dir1,dir2}/**/*'].each { |f| zf.add(f, f) }}

Unzipping it is done like this:

unzip_dir="out"

Zip::ZipFile::open("filename.zip") {
|zf| zf.each { |e|
fpath = File.join(unzip_dir, e.name)
FileUtils.mkdir_p(File.dirname(fpath))
zf.extract(e, fpath) } }
The author if this code helper and rubyzip gem is Thomas Sondergaard.
Author: "Benjamin" Tags: "rubyzip, zipping, unzipping, rails, ruby"
Send by mail Print  Save  Delicious 
Date: Wednesday, 01 Nov 2006 20:47
I needed to identify all of the elements occuring more than one time in an array and could not find a built in method to handle this task. This is a bit trickier than you might think, since the first thing that comes to mind when I think of duplicates and identifying them is Array.uniq and Array.sort and in rails, validates_uniqueness_of.

The Goal


Take this array: [1,3,5,5,6,7,9,10,14,18,22,22,4,4,4,3,6]
Turn it into this array: [5, 22, 6, 3, 4]

Before I go on further, credit is given where credit is due. The following tests, trials and solutions are the product of myself and suggestions from some of my friends from the ruby community: Piers Cawley, Simon Schubert and Rein Henrichs.

SPOILER

The solution and helper to this is at the very end of the post.

First Attempt

The first attempt was the most obvios but incorrect.
array - array.uniq

Second attempt using XOR

require 'set'
=> true
array = [1,3,5,5,6,7,9,10,14,18,22,22,4,4,4,3,6]
=> [1, 3, 5, 5, 6, 7, 9, 10, 14, 18, 22, 22, 4, 4, 4, 3, 6]
b = (Set.new(array) ^ array).to_a
=> [5, 22, 6, 3]
b
=> [5, 22, 6, 3]
# 4 SHOULD be in the above array 'b'
array = [1,3,5,5,6,7,9,10,14,18,22,22,4,4,3,6]
=> [1, 3, 5, 5, 6, 7, 9, 10, 14, 18, 22, 22, 4, 4, 3, 6]
b = (Set.new(array.sort) - array.sort).to_a
=> []
b = (Set.new(array) ^ array).to_a
=> [5, 22, 6, 3, 4]
# 4 IS IN THE ABOVE BECAUSE THERE ARE ONLY TWO 4s in the orginal.

Third Attempt Using If Then Else

# SAME THING AS ary.uniq
array = [1,3,5,5,6,7,9,10,14,18,22,22,4,4,4,3,6]
h = {}; array.map{|i| unless h[i] then h[i] = true; i; else; nil; end}.compact
=> [1, 3, 5, 6, 7, 9, 10, 14, 18, 22, 4]

Fourth Attempt

## Deletes the first instance of each one that occurs more than once
# ARRAY, HASH, EACH, UNLESS, LOCAL VARIABLES
array = [1,3,5,5,6,7,9,10,14,18,22,22,4,4,4,3,6]
b=[]; h = {}; array.each{|i| unless h[i] then h[i] = true else b << i end}; b
=> [5, 22, 4, 4, 3, 6] # ADD ON .uniq! to get rid of the extras
b=[]; h = {}; array.each{|i| unless h[i] then h[i] = true else b << i end}; b.uniq!
=> [5, 22, 4, 3, 6]

The Working Solutions

A few ways to solve this problem were finally discovered, some prettier than others. The next three examples each solve this problem slightly differently, the code is somewhat self-explanatory.
## INJECT AND HASH
array = [1,3,5,5,6,7,9,10,14,18,22,22,4,4,4,3,6]
array.inject(Hash.new(0)) {|h,v| h[v] += 1; h}.reject {|k, v| v == 1}.keys
=> [5, 22, 6, 3, 4]
# ARRAY, HASH, EACH, DELETE_IF
array = [1,3,5,5,6,7,9,10,14,18,22,22,4,4,4,3,6]
h=Hash.new{|h,k| h[k]=0}; array.each{|k| h[k]+=1}; h.delete_if{|k,v| v <= 1}; array=h.keys
=> [5, 22, 6, 3, 4]
# ^ IMPROVED to get rid of the Hash.new block by using 0 as a value object
h=Hash.new(0); array.each{|k| h[k]+=1}; h.delete_if{|k,v| v <= 1}; array=h.keys
=> [5, 22, 6, 3, 4]

The Rails Dups and Dups? Helper Methods

And here is what you have all been waiting for, the helper put together by Rein Henrichs. Yes, his last name is plural. =)
#### .dups and .dups?:
class Array
  # count returns a hash of item, count pairs
  def count
    counts = Hash.new(0)
    self.each { |item| counts[item] += 1 }
  end
 
  def dups
    self.count.dups
  end
 
  def dups?
    self.count.dups.empty?
  end
end
 
class Hash
  def dups
    self.reject{|h,v| v == 1}.keys
  end
end
Thank you for tuning in. I hope you find this useful and for those of you out there with alternative solutions, please share them!

Update - 07/07/2007 (by tshine)

This puzzle has been revisited by some verteran Ruby coders in IRC (carter, njero, divoxx, lisa). divoxx and njero came up with some compelling solutions even if they cheat a bit (see if you can spot where) Source code follows:
require 'benchmark'

n = 10000
array = Array.new(n) {rand(n/2)}
#array = [1,3,5,5,6,7,9,10,14,18,22,22,4,4,4,3,6]
#puts "number of dups: " + array.select { |i| array.grep(i).size > 1 }.uniq.size

Benchmark.bm do |x|
  x.report("hash    ") { h=Hash.new(0); array.each{|k| h[k]+=1}; h.delete_if{|k,v| v <= 1}; new_array=h.keys; }
  x.report("divoxx  ") { count = Hash.new(0); array.select { |i| count[i] += 1; count[i] == 2 }}
  x.report("divoxx2 ") { counts = Array.new(n); array.select { |i| counts[i] ||= 0; counts[i] += 1; counts[i] == 2 }}
  x.report("divnjero") do
   hcount = Hash.new
   res = Hash.new
   array.each do |obj| 
     hcount.key?(obj) ? res[obj] = nil : hcount[obj] = nil
   end
   res.keys
  end     
  x.report("njero   ") do
    counts = Array.new(n)
    res = Hash.new
    array.each do |i| 
      counts[i] ? res[i] = nil : counts[i] = true 
    end
    res.keys
  end
end

Here are the results:
      user     system      total        real
hash      0.020000   0.000000   0.020000 (  0.021919)
divoxx    0.020000   0.000000   0.020000 (  0.022452)
divoxx2   0.020000   0.000000   0.020000 (  0.021570)
divnjero  0.020000   0.000000   0.020000 (  0.014481)
njero     0.010000   0.000000   0.010000 (  0.012627)

      user     system      total        real
hash      0.020000   0.000000   0.020000 (  0.022935)
divoxx    0.020000   0.000000   0.020000 (  0.022138)
divoxx2   0.020000   0.000000   0.020000 (  0.021448)
divnjero  0.020000   0.000000   0.020000 (  0.016395)
njero     0.010000   0.000000   0.010000 (  0.012599)

      user     system      total        real
hash      0.020000   0.000000   0.020000 (  0.021925)
divoxx    0.020000   0.000000   0.020000 (  0.021771)
divoxx2   0.020000   0.000000   0.020000 (  0.021625)
divnjero  0.020000   0.000000   0.020000 (  0.015436)
njero     0.010000   0.000000   0.010000 (  0.014252)

      user     system      total        real
hash      0.020000   0.000000   0.020000 (  0.021945)
divoxx    0.020000   0.000000   0.020000 (  0.021335)
divoxx2   0.020000   0.000000   0.020000 (  0.021150)
divnjero  0.010000   0.000000   0.010000 (  0.018440)
njero     0.020000   0.000000   0.020000 (  0.012805)

      user     system      total        real
hash      0.020000   0.000000   0.020000 (  0.024188)
divoxx    0.020000   0.000000   0.020000 (  0.023519)
divoxx2   0.020000   0.000000   0.020000 (  0.026239)
divnjero  0.010000   0.000000   0.010000 (  0.015307)
njero     0.020000   0.000000   0.020000 (  0.014731)

      user     system      total        real
hash      0.020000   0.000000   0.020000 (  0.024547)
divoxx    0.020000   0.000000   0.020000 (  0.023641)
divoxx2   0.020000   0.000000   0.020000 (  0.024573)
divnjero  0.020000   0.000000   0.020000 (  0.014632)
njero     0.010000   0.000000   0.010000 (  0.014804)

      user     system      total        real
hash      0.020000   0.000000   0.020000 (  0.024099)
divoxx    0.020000   0.000000   0.020000 (  0.023453)
divoxx2   0.020000   0.000000   0.020000 (  0.031250)
divnjero  0.020000   0.000000   0.020000 (  0.014582)
njero     0.010000   0.000000   0.010000 (  0.015394)

      user     system      total        real
hash      0.020000   0.000000   0.020000 (  0.028281)
divoxx    0.020000   0.000000   0.020000 (  0.025164)
divoxx2   0.020000   0.000000   0.020000 (  0.024676)
divnjero  0.020000   0.000000   0.020000 (  0.014608)
njero     0.020000   0.000000   0.020000 (  0.015209)
Author: "Benjamin" Tags: "Helper, ruby, rails, Dups, Duplicates"
Send by mail Print  Save  Delicious 
Date: Sunday, 29 Oct 2006 22:35
Scraping a website means grabbing specific data from a site that is targetted to certain sections of the website. This could mean grabbing the temperature from a weather site or the phone numbers from a yellow-pages site. This example shows how you could scrape CNN for news. You'll also learn about a library known as scrapi for Ruby that makes scraping so much easier.
Credits go to Skiz on this one:
require 'lib/scrapi' # http://blog.labnotes.org/2006/07/11/scraping-with-style-scrapi-toolkit-for-ruby/

require 'net/http'

html = nil
Net::HTTP.start('www.cnn.com', 80) {|http|
  http.request_get('/') {|res|
    html = res.read_body
  }
}

top_story = Scraper.define do
  process "a", :description => :text, :url => "@href"
  result :description, :url
end

cnn = Scraper.define do
  array :stories
  process "div#cnnTopStoriesModule li", :stories => top_story
  result :stories
end

stories = cnn.scrape(html)

stories.each do |story|
  puts "<a href=\"http://www.cnn.com#{story.url}\">#{story.description}</a>" unless story.url 
=~ /^javascript/
end
Author: "Benjamin" Tags: "rails, ruby, scraping, news"
Send by mail Print  Save  Delicious 
Date: Friday, 27 Oct 2006 01:29

Here is a fun example of what some of the possibilities are for Javascript! This demo by MooTools shows how you can grab an object and drag it around and watch it bounce all over the screen.

Author: "Benjamin" Tags: "javascript, mootools, css"
Send by mail Print  Save  Delicious 
Date: Thursday, 26 Oct 2006 21:32

I use PostgreSQL for nearly all of my projects with Rails these days and have encouraged many others to do the same. Now, for those of you currently using it who want to explore the very latest features, you can do so. Here’s how to get the latest beta version:

Download the 8.2 Beta 2 version and give it a test run. Here is a chance to get that edge in using some of the latest features available through a high-quality open source database system.

Good Luck!

Author: "Benjamin" Tags: "open, source, postgresql, sql"
Send by mail Print  Save  Delicious 
Date: Wednesday, 25 Oct 2006 02:06
With the permission of the creator MBoffin we are sharing the Data Model relationships diagram he put together with suggestions on my part to help illustrate how rails defines relationships. Since the ActiveRecord layer is depending on you to make the correct relationship definitions, this diagram may be the answer.
Here is a resized version of the diagram and of course for the full version, click on the image or right click and save image as: Ruby on Rails Data Model
Author: "Benjamin"
Send by mail Print  Save  Delicious 
Next page
» You can also retrieve older items : Read
» © All content and copyrights belong to their respective authors.«
» © FeedShow - Online RSS Feeds Reader