» tagged pages
» logout

sorted by: recent | see : popular
Content Tagged with tricks + Elsewhere

Converting Ruby 1.9 Bytecode to Python

rubytopython.jpg

Never one to let us down on the ingenuity front, Why The Lucky Stiff (author of the Poignant Guide and creator of Shoes) is busy working on a system that can convert Ruby 1.9 bytecode to Python bytecode (and from there into regular Python by way of Python’s decompilation facilities). It’s exactly the sort of thing that could take off with more eyes looking at it, and Why has made it available on GitHub. This technique isn’t likely to unite Python and Ruby in any deep and meaningful way (to the point of a shared interpreter), but the research and experiments involved are worth a try.

Ruby: Inside Ruby

Using Amazon’s Web Services for Spidering the Web

aws.png

Robert Dempsey has written a code-packed article for Amazon Web Services’ “Developer Connection” site called Using Amazon S3, EC2, SQS, Lucene and Ruby for Web Spidering. It’s a bit of an epic and covers using a multitude of Amazon Web Services together (namely the S3 storage system, the EC2 “Elastic Compute Cloud”, and the Simple Queue Service), with Ruby acting as the glue that holds them all together. This could be of great interest to anyone who wants to put together large-scale crawlers using on-demand hardware and services.

As an aside, I’m interested in all interesting Ruby-related Amazon / S3 / EC2 articles and links for a future “list post,” so if you have any recommendations, leave a comment. Thanks!

Ruby: Inside Ruby

Ruby Cheat Sheets

Ruby is an incredibly easy language to learn, but it’s still often necessary to look up something we’ve forgotten. Often this can be done by using Google or using any Ruby books we have on our shelves, but sometimes it’s handy to refer to a simpler set of notes, such as a “cheat sheet.” Quite a few Ruby developers have made cheat sheets for Ruby, and this post attempts to cover the most interesting ones.

The idea for this initial list (Don’t worry, Rails will be covered later on) came from Scott Klarr’s own list. Scott has been quite prolific lately in putting together lists of cheat sheets. Some of his lists are: Apache cheat sheets, MySQL cheat sheets, PHP cheat sheets, and JavaScript / AJAX cheat sheets.

But.. on with the Ruby cheat sheets:

Ruby Cheatsheet (PDF and PNG)

rubycheat.png

This cheat sheet (homepage) covers types, exceptions, expressions, variable types, operators and precedence, constants, regular expressions, predefined / special variables, arguments accepted by the Ruby interpreter, reserved words, and a large collection of Object, String, Kernel, Array, Hash, Test::Unit, File, Dir and DateTime methods. Extremely suitable for printing and/or wall chart use.

Ruby QuickRef (HTML)

rubyquickref.png

I often use this one myself! A ridiculously comprehensive “cheat sheet” created by Ryan Davis covering syntax rules, reserved words, regular expression terminology, class and method definitions, predefined variables and constants, control and logic expressions and formations, exceptions, the standard library, and a whole ton of useful stuff.

Ruby Reference (PDF)

rubycheatsheet.png

More of an extremely brief reference than a truly comprehensive cheat sheet, but still useful, especially for beginners. 5 pages long, so not suitable for printing (Also available to view on the Web at Scribd.)

Cheat: Ruby Cheat Sheets on your Terminal! (Application)

errcheat.png

Not a cheat sheet, but an application (gem install cheat) that provides cheat sheet type reference material on your terminal (from 228 source cheat sheets!) Developed by the great guys over at Err Free.

A Beginner’s Notes (HTML)

beginnersnotes.png

A set of notes made by a beginning Ruby developer as he works his way through a Ruby manual.

Ruby Command Line Parameters Cheat Sheet (HTML)

A simplified list of the command line options offered by the Ruby interpreter.

Strftime Parameters (HTML)

A handy guide to the formatting parameters accepted by strftime. I commonly have to look these up myself!

Ruby: Inside Ruby

Merb + Shoes = Interesting Web / GUI App Crossovers

Shoes Meets Merb: Driving a GUI App through Web Services in Ruby by Gregory Brown and Brad Ediger leads us on a six page tutorial extravaganza through not only building a cross-platform GUI app (namely, a pastebin of sorts) using WhyTheLuckyStiff’s Shoes system, but using Rails-killer Merb as a backend for storing the data. It’s an impressive enough effort that Why himself has linked to it and added a few notes of his own (including the provision of a much better illustrative screenshot - as used above).

