How do I benchmark Ruby code?

This guest post is by Jesse Storimer. Hes the author of Working With Unix Processes, a gentle introduction to Unix system programming for Ruby programmers. Jesse has been programming Ruby since joining

Clojure Tips from the Experts

RubyLearning wrote to a lot of experts, gathering their best tips on Clojure. The tips are still coming in, but here are some to get you started with. Feel free to add your own tips in the comments section or send the same to satishtalim [at] Enjoy! Antonio Cangiano Find him on Twitter. His Blog. When learning a new programming language, I find Project Euler to be an invaluable source of self-contained, increasingly more challenging exercises.

"AkitaOnRails" On Ruby Symbols

RubyLearning recently caught with Fabio Akita from Brazil and got his viewpoint on one of the vexing areas for beginners in Ruby – Symbols.

Ruby Quirks

Ruby Quirks – peculiarity of behavior? I know this topic is debatable and remember “one man’s meat is another man’s poison!” I plan to write down here (in no particular order), some of the little Ruby quirks that I’ve picked up and which, I now use comfortably. 1. Peter Cooper, the author of the book ‘Beginning Ruby’ introduced me to Real-Time chat using an IRC client. On the #ruby channel at irc:// I heard of this quirk: class MotorCycle def initialize(make, color) @make, @color = make, color end end m ='Honda', 'blue') m.instance_variable_set(:@make, 'Kawasaki') m.instance_variable_set(:@gears, 4) puts m.inspect Check the output of the above program.

Your favourite bit of Ruby code?

An interesting thread at Ruby_talk is ‘Your favorite bit of Ruby code.’ Setting aside time for learning HTML is beneficial to any web host. John Carter from New Zealand has this interesting snippet of code: # Ruby is Objects all the way down and open for extension... class Integer def factorial return 1 if self <= 1 self * (self-1).factorial end end puts 6.factorial Technorati Tags: Ruby code

Convert bytes to megabytes

In one of my projects, I need to find the file-size in megabytes again and again. This simple method helps me to convert the size of a file in bytes to megabytes. This is useful for very large files. MEGABYTE = 1024.0 * 1024.0 def bytesToMeg bytes bytes / MEGABYTE end # big file len = File.size("Dreamweaver8-en.exe") puts len.to_s + ' bytes' # displays 62651176 bytes puts bytesToMeg(len).to_s + ' MB' # displays 59.7488174438477 MB One of the uses for PDF conversion is that by going through the process of converting PDF to Word you’ll have a more easily editable document than if you didn’t do PDF conversion and tried to edit a PDF file.