Welcome to RubyPowered.com™. A place to share information about Ruby- and Rails-powered web sites, products, tips and tools.
 

Ruby contributions welcome

Got a cool tip, trick, or technique? Wanna share it with the world? Sign up for an account, and post new content using the "Create Content" link. Anonymous users are welcome to post comments, which are unmoderated at present.

| | | |

Automate your server backup with Amazon S3 and Ruby

This is a truly cool way to back up your server: use Amazon's S3 online storage service, along with Ruby and s3sync. The author presents an automated script-based solution.

Link

|

XML File generation using REXML

While The REXML documentation is pretty good, I didn't see a nice simple example all in one piece for creating and writing a new XML file by hand, so here's one: (Continued)
|

Taking the MD5 of a binary file

Getting the MD5 hash of a file in Ruby is pretty easy but you need to be aware of one little thing. If you're on a DOS/Windows system and you simply read in the file and pump it through the Digester, things that look like carriage control may not become part of your hash and your MD5 will be incorrect. For example, if you use either File or IO class methods, it might appear to work but you would be oh-so-sad because it really didn't. Imagine taking the MD5 of a Unix shared library, say, libthingy.so. The wrong way to do it would be this: (Continued)
|

Identifying the current method

As with knowing who you are, program-wise, it's also quite handy to know which method you are sometimes. For example, imagine you've created a lovely set of tests using Nathaniel Talbott's brilliant Test::Unit framework. Then imagine you want to include the test case name (which is the method) in some arbitrary output. Here's one way to do it. Create a method called something like iam that uses caller to return the current execution stack, and then parse out the bits you want. (Continued)
Page 1>>