On testing in production

Interesting quote from a piece over at Software Development Times:

We realized that testing in a lab behind a firewall is kind of ridiculous in the web era. You can’t replicate the Internet behind the firewall. Add in dependencies on third-party services and it’s impossible. The only real true way of testing today is in production. Seventy percent of our load testing is done in production right now.

Building production-like testing environments is a complex process and depending on the application is more work than its worth, both in time and dollars.

September 03, 2016  ·  Source  ·  Permalink

Make your Javascript pure

Jack Franklin for A List Apart:

You get referential transparency for free when following the rule of declaring all your data as inputs, and by doing this you eliminate an entire class of bugs around side effects and functions acting unexpectedly.

This should apply to any language where you're building classes with functions.

June 24, 2016  ·  Source  ·  Permalink

The Good Remote Worker: Work rarely speaks for itself

A common fear held by both remote workers and teams collaborating with them is having no idea what they're doing or why they're doing it. A fear that, when left unchecked, diminishes the value of actual work being done.

In this part I'm going to discuss why just doing work isn't enough and how a remote worker can avoid being forgotten by their team.

Continue reading...

June 03, 2016  ·  Permalink

The Good Remote Worker: This thing on?

Having worked with teams consisting of 100% remote, 100% in-person, and folks who do a little of both, I can understand why many organizations have a hard time with remote collaboration. This series will cover all the things I learned over the years collaborating remotely. In this first part, I talk about video conferencing. Often the most painful aspect of remote working.

Continue reading...

April 16, 2016  ·  Permalink

Why I love Trump

Ricky Jones for the Courier Journal:

I love Trump, but not for the same reasons David Duke pulls him to his bosom. I love Trump because with every win he exposes the GOP and America for what they are. Trump doesn’t vote for himself – Americans do. Republicans and the country both need to deal with that truth.

March 13, 2016  ·  Source  ·  Permalink

Use a regular expression to match a string up to a given character

Often I run into a string where all I want is to match everything up to a given character. So given the following test string:

This is my string with a pipe | and everything after it is stupid.

Using Ruby as my reference language, I might do something like this in an interactive ruby session (aka: IRB) or on Rubular.com:

str = 'This is my string with a pipe | and everything after it is stupid.'

Which would produce the following in Ruby:

"This is my string with a pipe "

Lets break down the different parts of the expression ^.*(?=\|) and what they're doing:

  • ^ start at the beginning of the string
  • .* match anything from the current position
  • (?=\|) only if followed by a pipe character

The last part of the expression is what's known as a positive look-ahead (?=). Using a look-ahead is like attaching a condition to an existing regular expression. I'm telling my expression to return the match only if it's followed by characters matched by an additional expression.

For a more comprehensive dive into look-around functions, head on over to Regular-Expressions.info. Also feel free to play with my example on Rubular.com.

As always, use regular expressions responsibly.

November 20, 2015  ·  Permalink

Clean up empty upload directories created by Carrierwave

Carrierwave doesn't clean up empty directories when you delete a record with an existing upload. It deletes the file, but not the containing directory. That is a task you can handle with an ActiveRecord callback.

Let say there is a model called 'Post' that you can attach an image to. The code would look like the following:


class Post < ActiveRecord::Base
  mount_uploadeder :image, ImageUploader

  after_destroy :delete_empty_upload_directory

    def delete_empty_upload_directory
      FileUtils.rm_rf(Rails.root.join('path', 'to', 'your', 'uploads', self.id.to_s)) if self.image

Simple, nice, and easy.

November 11, 2015  ·  Permalink