Eric Hodel has worked out a scary way to reduce Ruby’s safe-level on the fly using a little inline C. Please don’t use this in production code, it’s just an experiment! That said, this could be a useful trick for things like Classroom and sandboxing environments. Read More
HotScripts.com, a popular destination for finding PHP and CGI scripts, has added a Ruby on Rails category. Currently only 30 resources are listed, but as one of the heavyweights in the Web developer resources industry, it’s likely to get a lot bigger soon. If you’re a developer you might want to get your stuff added while it’s still small.
(Thanks to Peter Scott for the tip-off!) Read More
def foo
‘bar’
end
module M
def foo
‘baz’
end
end
puts "should be ‘bar’: #{foo}"
self.dup.instance_eval do
extend(M)
puts "should be ‘baz’: #{foo}"
end
puts "should be ‘bar’: #{foo}"
Garry Dolley worked out some interesting Ruby-fu to create a temporary execution context on the fly using self.dup.instance_eval. Any other tricks we could use this for? Read More
Kevin Clark presents “Things You Shouldn’t Be Doing in Rails“. It’s not a list of things Rails isn’t any good for, rather it’s features or concepts related to Rails that you shouldn’t be using. It covers deprecated finders, the in-built pagination classes, scaffolding, engines, layouts, and namespaced controllers. Read More
The Money Train is a great book being written by Benjamin Curtis about building e-commerce sites using Ruby on Rails. It’s released as a ‘beta book’ meaning you can buy and read it in PDF form straight away, but over time you’ll get tons of free updates and eventually the full, completed book (in PDF format). Even better, it’s only $12!
It has some pretty cool ‘e-commerce recipes’ in it, so it’s worth getting for those. It covers the basic such as products, variants of products, related products, and customer reviews.. through to gift certificates, shipping, carts, payment processing, and affiliate referrals. Read More
FileList["**/*.rb"].egrep(Regexp.new(ARGV.first))
Jim Weirich has an interesting blog post about using Rake’s ‘FileList’ class to find files on your hard drive. I’ve already started to use the example he gives here.. good find! Read More
This isn’t particularly new, alas, but still interesting:
Got 15,842 records that you’d like to export to a file? Using the standard the Rails ActiveRecord::Base#find method will load all 15,842 into memory all at once and return them all in an array. If your app is running on a shared host, or if you’re keeping your app on a memory budget, this is a big problem for you. So you could load each record one by one, but that’ll kill your db server. Wouldn’t it be sweet if #find could return an enumerable that would load your records in batches of say 1,500 records? Read More
Prolific PuneRuby blogger Satish Talim has just begun a course of free Ruby lessons. They’re open to anyone who wants to get involved, and so far 43 people are signed up! The lessons have already begun, but you can still get in on the action. The syllabus is available to check out, and to register to receive the lessons you only have to e-mail Satish at satish.talim /at\ gmail.com. This might be an ideal chance to get those friends who keep asking you questions about Ruby off your back ;-)
(E-mail address fixed. Sorry!) Read More
#!/usr/bin/ruby
require ‘rubyhp’
__END__
<html>
<body>
<% cgi.params.each do |key, value| %>
<%= key %>: <%= value %><br />
<% end %>
<% if cgi.params.empty? %>
Sorry, please enter some cgi parameters. How about "?foo=baz"?
<% end %>
</body>
</html>
Christopher Cyll has put together a great little example of how to quickly create templated Web pages with Ruby without requiring any frameworks. It relies on CGI, but sometimes that’s all you need, and it makes throwing together tiny Ruby-powered Web pages possible as easy as creating a simple PHP page. Read More
It’s not mentioned on the official Ruby homepage yet, but Matz has just announced the release of Ruby 1.8.5 on the Ruby mailing list. He claims there are no big changes from 1.8.4 and cites stability as the main benefit of upgrading. Unless you’re having problems with 1.8.4, however, I’d wait a few weeks to see how it pans out, but if you’re itching to try it out get it from http://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5.tar.gz Read More
Today I read JesusPhreak’s “Of snakes and rubies; Or why I chose Python over Ruby” and it highlighted a few of the feelings that have been running around in my head lately regarding Ruby. He points out Python’s wealth and depth of libraries, style guides, and how Python is wider used and less dependent on a single technology to promote it. While Rails is good, he seems to feel that Rails is defining the entire Ruby experience too much. I’m inclined to, sadly, agree.
While Ruby has a large life outside of Rails, Rails tends to define the experience for a great deal of new users. Read More
Geoffrey Grosenbach is unstoppable! He’s put together a simple, but effective, cheatsheet for Ruby and Rails testing that’s full of assertion references. Enjoy.
Link now fixed. Thanks Mike! Read More
The entries and the numbers associated with them were shown in the last post, so choosing a winner is as simple as using ‘rand’. For the first prize $100 drawing:
irb(main):001:0> rand(24) + 1
=> 19
1st prize of $100 goes to Duncan Beevers with Using Simile Timeline with Ruby on Rails Views. A well deserved win too, as it’s a particularly cool demonstration of how to use a JavaScript / AJAX library to show timelines on your Web pages.
And for the second drawing:
irb(main):002:0> rand(6) + 1
=> 3
2nd prize of $15 goes to Tim Shadel.
Thanks for all of the entries folks, and I hope those of you who didn’t win will still enjoy checking out the 24 great articles and resources created for the contest. Read More
These are all the valid entries into the first prize contest from which one random winner will be chosen:
1. Setting Up a Rails Development Environment and Deploying to Textdrive by Jordan McKible.
2. Anatomy of an Attack Against Rails 1.1.4 by Evan Weaver.
3. Top 13 Ruby on Rails Presentations from TechKnow Zenze.
4. Noobies First Impression of His First RoR Project by Shane Thomas.
5. Ruby/Tk Client for SOAP Server by Satish Talim.
6. Ruby-Prof and Call Graphs by Pat Eyler.
7. Profile and Ruby-Prof: Getting Specific by Pat Eyler.
8. Security Threat Last Week by Nick Seiger.
9. Read More
RubyPhone is the first Ruby project I’ve seen relating to telephony (although if you can leave links to others in the comments, please do!) but this code example struck me as particularly interesting:
phone.answer(call) if phone.ringing?
They say it’s ultra-alpha quality, but if you’re getting into this area, it’s worth a look. Read More