Cucumber step definitions with optional arguments

When I am writing cucumber step definitions that pass arguments, not all of those arguments are needed. And I don't want to write a separate step with or without those arguments. The best way to do this is with a non-capturing regex.

Take the following example (in Ruby):

Given /I am logged in as (.+)/ do |user|

What if I don't want to define a user in every scenario? A default user would be great when none are passed. Since the verbiage works without this portion: as (.+), I'm going to do non-capturing regex around it, which looks like the following:

Given /I am logged in(?: as (.+))?/ do |user|

There are 2 capture groups. The first captures the entire string and the second captures the argument I'm trying to pass. I add ?: which defines the first group as non-capturing. The second group remains the same. How I make it optional is by adding a ? (question mark) to the end of the first group.

Now I can hit two birds with one stone like so:

Given I am logged in
Given I am logged in as some_user

Both will match a single step definition. Don't repeat yourself.

May 15, 2015  ·  Permalink

Should you get the new Macbook (2015)?

Answering such a question means understanding why this Macbook exists. The new Macbook, simply put, is filling the gap between the best iPad and slowest Macbook Pro.

UPDATE: I completely glossed over the 11-inch Macbook Air for $899. Which is an even better value if you're upgrading from an iPad. It's faster, supports more storage and is less than half a pound heavier. While it lacks a Retina display, I don't see any reason to get the new Macbook over the similar sized 11-inch Macbook Air.

It's all about upgrade path

It's rocking an Intel Core M processor so you're not getting a huge leg up over anything younger than 2 years. Andrew Cunningham of Arstechnica had this to say:

If you’ve got a 2013 or 2015 MacBook Air, it will be a step down. If you have a 2012 MacBook Air, it’s a step sideways at best.

An upgrade from an iPad makes the most sense. Especially if you've been using one for a few years. If you wanted something as cheap as the best iPad but not as expensive as the latest Macbook Air or Pro, the new Macbook is the way to go. Buying it for any other reason will leave you mostly disappointed.

Should you get one?

No. The 2015 Macbook is the slowest Macbook in the line up by a large margin despite it's Haswell heart. While it does bring you the lightest most portable Macbook with a retina display, you're still better off with a Macbook Air or the entry-level 13-inch Macbook Pro.

March 13, 2015  ·  Permalink

File Uploads with Rails 4, Carrierwave and Google Cloud Storage

You're developing a rails app and you want to upload files. You, of course, are fancy and want to use Google Cloud Storage instead of Amazon's Simple Storage service (AWS) and Carrierwave instead of Paperclip.

Instead of boring with you with prose, I'm just going to send you over to the Stack Overflow answer that gives you the TL;DR on how to accomplish multi-file uploads with Rails 4, Carrierwave and Google Cloud Storage! The answer also includes a link to the rails app demo source code on Github.

More at Stack Overflow

December 14, 2014  ·  Source  ·  Permalink

The web reacts to Facebook's Slingshot app

This following was originally sourced by Bits Blog at New York Times. People are concerned that Slingshot is basically a Snapchat clone, a fair assertion. But I love the analogy used to describe technology clones in general.

"Did you know there are over 150 varieties of Finches? Each slightly different, maybe color difference or a larger beak or bigger wingspan. They came about by iterating on the Finches that came before,” the user wrote. “In fact, that’s how most advancements come about in nature, poetry, art, and yes, even technology. We take what came before and iterate on it."

Not all clones, despite the terminology, are created equal. Personally I prefer innovation by iteration and when a clone does something similar but better, I tend to commend developers. There are no original ideas, there are only better ideas.

June 18, 2014  ·  Source  ·  Permalink

H1Z1 is shaping up to be the zombie survival game we all want

Personally I've never liked DayZ. It is nothing more than a poorly optimized mod. H1Z1 looks to change the landscape and give us a proper zombie survival experience.

Starting in the game's 64-square-kilometer world, you have little more than a fire ax and basic gear, and you must contend with the zombies that stalk the landscape in addition to your health, hunger, stamina and thirst.

The features you'd expect as first class citizens. I'm quite thrilled about this title as I've also enjoyed Planetside 2.

June 15, 2014  ·  Source  ·  Permalink