Ruby is from objects, Perl is from procedures

Perl has had objects for quite a while now, decades even, but you can’t get away from the fact that OO is really just a bag-on-the-side of Perl 5.  This can be a Good Thing sometimes, actually, because it means that well-written code can be used objectively or functionally.

Still, though, Perl 5 is fundamentally not OO at it’s core and all the magic exists in bless().  Ruby (and many others, too many to mention) are object oriented from the ground up.  But what does that really mean?

Continue reading

This is the first part of what I hope will be a pretty useful set of tutorials for those moving from the world of Perl in to Ruby. For the overview of topic I hope to cover in this series you can go back and look at the “Overview” page. In this first part I want first to talk about how Perl and Ruby are similar and then go over some of the most visible differences.

Continue reading

I originally gave a presentation with this same title at the February 2012 ut.rb meeting.  Although it was focused at the Perl programmers that were present at that meeting it was so well received I’ve decided to spend more time on it an develop it in to a series of blog posts.

Of course this is meant to give Perl programmers a foothold in a new language but it is also useful for anyone coming in to the language from somewhere else.

My Perl credentials

I started developing in Perl in 2000 and was a full-time Perlista from 2000-’07 using versions 5.005 to 5.6, but I’ve never used the Perl 6 series.  My first gig was doing financial code for a credit-card processing company, then I moved on to start a web site ( that eventually went to many tens-of-millions of daily page views on Perl code I wrote.

Overview of what’s on tap

In this series I plan on covering:

  • Part 1: basic similarities and shared conventions. Differences between use of semicolons, and parenthesis.
  • Part 2: Bagging on Perl’s OO system.  Objects and methods under Ruby.  Symbols.
  • Part 3: Perl sigils counterparts in Ruby.  New meaning of $, @ and @@.  Constants in Ruby.
  • Part 4: String interpolation, deliberate/implicit returns on methods.
  • Part 5: Bang (!) and Boolean (?) methods.
  • Part 6: blocks (very basically).
  • Part 7: bonus Rails-specific content: method_missing() and “magic methods”.

Check to see that you’re not trying to do a synchronous call cross-site. And if you’re doing PhoneGap chances are the majority of calls you’re doing are cross-site.

"async": false,

..probably needs to be changed to “true” or removed altogether. If you really need cross-site async JS you may look in to <a href=””>Google JSONP</a>.

At my day job we have reports that are emailed out at 3AM every day, and the people who get them need them by, like, 9AM. Usually they work but for a number of reasons they occasionally will belch and I wouldn’t know until after the fact.

When that happened I would “hear about it”, and I generally just sucked it up and promised to fix whatever problem it was. One day, about 9 months ago, I had the brainwave that “I wish there was a site that would tell me when email didn’t get sent.” It was an awesome idea that was so cool I promptly forgot about it for almost a whole year..

A few weeks ago after having no problems, I once again “heard about” an email not going out decided to be proactive and build the system I had thought of 3 quarters before, and that system is Mailping.

So what is it? In a basic sense it is a incoming mailbox with filters and rules and if those filters/rules are or are not satisfied you will receive a notification.

So in my case it’s like this: I set it up to watch for an email with the subject line “X” between the hours of “Y” and “Z”. If that email comes through then great, but if not I have the system alert me that something is not right. It could also work the other way, where it can send you an email if if DOES receive a certain email. Whatever you want.

It can also ping a web site with a webhook sort of thing. Bitches love webhooks.

You can start using it now on your own project, anywhere you want to check if email is being sent. I’m already using it daily to make sure the automated email at my day job is working.

Plus, if you wanted to “think out of box” you could use the webhook functionality to trigger actions via an email.

Update, August 2013: The ideas here have been turned in to a gem!

For the last few days I’ve been use Rails’ built in JSON facilities to build API capabilities in to an existing app. Rails makes this easy so kudos, etc, blah blah. Seeing as how I need to test these features I was following a Test First approach and since a JSON API is basically a web-request in drag I decided to use Cucumber and Rack::Test. I wrote a lot of tests like:

Continue reading

Are you having an issue where ActiveRecord is insisting a column in an integer even when MySQL says it is a decimal?

Check the definition of the table in Mysql, chances are you have a decimal column with no decimal “scale” set.

By default, if you don’t tell Mysql ho many decimal places to use it will have none, and ActiveRecord will then simply interpret that as an Integer.

Update you column with a migration like this:

change_column('table_name', 'colun_name', :decimal, { :scale => 2, :precision => 10 } )

When /^I reload the page$/ do
# puts "DEBUG - The page for #{current_path}"
case Capybara::current_driver
when :selenium
visit page.driver.browser.current_url
when :racktest
visit [ current_path, page.driver.last_request.env['QUERY_STRING'] ].reject(&:blank?).join('?')
when :culerity
raise "unsupported driver, use rack::test or selenium/webdriver"

By default, when using celerity and celerity, there is no handler for file downloads. If your action in your scenario results in being served a file with a mime type you don’t understand it will end up being unceremoniously lost.

You can’t read “page.body” because that will return the page you are on, not the file you want to download.

You have a link to the action that will result in the file getting served to you:

When /^I press "([^"]*)" and download the file$/ do |element_id|

@file = page.find_by_id(element_id)


That will read the results of your click in to the @file variable that you can then parse in later steps.