Building a CLI in Ruby with GLI

Typically in Rails apps we use rake tasks as a way to interact with our application through the command line. We're all familiar with running code like rake db:migrate, or custom rake tasks that we create ourselves. There is another way to create CLI programs in Ruby with a very nice interface, ...

In Ruby On Rails By Leigh Halliday January 28, 2016

Leigh Halliday

Skinny controllers through refactoring

Controllers can get out of control. Their job should generally be quite simple. In an MVC framework such as Rails, they should have the job of knowing how to work with the Model in order to get what is needed for the View. In other words, they receive the user input (through params) and determine...

In Ruby On Rails By Leigh Halliday January 19, 2016

Leigh Halliday

Ruby web frameworks which aren't Rails: Cuba, Sinatra, Padrino and Lotus

It’s common for a Ruby developer to describe themselves as a Rails developer. It’s also common for someone’s entire Ruby experience to be through Rails. Rails began in 2003 by David Heinemeier Hansson, quickly becoming the most popular web framework and also serving as an introduction to Ruby for...

In Ruby On Rails By Leigh Halliday December 15, 2015

Leigh Halliday

Jbuilder to AMS - A tested journey

Not everyone is creating a new Rails app from scratch. Most of us have existing ones which may use RABL, Jbuilder, or a number of other options to generate JSON responses. When we're refactoring large and important parts of our app, how can we test to ensure that refactoring doesn't change the ap...

In Ruby On Rails By Leigh Halliday November 30, 2015

Leigh Halliday

Is it nil?

What is actually happening under the covers in Ruby when you ask if a variable is nil? It turns out that it's way simpler than you may think, and it all comes down to object oriented programming and inheritance. You've probably heard it said that everything in Ruby is an object... this includes ...

In Ruby On Rails By Leigh Halliday November 25, 2015

Leigh Halliday

Storing JSON in Postgres

Should you use a Document (JSON) or Relational database to power your website? With Postgres you don't need to choose between them... the answer is to use both! Postgres 9.4 comes with amazing JSON support which gives you the best of both worlds. This article also explores how to use this new functionality from within Rails.

In Databases By Leigh Halliday November 22, 2015

Leigh Halliday

Understanding method missing

In this article we look at how method_missing and respond_to_missing? work by looking at the StringInquirer class of Ruby on Rails.

In Ruby On Rails By Leigh Halliday September 08, 2015

Leigh Halliday

Exploring some string methods

It's important to be able to manipulate strings effectively in Ruby. Here are some details about some code I wrote to convert phone numbers that arrive in all different formats to a standard "555-555-5555" format that an API I'm working with expects.

In Ruby On Rails By Leigh Halliday August 20, 2015

Leigh Halliday

A Stack in Ruby using Linked Lists

A Stack is an abstract data type in programming which has a variety of uses. The basic premise of a Stack is that you can add a new value to the end (pushing), and you can remove the last value off of the end. This is referred to as LIFO - Last In First Out. Today we'll explore how to create a Stack in Ruby using Linked Lists.

In Ruby On Rails By Leigh Halliday July 03, 2015

Leigh Halliday

Weighted Quick Union & Quick Find Algorithm in Ruby

We are going to explore a Ruby implementation of the Weighted Quick Union & Quick Find algorithm. This is an algorithm used to find if there is a connection between two nodes. First we explore the simplest solution and then make it more performant.

In Ruby On Rails By Leigh Halliday June 29, 2015

Leigh Halliday

Showing similar results in Postgres

If you search "trgrams in pstgres" in Google, you'll get results for "trigrams in postgres". To say that is useful is an understatement! Recently at work I wanted to search a table of tags, but I wanted to account for spelling mistakes. Just because the user is 1 letter off doesn't mean I shouldn't give them a meaningful search result. We are going to use the Trigram feature in Postgres to help us achieve this.

In Databases By Leigh Halliday June 25, 2015

Leigh Halliday

Avoid race conditions in Rails with Postgres locks

Earlier this year a programmer reported that he discovered a race condition bug in the Starbucks system which allowed him to essentially have an unlimited giftcard balance. It's obviously a problem that can have some serious financial implications. In this article we explore how to handle race conditions in Rails.

In Ruby On Rails By Leigh Halliday June 16, 2015

Leigh Halliday

CORS in Phoenix

There are some special considerations you have to think of when creating an API that will be consumed by Angular (or any other front-end framework). One of these is security related, specifically around the issue of CORS. This article is about handling CORS in Phoenix.

In Elixir By Leigh Halliday June 11, 2015

Leigh Halliday

Recursion in Elixir

I recently wrote an article on Recursion in Ruby, and this is meant to be its Elixir counterpart. It will provide a way to compare solving the same problems in both languages and a chance to talk about some of their differences.

In Elixir By Leigh Halliday June 01, 2015

Leigh Halliday

Recursion in Ruby

Recursion in computer science is a method where the solution to a problem depends on solutions to smaller instances of the same problem (as opposed to iteration). Let's take a look at how recursion is done in Ruby and how it compares to iterative solutions.

In Ruby On Rails By Leigh Halliday May 26, 2015

Leigh Halliday

Software Development

category-image

Ruby On Rails

category-image

Databases

category-image

Elixir

category-image