In related news, yesterday Why announced the launch of a new version of Shoes, known as “Curious.”

Ruby: Inside Ruby

How To Develop Computer Games In Ruby

In the first of a series, Andrea Wright looks at how to create games using Ruby. The series isn't a tutorial level set of articles, but instead a walk through some of the major libraries and technologies you can use along with some code examples. In this first edition, Andrea looks at Ruby/SDL, Rubygame (inspired heavily by PyGame, a significant Python game development library) and RUDL.

Ruby: Inside Ruby

How to Build a Drawing Application Using Shoes, OS X and Ruby

Shoesdemo
Will Larson has put together a great "from start to finish" tutorial on building a graphical application on OS X using Shoes, the cross platform GUI library by whytheluckystiff. It goes right from explaining what Shoes actually is, through to its installation, some basic examples, and then to building a basic graphics-focused application.

Ruby: Inside Ruby

Shoes Roundup: Ruby GUI App Development Goodness

Shoeswindow-1

Just over a month ago I mentioned the release of "Shoes", a new Ruby library for creating "Web-like desktop apps" by Why The Lucky Stiff. Shoes provides a somewhat platform-independent way of creating desktop applications easily. Now that Shoes is several weeks old, it's worth pointing to a few resources and tutorials that will come in useful if you decide to start building Shoes-powered apps:

Running with Shoes - A Mini GUI Toolkit by Juixe: A great walkthrough building a simple Shoes application.

Cut Holes in Shoes and Get A Mask by Why The Lucky Stiff: A demonstration of using masks to create fancy text graphics.

Running with Shoes - 2D Graphics and Animation by Juixe: A look at drawing shapes in a Shoes app, such as lines, ovals, and rectangles, along with simple animation techniques.

Source code for a basic text editor by Why The Lucky Stiff: Source for a bare bones editing tool.

Yeah, Shoes Has Just a Few Simple Controls by Why The Lucky Stiff: A demonstration of a few of Shoes' widgets.

Mashing In Some Graphics by Why The Lucky Stiff: A code example of drawing rectangles within a Shoes application.

Hypershoes by Why The Lucky Stiff: A look at how to build a "book reader" program in Shoes and how Shoes' concept of URLs helps.

Ruby: Inside Ruby

How to Build Simple Console Apps with Ruby and ActiveRecord

Gregory Brown has put together a great four-page tutorial on how to build a database driven console application using Ruby and ActiveRecord (no Rails needed!). As well as delivering what the title suggests, Brown also looks at some neat Ruby techniques for structuring applications in general (such as using modules and module_function). The end result is an app called "EarGTD," a basic time / task management tool.

Ruby: Inside Ruby

Deplate: Cross-Publish Wiki-based Documents to Other Formats

Deplate is a Ruby-based tool written by Thomas Link to convert documents written in wiki-like markup to various output formats. Supported output formats include LaTeX, HTML, "HTML slides", DocBook (which means it can also convert to PDF, and other DocBook-supported output), and plain text.

In addition to being capable of reading various Wiki markup variants, a particularly interesting feature is it also handles rdoc input which is very handy for generating print-ready documentation of your Ruby projects.

To see the results for yourself, various samples of Deplate generated output are available for your viewing pleasure. To get it, you can download the stable version from Deplate project files page or check out its latest development version from CVS.

Ruby: Inside Ruby

Textpow + Ultraviolet: TextMate Powered Syntax Highlighting for Everyone!

Textpow Ultraviolet

Textpow and Ultraviolet are a pair of interesting, new(ish) Ruby libraries that co-operate together to parse TextMate bundles and perform syntax highlighting. Textpow is a library that parses and processes the TextMate bundles (special files included with the TextMate text editor that specify how different types of plain text content should be delimited and colored). Ultraviolet then uses Textpow and performs syntax highlighting either as a standalone application or as a Ruby library.

Currently, Textpow can process syntax (tmLanguage and tmSyntax) and theme (tmTheme) files.. and you can obtain these from the free trial download of TextMate if you don't have them already (although, I imagine, non OS X users might be able to find other TextMate bundles and themes elsewhere, such as the Vibrant Ink theme downloadable from here).

Ruby: Inside Ruby

How to Transfer Files using SSH and Ruby

