Category Archives: Ruby

Convert integer to Excel-like column name

Problem Given an integer, how can you get an Excel-like column name? In other words, how can you write the column_name method such that the following spec passes? Solution It turns out that in Ruby, this is quite simple with … Continue reading

Posted in Ruby | Leave a comment

Create file with fractional megabyte size

Problem I was looking to create some files of arbitrary size. While it was easy to find some solutions, they only created files with in whole megabytes. They did not allow creating partial megabytes – ex 49.5MB. Solution I took … Continue reading

Posted in Ruby | Leave a comment

Checking if a number is within a range

I had been looking at a StackOverflow question where part of the solution required checking if a number was within a range. Seeing the answers to this and other questions, I learned a couple of new, more Ruby-like, ways to … Continue reading

Posted in Ruby | Tagged | Leave a comment

Modify each word except the first

Problem I had a string representing a CSS property that needed to be converted to a DOM style object property. For example, the string: “font-weight” had to be modified to: “fontWeight” Basically, two changes needed to be made to the … Continue reading

Posted in Ruby | Tagged , | Leave a comment