Ruby-Tricks

Fast HTML parsing in Ruby with Hpricot

Hpricot

Ruby legend whytheluckystuff has developed a new HTML parser called Hpricot. It's easy to install and use and parses HTML in a liberal fashion. It does, however, require a compiler to install (as it's written in C), so should be okay on Linux and Mac OS X, though not necessarily on Windows (yet).

Read more →

How to create a Ruby extension in C in under 5 minutes

Many coders will reach a situation where developing a C extension makes sense, whether for doing 'heavy lifting', diving into assembly language, interfacing with other C code, etc. Luckily, developing a basic Ruby extension in C is easy.

Read more →

Screen scraping with Ruby

Peter Szinek has announced he's going to write a series of articles on 'screen scraping' with Ruby (more accurately, extracting data from Web pages and other online sources) and has released the first article entitled "Data Extraction for Web 2.0: Screen scraping in Ruby/Rails". He covers four basic scraping techniques, first using regular expressions, then HTree and REXML, then RubyfulSoup, and finally WWW::Mechanize. If you need to process shaky HTML sources from Ruby, read on.

Read more →

Game development in Ruby with Rubygame

Rubygame is a new library that provides ties between the SDL (Simple DirectMedia Layer) and Ruby, so that you can do graphics and sound work from Ruby, ultimately to build games. It's stylized off of the popular pygame, the equivalent library for Python. Unfortunately it currently only works on Linux (and other Unix-like systems) but Windows and Mac users should be in luck soon.

Read more →

Write C code inline with your Ruby code

Ruby Inline is an analog to Perl's Inline::C. Out of the box, it allows you to embed C/++ external module code in your ruby script directly. By writing simple builder classes, you can teach how to cope with new languages (fortran, perl, whatever).

Read more →

The Ruby Source Cookbook

Rcookbook
Inspired by the legendary (amongst Perl programmers anyway!) Perl Cookbook, comes the Ruby Cookbook. It has the equivalent examples from the Perl Cookbook but in Ruby form, of course. The basic sections are mostly complete, although some of the later sections are barely covered yet. Still, if you want to see the basic recipes for dealing with strings, numbers, dates and times, arrays, hashes, file I/O, process management, and so on, it's a cute little resource.

Read more →

Five great tricks with Rails views

Bruce Williams has a great set of articles going on on his blog called "Rails Views". Each one looks at a different aspect of Rails' views and templates system and how you can use it in a cool or different way. You are bound to learn something or come up with some ideas on how to make your views more efficient (I sure have!). Here are some of the recent posts in the series:

Read more →