Matthew Bass has written a tutorial, published by InfoQ, called "Automating File Uploads with SSH and Ruby." It provides an in-depth look into building a small Ruby script that can backup files to a remote machine over SSH using the Net-SSH and Net-SFTP libraries. It goes into quite some depth, and provides source code for a recursive backup script. If you haven't had a dig into the Net-SSH and Net-SFTP libraries yet, it's worth a look to see how the basics work.

Ruby: Inside Ruby

RFaceBook: Ruby library for FaceBook's new API

Facebookplatform

FaceBook, a popular social networking site, recently announced the availability of an API, allowing third party developers to build tools, apps, and systems that integrate with FaceBook and which FaceBook users can use from within their accounts. MySpace users, who are used to copying and pasting crazy blocks of HTML into their profile foxes, will be aware of what a big deal this is.

Hot on the heels of this announcement, Matt Pizzimenti has updated RFaceBook, a Ruby library for integrating with FaceBook, to support various features of the API. It's not something I'm likely to use, or that I fully understand, but the initial response to RFaceBook appears to be incredibly positive, so if FaceBook is your cup of tea, check it out.

(Post fixed.)

Ruby: Inside Ruby

Handshake: Design-by-Contract

Handshake, currently in version 0.3.0, is an informal design-by-contract system written by Brian Guthrie in pure Ruby. It's intended to allow Ruby developers to apply simple, clear constraints to their methods and classes.

Handshake is definitely welcome alongside the ever-increasing number of test-driven and behavior-driven design/development based tools, such as RSpec and test/spec.

Some examples of Handshake contracts (from its documentation):

# An array that can never be empty.
class NonEmptyArray < Array
include Handshake    invariant { not empty? }
end

# An array to which only strings may be added.
class NonEmptyStringArray < NonEmptyArray
contract :initialize, [[ String ]] => anything
contract :<<, String => self
contract :+, many?(String) => self
contract :each, Block(String => anything) => self
end

Visit Handshake project page and Rdoc documentation for more information.

Ruby: Inside Ruby

Twitter Gem: Twitterize Your Ruby Application

Twitter-1

You've heard of Twitter, an online service that allows you and your friends to communicate up-to-the-second by sending short messages. Twitter has built-in features to deliver the updates to your instant messaging account (such as Google Talk) or to your cell phone. Yesterday we covered real-time Flash visualization of RailsConf twitters.

Want to incorporate Twitter functionality into your own projects? Enter the Twitter gem by John Nunemaker. Observe:

# to post an update to twitter
$ twitter post "posting from the twitter gem"

# to see you and your friends timeline
$ twitter timeline

The command line interface is very simple, and configuring it is easy using a YAML file. Of course, it also sports a Ruby API:

twit.update('me got dizzy this time')
# Show your friends' status
twit.timeline(:friends).each do |s|
  puts s.text, s.user.name
end

Use RubyGems as usual to install it:

gem install twitter --include-dependencies

Head on to Twitter gem site for more information.

Ruby: Inside Ruby

Silverlight (and Ruby on the .NET CLR)

Silverlight

At MIX07 a few days ago, Microsoft announced "Silverlight", a new Flash-esque .NET-based platform for delivering "media experiences" and "rich interactive applications" on the Web. It's interesting, and some people seem to think it's going to revolutionize the Web, but that's not why we're interested in it at Ruby Inside.

The most interesting part of the Silverlight announcement is that it's based on a subset of the CLR (Common Language Runtime) from Microsoft's .NET platform. The .NET CLR has become a common target for programming language runtimes recently, but Microsoft has officially announced C#, Javascript, VB, Python and Ruby support for Silverlight's CLR. Microsoft are also adding new features in a system called the DLR (Dynamic Language Runtime) to bring more dynamic features (as required by Python and Ruby) to the CLR. InfoQ has more information on this, in terms of Ruby.

What all of this means is that there's baked-in support for Ruby in what could be one of the biggest runtime environments on the Web in the next few years, and this can only be a good thing for Ruby. Jon Udell sat down with John Lam (the creator of RubyCLR) and talked about the DLR, Ruby, and how the whole caboodle works / will work.

Let's cross our fingers and hope this isn't ActiveX all over again.

Ruby: Inside Ruby

Ruby Cheatsheet

Rubycheat

