Articles Index
Spotlight on Gems: Dynahash
The dynahash gem allows you to access hash members as if they were attributes.
Quick Tip: Last Result in IRB
There's a really quick way to get the result of the last expression evaluated in IRB.
Mechanize Error: Mechanize::UnsupportedSchemeError
The error Mechanize::UnsupportedSchemeError is raised when Mechanize tries to fetch a page using an unsupported protocol scheme, such as ftp or gopher. Mechanize supports only the file, http and https schemes.
Error: "Mechanize::RobotsDisallowedError: Robots access is disallowed for URL"
The "Mechanize::RobotsDisallowedError: Robots access is disallowed for URL" error is raised by Mechanize when robots.txt is honored and you have tried to fetch a page forbidden by robots.txt.
Mechanize Error: "Unknown cookie jar file format"
The error "Unknown cookie jar file format" can be raised in one of two places, in Mechanize::CookieJar#save_as and Mechanize::CookieJar#load.
Command Line Tools using Execute
There are numerous libraries to parse command line parameters, but they all involve some sort of API or meta language to define these arguments. The Execute gem skips this step and provides a command line interface for a class with just a few lines of code added. The only catch is that you code must follow a few simple conventions.
Convoluted Constructions: a = 1, b = 2
Given the expression a = 1, b = 2, what will a and b be equal to? What will their types be? Why?
NameError: undefined local variable or method `a' for #
Problem: You encounter an error reading NameError: undefined local variable or method `a' for #
NameError: uninitialized constant Object::Something
Problem: You encounter an error reading NameError: uninitialized constant Something or NameError: uninitialized constant Object::Something (with various class names in place of Something).
Quick Tip: Install Gems Faster
Some larger projects, especially Ruby on Rails, come with quite a bit of documentation. This is good, documentation is good, but the code that processes this documentation (RDoc) into HTML and ri format is not exactly speedy. On slower computers, or with larger projects, the time this takes becomes and annoyance.
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
Problem: You're trying to install a gem and you encounter an error reading no such file to load -- mkmf. This doesn't always occur, only when you're trying to install gems with native C code that must be compiled.
Couldn't find without an ID
Problem: You've encountered the error message Couldn't find Page without an ID while trying to run find on an ActiveRecord class.
undefined method `to_sym' for nil:NilClass
Problem: Seemlingly at random, you've encountered the error undefined method `to_sym' for nil:NilClass, or a similar error message for any method name other than to_sym.
RVM and 'sudo'
RVM is great. However, there may be times where you must run Ruby scripts with RVM as root (or another user) via sudo.
How to Install Git
How to install Git on Windows, Linux or Mac OS X.
Spotlight on RubyGems: The Simple-RSS RubyGem
The Simple-RSS RubyGem provides a simplified interface for reading RSS and Atom documents.
How to Parse Twitter XML in Ruby on Rails
Learn how to parse the Twitter API's XML easily using Hpricot.
How to Install wxRuby on Ubuntu Linux
wxRuby, a GUI toolkit for Ruby which interfaces with wxWidgets, can be installed on Ubuntu Linux with relative ease.
Ruby Best Practices--Making Quick Exceptions
Knowing how to make quick exceptions to catch and tell the difference between several conditions is a Ruby best practice you can't afford not to know.
ShortURL: Use ShortURL for Twitter
Shortening URLs for Twitter is much easier with the one-line interface provided by ShortURL.
Be Notified of New Twitter Updates by IM
Be notified of Twitter updates by IM, using this Ruby script. It's a pain to switch to a Web browser every you want to check your Twitter account. This script solves that by sending you an instant message (IM) using the Jabber protocol when there's something new to see on Twitter.
Ruby Annoyances: Variables Don't Have Type
To many programmers new to Ruby and dynamic languages in general, one annoyance or point of confusion is that variables don't have type.
On 'case' and 'class'
While dynamic programming and duck typing often make it a bad idea to do so, it's sometimes useful to do different things based on the type of a given variable.
A Quick Look: CouchDB
CouchDB is a NoSQL database being offered by the Apache Software Foundation. It's among the most popular implementations of these types of databases.
Interfacing with the Arduino on Linux
How to interface with the Arduino's serial port on Linux.
