Refactoring Rails into Service Objects

One of the things that I dislike about Rails is how some actions feel untestable. Take, for example, the act of grabbing the current user. This is bog-standard code that you’d see in a lot of Rails tutorials and people’s codebases. What I don’t like about it is that the current_user method is not easily testable. Heck, which test file do you put the tests in? ...

October 28, 2013 · 3 min · 529 words · Scott Brown

Where the name 'typicalrunt' comes from

I’ve been asked a few times where the name ’typicalrunt’ comes from, so I thought I’d write the meaning down and also explain why I don’t use my real name. I love learning about the origins of words, so here’s my explanation of my nickname. The handle ’typicalrunt’ is from 1997 when I needed a handle for all of my online activities (at the time, this mainly included online gaming). Typically a nickname is chosen for you through some kind of friendly back-and-forth with friends. This time I chose the name because I wasn’t called any nicknames (this changed in subsequent year, but I’m keeping those names secret). ...

October 26, 2013 · 2 min · 355 words · Scott Brown

Happy Programmers' Day

As a fellow programmer, I would like to wish every other programmer out there a Happy Programmers’ Day. This is a short article, but one that I feel the need to write on a day like today. I really like programming, as it helps me to not only solve people’s organizational problems, but also to bring some critical thinking to whatever is floating around in my head. Earlier this week I read Avdi Grimm’s book, Objects on Rails, and found it to be a refreshing take on how to build an MVC application, albeit on Rails. I very much like Rails but, as a programmer (and hence why I’m writing this article today), I have to admit that I have a love-hate relationship with all frameworks (mostly hate, but that’s just me). I dislike how a framework is doing things for me, because I enjoy figuring out how technology works. It seems that in this day and age, people like to build MVPs using the latest frameworks just to quickly get something up and making money. From a business point of view, I 100% agree and understand, but I’m also a programmer at heart and there is a very loud voice that yells at me whenever I use a framework. This is a voice that wants to build things properly so that scaling and readability are first-class citizens, not something relegated to “phase 2”. ...

September 13, 2013 · 2 min · 234 words · Scott Brown

Preserving Memories the Right Way

I was working away happily this week on my Ansible scripts, testing them with Vagrant VMs when all of a sudden Vagrant wouldn’t create new VMs for me. I discovered the problem was that the 256GB SSD on my laptop was filled with photos and videos. I regularly take photos, with both a camera phone and a DSLR but, ever since my daughter was born, my wife and I (mostly my wife cough cough) have been taking an enormous amount of pictures. It wasn’t until my hard drive space was at 90% that I realized that I have a data growth problem on my hands which is going to cost me an increasing amount of time and money to manage correctly. ...

September 7, 2013 · 2 min · 316 words · Scott Brown

Making Ansible and Vagrant Play Nice on OSX Mountain Lion

Here I was learning the ins and outs of Ansible so that I can provision my Vagrant installation with a modicum of scripting, when lo and behold it decides to abruptly fail on me. Searching around the Interwebs using the error I received didn’t help much, except to tie bits and pieces together. So I’m writing this in case (a) I ever forget the issue again, or (b) someone else gets tripped up on this. It isn’t in Ansible’s docs, so I’m guessing they are a Linux-only shop. ...

August 30, 2013 · 1 min · 200 words · Scott Brown

Making Fool-Proof Dynamic SQL

I was reading the MyBatis docs as a refresher and in the Dynamic SQL section I noticed that they are still struggling with the WHERE clause if all elements are conditional. Take this example from the docs: It says that if none of the conditions are met, you will end up with an invalid SQL statement of SELECT * FROM BLOG WHERE or in another case SELECT * FROM BLOG WHERE AND title like #{title}. Both of these are a common problem when trying to build a dynamic SQL statement. ...

August 27, 2013 · 2 min · 268 words · Scott Brown

Beware of Incorrect Usage in Accessor Methods

When people have looked at my code, specifically my test code, one of the most common things they ask is why I test my getters and setters. They see this as a weird thing to do, but I tend to be a very paranoid defensive programmer, so I like to ensure that my getters and setters aren’t actually modifying anything. “That is paranoid, Scott” you proclaim, and try to enlighten me on all the code that doesn’t modify accessor methods. But I’ve been burned by this assumption often, and a simple and stupid unit test ensures that the code is adhering to my assumptions. It’s quick and painless. ...

August 26, 2013 · 3 min · 512 words · Scott Brown

Adding Font Awesome to your project manually instead of via a gem

Font Awesome is truly a work of art. Those guys should be charging for this product, but I am grateful that they are not. Today was the day that I finally got fed up using the font-awesome-rails gem. On Rails 3 it was excellent and it was just a bundle install away, but with Rails 4 it just stopped working. Others have had issues with it and their response was that it was a sass-rails problem, and not theirs. Every time I used their gem with a Rails 4 project I would manually patch their gem to make it a proper SCSS file font-awesome.css.scss instead of using the old style font-awesome.css.erb that they use. However, whenever they release a new version of their gem mine stopped working until I patched it again. ...

August 6, 2013 · 2 min · 335 words · Scott Brown

A Response to "Crushing the Imposter Syndrome"

I came across a fantastic article on Hacker News called Crushing the Imposter Syndrome and I think everyone should read it. I have an addendum to make to it as it relates to my life and what I have seen in the IT industry over the past 16 years. Please go and read the article now, then come back and read this. Back? OK, let’s start. I see imposter syndrome happening in IT quite a lot, but limited to a select group of people who really try to do a good job (e.g. solving a large problem). This is in contrast to the people in IT that are in it purely for the money and power or to sell something and then forget about that customer in the attempt to get a new customer. It possibly happens as much in other industries, but I don’t know since I have only existed in IT (or the IT department of other industries). One big cause of imposter syndrome is the pressure put on IT applicants when searching for a job. ...

July 29, 2013 · 9 min · 1804 words · Scott Brown

Canada's Failing Economy

I was reading a brilliant article titled “Post-Scarcity Economics” by Tom Streithorst and it resonated with me about our failing economy in Canada that I needed to write an article on it. Although the article is set against the US economy, much of what happens there also happens in Canada, albeit to a less extent 1. Please read the entire article (warning: it is lengthy) first, and I will be pulling sentences out and applying my experiences in Canada to them. ...

July 16, 2013 · 8 min · 1648 words · Scott Brown