Cenophobie has created a Ruby Cheatsheet available in PDF and PNG formats. It's a little old (not out of date) but I hadn't seen it before and it's quite good. It only covers the basic, but is a useful reminder of which methods you have at your disposal on the basic classes like Object, String, Array, and Hash. It also includes a list of the special variables, command line arguments, reserved words, expressions, and so forth.

Ruby: Inside Ruby

How to Schedule Tasks with Ruby

Ilya Grigorik has written a article demonstrating three different ways you can schedule tasks to run using Ruby, including a simple thread based scheduler, a OpwnWFEru based scheduler, and a BackgrounDRB based scheduler. A notable omission is RailsCron, which provides another alternative for Rails users.

Ruby: Inside Ruby

Build a Feed Reader in 26 Lines of Ruby

Feedreader

Ever thought that parsing feeds was a complex task? Not in Ruby! Using the Feed Normalizer library (a wrapper for other feed processing libraries), Ilya Grigorik demonstrates how you can create a complete RSS / Atom feed aggregator in 26 lines of code, including renderer!

Ruby: Inside Ruby

7 Cool New Ruby Snippets

I've stumbled across several great snippets of Ruby code on the Web in the past few weeks, and rather than bore you with a post on each one, here's a whole collection at once:

1. RSS Twitter Bot - A short Ruby script that will read an RSS feed and republish it to your Twitter account. This could be useful for livestreaming or getting some sort of commercial presence on there.

2. Check if a number is prime in ONE line of Ruby - A rather mind-boggling technique to detect primes using a regular expression (!)

3. iTunes Database Parser - A short script that reads through your iTunes database and tells you what you like to listen to based on your listening habits.

4. CSV to XML Converter - Short and sweet.

5. Send and receive SMS text messages with Ruby and a GSM modem - I'll admit.. I wrote this one, but it works. You may need to hack the SerialPort library to support your GSM modem, especially if it's not on a usual port. I had to hack the C a little for OS X using /dev/something-weird-here, etc. Hopefully this will get you going though.

6. to_fraction method for Float

7. Create Web site thumbnails quickly with Ruby - Another one of my mine I'm afraid, but again, it works well (so far)!

Ruby: Inside Ruby

Haml 1.5 Released

Haml

Back in September 2006, I posted about a new markup language for Rails templates called Haml. For those who missed it, Haml is a high-level, semantic language that makes it rather hard to make HTML markup errors. It relies heavily on indentation, a la Python, for its structure.

Hampton Catlin has now released a significant new version, Haml 1.5. Along with this comes a great new logo (above) and official Web site. A very easy to follow tutorial is also offered to whet your appetite.

Hampton says that a significant improvement in 1.5 is a feature called "Sass", a new way to define CSS stylesheets in a logical way, along with constants, operations, nesting, and selectors. Full release notes are available.

Ruby: Inside Ruby

Using RubyInline and C To Speed Up Polygonal Point Searches

Evan Weaver had a basic problem to solve:

We need to compute whether a point lies within a polygon. And we need to do it a lot.

Due to MySQL's lacking geometry features, Evan had to perform location searches using Ruby code to find points within certain polygons. Keen for a speed-up, Evan digs out some C code from 1987 and sets about using RubyInline to speed up the whole process. The end result? A 22x increase of speed.

Of particular interest to RubyInline newbies will be the way Evan had to adjust the C code for it to work directly on Ruby objects.

Ruby: Inside Ruby

Embedding Images in PDFs with Ruby

Pdfcalendars

Ilya Grigorik has put together a little tutorial demonstrating how to dynamically create PDF "photo calendars" with Ruby. The calendar aspect might not seem particularly interesting to you, but the tutorial is notable for demonstrating how to easily embed images into PDFs dynamically.

Ruby: Inside Ruby

scRUBYt - Hot, New Ruby Web-Scraping Toolkit Released

Scrubyt

For the past few months Peter Szinek has been giving me lots of tasty tidbits about his forthcoming ScRUBYt Web-scraping toolkit, and now it's finally fully released to the public! Peter describes ScRUBYt as "WWW::Mechanize and Hpricot on Steroids" and this description is pretty bang on.

Process
As well as providing a simple DSL for performing Web actions (clicking links, submitting forms, etc.), one of ScRUBYt's most impressive features is that you can provide it with 'example' data from which it will extrapolate a search pattern and then find any other similar data within the same page. This is demonstrated perfectly by Peter's basic example:

