I've had this link sitting in my brew pile for some time and wanted to see if I could get it to work with the latest version of Ruby and Rails, but since I've been too busy so far, I wanted to post it anyway in case a reader would find it useful.
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:
Courtenay has come up with an ingenious solution to caching and precaching in Ruby on Rails with memcached. It caches data from database requests, as you'd expect, but you can also put together a special forking method that caches data in advance. Courtenay's suggestion for this is if a user does a search and you cache the initial page of search results, you could speculate the user might progress onto page two of the search, so you can get Rails to precache that data in advance so the next page load is blazing fast.
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.
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)
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.
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:
Chronic is a natural language (English only, at present, I think) time and date parser written entirely in Ruby. It supports a staggering number of different ways of expressing the date and time. For example:
def foo'bar'endmodule Mdef foo'baz'endendputs"should be 'bar': #{foo}"self.dup.instance_evaldoextend(M)puts"should be 'baz': #{foo}"endputs"should be 'bar': #{foo}"
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!
#!/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.
Lucas Carlson comes up with a cute trick to make Ruby feel a little more like a prototyped language by allowing you to define methods on a class in real-time through child objects, like so:
Expat is the recognized big daddy of XML parsing. It's a stream-based XML parser written in C and, as a library, is used for XML parsing functions by many languages. Rubyists have tended towards REXML, however, a more flexible (though infinitely slower) parser. Sam Ruby, however, has come up with some techniques to get Ruby's REXML working with Expat.
After writing a basic routine to print all prime numbers between 1 and 10,000 in Ruby, Pat Eyler found it took almost 3 seconds to complete, and seeked out a way to make it faster. Enter RubyInline (covered previous at RubyInside).. With RubyInline he added a basic C function into the Ruby mix and knocked down the time required to 0.3 seconds.
_why announces a release of a new UTF-8 library (which adds UTF-8 support to Ruby, without using KCODE) by Nikolai Weibull. _why has also packaged it up (unofficially) into a gem to make it even easier to install (not all of us use git). Here's some demonstration code: