Skip to content

Tag: ruby

Calculating a Percentage in Ruby Elegantly

In a recent project it would have been handy to write some ruby code which looked like: View the code on Gist. When searching through the ruby libraries there wasn’t any indication it existed. Wanting to avoid a class method – a quick google turned up this StackOverflow post – Calculate percentage in ruby. It presents a nice solution to the problem (one I should have thought of!). Create a class called Numeric and add the method to it: View the code on Gist. Now a number object has a method called percent_of which takes itself and another number as an argument to…

Using Ruby to Recover JPEGs from a Forensic Image

This is the second post in a series investigating different programming languages applied to a forensics recovery problem. More detail about the problem can be found in Using Go to Recover JPEGs from a Forensic Image. The code is available on GitHub. Continuing from the last post the next language I looked at was Ruby. As a brief recap, the problem was to recover 16 JPEG files from a forensic image which had been zero wiped before they were taken. About Ruby Ruby is a language that was popularised by the web framework Ruby on Rails. It can be best surmised by the quote…