ebay_data = Scrubyt::Extractor.define do
   fetch 'http://www.ebay.com/'
   fill_textfield 'satitle', 'ipod'
   submit
   click_link 'Apple iPod'

   record do
     item_name 'APPLE NEW IPOD MINI 6GB MP3 PLAYER SILVER'
     price '$71.99'
   end
   next_page 'Next >', :limit => 5
end

This code goes to ebay.com, looks for iPods, and then extracts all records using a dummy one as an example. It then proceeds through up to 5 more pages of records, returning them all as an XML dataset.

If this all floats your boat, there's a lot to explore. Start off with the official site and Peter's comprehensive announcement. Peter also has a lengthy tutorial available which makes good reading.

Ruby: Inside Ruby

Writing Your Own Ruby Extension With C

In case the title of this post is giving you deja-vu, we've looked at "How To Create A Ruby Extension In C" before at Ruby Inside. We've also looked at using RubyInline to make the process even faster by not having to write a specialized C extension.

Despite this, Wim Vander Schelden has written such a detailed and interesting guide called "Writing Your Own Ruby Extension With C" that it's a must-read if this area interests you, especially since it goes far beyond what was covered in our previous articles.

Ruby: Inside Ruby

How To Build a DSL (Domain Specific Language) in Ruby

Russ Olsen has been putting together a small series of blog posts about building a DSL in Ruby. The first part dates from October 2006, but the second part has just been released, making it a good double length read. In the mini-series, Russ looks at the motivation for developing a DSL and develops a basic DSL called Potemkin.

Ruby: Inside Ruby

Heckle: Tortures Your Tests For Revealing Confessions

Cmbiz041

Heckle is a great new library from Kevin Clark (though Ryan Davis wrote a proof of concept at RubyConf) that 'torments your tests'. It uses ParseRuby and RubyToRuby to rip your code apart and forces random data into your code (currently it does this for strings, symbols, regexps, ranges, booleans, and numbers) to see how good your tests really are.

Simply, it's fuzz testing for your Ruby tests, and that's a good thing if you want your test suites to be strong and far-reaching.

Ruby: Inside Ruby

How To Build A 5,000,000 Image Search Engine With Ruby, Alexa and S3

Cameraimage

Note: This story actually dates back from May 2006, but I don't remember hearing about it then, and it's tucked down inside Alexa's Developer's Corner.

Using the Alexa Web Search Platform as a source of data, Derrick Pallas put together a search engine using Ruby, RMagick and Amazon S3. With AWSP's data set and CPU cluster he fetched 5,000,000 photos from the Web, analyzed their EXIF info with RMagick , and uploaded them to Amazon S3. The result was Camera Image Search, a search engine that can show you pictures taken with certain cameras or with certain exposure times / focal lengths / etc (for some reason the Manufacturer drop down does not appear to work, but other fields do).

This is an impressive demonstration of using the CPU power and mammoth data sets provided by Alexa and Amazon to put together something that would otherwise be out of the reach of the independent developer, and getting the full instructions to how he did it is great too.

Ruby: Inside Ruby

Yahoo! Video Library for Ruby Released

Walter Korman has released the first version of a Yahoo! Video library for Ruby. All it takes is a gem install yahoo-video and some simple code like this:

require 'rubygems'
require 'yahoo-video'

# your application id for use with the yahoo search services.  you can
# get one at http://api.search.yahoo.com/webservices/register_application.
APP_ID = YOUR_APP_ID_HERE

query = ARGV[0]
print "Running a video search for '#{query}'...\n"

client = YahooVideo::Client.new APP_ID
request = YahooVideo::SearchRequest.new :query => query
response = client.search request

As Walter points out, this gives Ruby the distinct honor of supporting the trifecta of video search services: Yahoo! Video, Google Video, and YouTube.

Ruby: Inside Ruby

Under The Hood of Rails' 'find' Method

Jamis-Find

Jamis Buck has put together a cool series of articles about ActiveRecord's find method as used in Rails. He goes into a lot of detail about how find and its related methods work in terms of the internals of ActiveRecord. Jamis' explanations are not only useful for Rails developers, but for anyone interested in patterns and how to structure code in Ruby. The Rails team don't always do everything the 'best' way, but it's usually tight, well developed code you can learn a lot from.

