Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

By Peter Cooper / October 5, 2006

Austrian development agency, Sparkling Studios, look at how to use the Akismet anti-spam system to check data submitted to your site and protect your application from spam. It works by signing up for a key from Akismet and using a Ruby Akismet library. Then whenever you want to check your data, you make a simple call and Akismet returns a true or false based on whether the system believes the data to be spam.

It should be noted that this method is primarily useful for blog comment and trackback related spam, but could be useful on other data that fits the same structure. Read More

By Peter Cooper / October 2, 2006

SessionTimeout is a Rails plugin by Luke Redpath that makes enforcing short session times easy, like so:

class ApplicationController
session_times_out_in 600, :after_timeout => :do_something

def do_something
logger.info "HELLO, IVE TIMED OUT!"
end
end

Luke explains:

With Rails built-in session options, you can set a specific session expiry time however in production mode this expiry time is set just the once. This is fine if you are setting your expiry time far in the future (and therefore you are likely to restart your server processes by that time) but if you want to set your timeout in the near future, your session expiry will soon be a date/time in the past – this will cause a new session to be created for every new request resulting in disaster. Read More

By Peter Cooper / October 2, 2006

James Edward Gray II laments:

Every so often a person asks the question on Ruby Talk, “How can I get just one character from the keyboard (without needing the user to hit return)?” Everyone is always quick to post solutions, but sadly there are some issues with almost every one of them.

He moves on to look at a reasonably cross-platform solution called HighLine. This isn’t very useful if you’re just a Rails developer, but if you’re creating Ruby apps to be used at the command line, it’s gold.

(Update January 8, 2008: Thanks to Michael Fellinger for pointing out the above URL was broken. Read More

By Peter Cooper / September 30, 2006

Rubyinsidelcd
BetaBrite is a Ruby LCD sign library developed by Aaron Patterson. Since few people have LCD signs to play with, Aaron has set up a test-bed installation that you can use via DRb. Ingenious! Next I expect a Ruby blinkenlights library and DRb hookup.
(First seen at why‘s) Read More

By Peter Cooper / September 30, 2006

Youtuberuby

Shane Vitarana has put together a Ruby library for accessing YouTube videos and metadata. All that’s needed is a simple gem install youtube, and you can put together great examples like the above. Shane cites Scott Raymond’s Flickr Ruby library as an inspiration. Read More

By Peter Cooper / September 27, 2006

Jon Maddox was inspired by Ruby Inside’s previous post about init.d startup scripts, and has put together a UNIX init.d script that can start, stop, and restart all of your Rails apps’ Mongrel clusters automatically. The benefit of Jon’s approach is that unlike with the startup script supplied with Mongrel, you don’t need to manually copy in each Mongrel configuration file to make it work. Instead, you tell the script under which folder your apps are hosted, and it looks for your Mongrel cluster configuration files automatically. This is an ideal script if you have multiple Rails apps on a single machine and want to stop and start the entire set at once. Read More

By Peter Cooper / September 25, 2006

Most init.d start-up scripts seem to be bash scripts, but you can write them with any language. Here’s some template code I use to create my own Linux services. You can even add them to chkconfig to be started properly on startup, and they’ll also work with RedHat / CentOS’s service system straight off.

(Update: January 2007, John Dewey warns me that this will not work on Solaris as it forces scripts to be run using /sbin/sh .. I guess a way around it would be to have a script in the middle that then calls Ruby, but it’s your call :)) Read More

#!/usr/bin/env ruby
#
# app_name This is a startup script for use in /etc/init.d
#
# chkconfig: 2345 80 20
# description: Description of program / service
APP_NAME = ‘app_name’
case ARGV.first
when ‘status’:
status = ‘stopped’

puts “#{APP_NAME} is #{status}”
when ‘start’: # Do your thang
when ‘stop’: # Do your thang
when ‘restart’: # Do your thang
end unless %w{start stop restart status}.include?

By Peter Cooper / September 25, 2006

