FAQ for 2013

This year I decided to collect and bundle all of the questions I am asked on a regular basis, whether it is through mentoring or conversations with other developers. What is your favourite IDE? I don’t have a favourite IDE because I don’t use one (caveat below). I develop code in Vi/Vim, which is a terminal-based text editor that has a lot of features hidden away that could turn it into a full-fledged IDE if one chose to use it that way. The reason I stuck with this editor is that I found myself helping numerous clients who had remote servers that I needed to login and perform work. If one only has experience using a GUI text editor or IDE, then being confined to a terminal environment will feel like a prison and work performance will slow to a crawl. Regardless, I stuck with the practice of using Vim even after the engagements ended and I have been quite happy ever since because it means that I can code anywhere that has an SSH terminal application. It also means that I can make changes to any text file quickly and with less keystrokes. ...

December 7, 2013 · 7 min · 1305 words · Scott Brown

Refactoring to Decouple HTML, CSS, and JS

After reading Tips for how to decouple your HTML, CSS, and JavaScript, I was struck by how stupid I’ve been marking up my HTML for CSS and JS events. I started rewriting my latest project using these principles and they’ve really helped create a separation of concerns. To illustrate how this has helped, I was coding up a quick administrative interface to CRUD some service model classes in my project and I started to really hate the UI/UX I chose. I decided to switch to a table since the data is more tabular in nature and I was quite please to see that none of the JavaScript functionality broke. ...

October 29, 2013 · 3 min · 490 words · Scott Brown

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