In the first installment, Jamis just presents a basic introduction to his series.

In the second installment, he leaps right in to the details of find and its child methods, find_from_ids, find_every and find_initial. If you want to see how the find methods put together the correct SQL queries, it's a must read, and it takes away a lot of the 'mystery' of the black box that is ActiveRecord.

In the latest, third, installment, Jamis looks at dynamic finders (e.g. find_by_username_and_password and similar).

Hopefully Jamis will keep posting stuff like this because it makes fascinating reading.

Ruby: Inside Ruby

A Basic Prolog Implementation in Ruby

Ruby genius Mauricio Fernandez has been playing with an attempt at processing Prolog using Ruby found on a Japanese coding site and has come up with tiny_prolog.rb.

require 'tiny_prolog_ext'

# rules
# read as "X and Y are siblings if Z is the parent of both"
sibling[:X,:Y] > 1 sibling["Erica", "Sally"]

If you know what Prolog is, or you have an interest in micro-languages and Ruby, it's well worth a read as Mauricio looks into solving problems using logic that Prolog was designed for.

Ruby: Inside Ruby

How to Build Complex Composite Images with Ruby and RMagick

Montage

Corban Brook presents a step-by-step guide to producing 'great looking collages' using Ruby and the RMagick graphics library. Rather than be stuck with a dry picture-by-picture view, Brook uses RMagick to great effect to produce a complex, dynamic image that looks as if it were put together by hand. If for nothing else, this is a great look at some reasonably advanced RMagick code and a great way to learn about a few of the more arcane methods it offers.

Ruby: Inside Ruby

SimpleConsole - A Ruby Framework for Console Applications

Simpleconsole

I think t0fuu has hit upon gold with SimpleConsole, his new Ruby framework for console applications. Imagine Ruby on Rails, but entirely for command line scripts, and that's SimpleConsole. It has automatic options parsing, before and after filter support, has logic and view separation, and a routing system. It's real thinking out of the box, and with more work it could be an incredibly powerful and productive way to knock up quick scripts for the command line.

Ruby: Inside Ruby

Rb-AppScript: Get AppleScript-style functionality in Ruby

Rb-AppScript is an event bridge between Ruby and OS X that allows you to get AppleScript-esque control in OS X. The Appscript creators claim Appscript is a 'serious alternative' to AppleScript and it certainly looks good. Check out this example:

AS.app('TextEdit').documents[1].paragraphs[1].get

The equivalent AppleScript?

tell application "TextEdit"
    get paragraph 1 of document 1
end tell

Appscript provides the system to perform remote procedure calls to OS X applications, converts values between Ruby and Apple classes, and allows developers to get full use out of OS X while still using Ruby's object oriented environment.

Ruby: Inside Ruby

Generate your own Ruby Gems More Easily

The eminent Dr. Nic Williams has put together a useful generator that makes it a lot easier to construct your own gems. It's an ideal script if you've never put a gem together before, or if you're sick of the repetition involved. Nic tells me that this tool might make its way into the core RubyGems distribution in the future, but it's worth playing with straight away.

Once installed, all you do is run newgem followed by the desired name of your gem, and Nic's generator creates the correct directories and pre-populates several relevant files (for testing, documentation, Rake tasks, etc.). A real time saver.

Ruby: Inside Ruby

Backup - A Ruby Gem that makes backup operations easy

Some user mail from Nathan Murray:

I just wanted to let you guys know I've just released the first version of my Backup Gem. You can read the manual here:
http://tech.natemurray.com/backup/

BackupGem aims to be the easiest and most flexible backup, archive and rotate tool. It’s a beginning-to-end solution for scheduled backups in a clean ruby package that is simple use and powerful when customized.

A configuration as simple as:

set :backup_path, "/var/local/backups/my_old_logs"
action :content, :is_contents_of => "/var/my_logs"

Will compress, encrypt, deliver, and rotate the contents of /var/my_logs. But this is just a taste of the power this gem has.

You can install the gem easily with gem install backup and the official documentation is very complete and full of examples. From what I can see so far, it's a very complete and flexible backup library that you can use to create your own backup systems with a minimum of fuss. Even better that it uses Ruby )

Ruby: Inside Ruby

Accepting a single character from the keyboard in Ruby

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.

Ruby: Inside Ruby

Page 1 | Next >>