It’s not a common pursuit but some developers would like to look through the source code to Ruby itself. It’s a great way to start if you ultimately want to get involved with helping develop Ruby itself, but it’s heavy stuff. Mauricio Fernandez, however, has put together a brief guide to the different source files you should read relating to different elements of functionality within Ruby. Experts only. Read More

By Peter Cooper / September 23, 2006

Metaprogrammingfun

Ola Bini, a Ruby developer from Stockholm, Sweden, has put together an excellent article about Ruby Metaprogramming Techniques. He looks at singleton classes, writing DSLs, dynamic class and module generation, fun with method_missing, method-pattern dispatchers, method replacement, null object refactoring, instance variable introspection, Procs and blocks, and bindings. It’s heavy stuff but presented in a surprisingly light and interesting way. Read More

By Peter Cooper / September 23, 2006

Mysqlanalyzerplugin

Bob Silva has put together a fine MySQL query analyzer plugin for Ruby on Rails. It uses MySQL’s EXPLAIN command to analyze all of the different SQL queries made by your Rails application (or, more accurately, by ActiveRecord!) and gives you the information you need to add better indexes (or add any extra indexes at all!) and could help show where a little custom SQL could silence a squeaky wheel. Read More

By Peter Cooper / September 21, 2006

Eric Hodel has looked at a new feature provided by Ruby 1.8.5 called Process::setrlimit. It makes it easy to limit the memory usage of your Ruby processes.. ideal if you’re experiencing memory leaks! Eric shows an example that’s as simple as adding this to your application’s environment.rb file:

Process.setrlimit Process::RLIMIT_RSS, 1024*1024*150, Process::RLIM_INFINITY

Of course, this isn’t a Rails only feature. Read More

By Peter Cooper / September 21, 2006

This month’s “Troll of the Month” is Ruby vs Python – why no-one should care by Cynos. Cynos touches on a point I’ve seen raised a few times in the past month.. namely that Python and Ruby are similar and are, supposedly, ‘converging’. He argues, therefore, that both communities should stop evangelizing to each other. Despite a reasonable, if baited, argument, however, the comments quickly turn into a pointless flamewar:

- and when you unfairly malign nice people because of the programming language that they use [...] that I can only assume you’re a born again Ruby user

- I don’t really care about either language, but if I had to pick one I’d go with Python. Read More

By Peter Cooper / September 20, 2006

The Rails Forum has announced a Rails Tutorial contest:

To celebrate our 500 member mark obtained yesterday, and in the interest of getting more good Ruby on Rails tutorials, Rails Forum is giving away an iPod shuffle to the best tutorial written between now and 12:01 AM GMT on November 1, 2006!

What do I need to do to enter?

Simple! Just post a tutorial in our Ruby on Rails Tutorials forum between now and the time above, and you’ll be automatically entered!

To learn more, read the announcement post. If any good tutorials end up on there, I’ll be posting references to them here on Ruby Inside.. Read More

By Peter Cooper / September 20, 2006

Mnlrb

Mr. Neighborly (a.k.a. Jeremy McAnally) has just released his “Humble Little Ruby Book“, a Ruby book available in both e-book (PDF) and print formats. The book is a bargain basement $5 as a PDF or $10 in print! Much like Why’s Poignant Guide, the Humble Little Ruby Book is written in a conversational style and has a real ‘atmosphere’ about it. It covers the Ruby language from the very basics through to creating useful and functional programs. Read More

By Peter Cooper / September 18, 2006

Railsforumbuttons-1

Kelli has posted four different Rails buttons on the Ruby on Rails Forum (shown above) that you can use anywhere you like.

In the same spirit, I’ve put together four “Ruby Inside” graphics you can also use where you like. They’re not ads for this blog, so you don’t have to link back to here with them (though you can if you like!) but they’re more to demonstrate that Ruby is in action on whatever you use them against. Like “Intel Inside”, etc.

Big JPEG:
Rubylogo

Big PNG (transparent – will work on any color background):
Rubylogo

Small JPEG:
Rubylogosmall

Small PNG (transparent):
Rubylogosmall Read More

Recently Popular Posts