If you want to save the location of someone, something, or somewhere, you'll need to store its coordinates. In this article we'll be looking at a Point , a singular location with latitude and longitude. We'll see how GeoJSON points should be…| Leigh Halliday's RSS Feed
Making HTTP requests in tests isn't a great idea in most situations... it can slow your tests down, is unreliable, and the API you are making requests to may not appreciate it either. So how do you avoid making HTTP requests in your tests? If you are…| Leigh Halliday's RSS Feed
The reduce function of an Array is one of the most versatile functions in JavaScript. With it you can accomplish a lot of the functions from the Array and Math objects. It's job is to start with an array, and reduce those elements into some…| Leigh Halliday's RSS Feed
Publishing an NPM package with TypeScript has never been easier with the help of tsdx , a wonderful package from Jared Palmer , who also happens to be the creator of Formik for easily building forms in React. With tsdx, without ever having…| Leigh Halliday's RSS Feed
Performance can begin to degrade pretty quickly when you are trying to show large amounts of data on a map. Even at hundreds of markers using Leaflet via React Leaflet , you may feel it start to lag. By clustering the points together you can…| Leigh Halliday's RSS Feed
Performance can begin to degrade pretty quickly when you are trying to show large amounts of data on a map. Even at hundreds of markers using Google Maps via google-map-react , you may feel it start to lag. By clustering the points together you…| Leigh Halliday's RSS Feed
Performance can begin to degrade pretty quickly when you are trying to show large amounts of data on a map. Even at hundreds of markers using Mapbox via react-map-gl , you may feel it start to lag. By clustering the points together you can improve…| Leigh Halliday's RSS Feed
Redux has been the go-to way to manage state within your React application for years. It's popularity is due in large part because when it was introduced, it solved a number of problems which were difficult to do in vanilla React on its own. A few…| Leigh Halliday's RSS Feed
SWR is a great package from Zeit to help make it easier to fetch remote data with hooks. It is based on the stale-while-revalidate RFC, which in simple terms says to show stale (old) data while you are fetching a new version of the data. The…| Leigh Halliday's RSS Feed
Zeit has great documentation, but it took me a while to understand the difference between environment variables (secrets) on the serverless side vs how to get env vars exposed and available to the React code which runs client side, in the browser…| Leigh Halliday's RSS Feed
How do you iterate over objects in JavaScript? In this article we'll answer this question by showing 3 alternatives. The data we'll be using for this article contains the name of 3 Toronto Raptors, with a unique key property for each of them. Mapping…| Leigh Halliday's RSS Feed
I kept seeing Tagged Template Literals in a number of popular libraries, but I didn't understand how they worked. This article explores what they are, how they're used "in the wild", and we'll then build a small version of a css function which…| Leigh Halliday's RSS Feed
useEffect is meant to handle any sort of "side effect" (making a change in some external system, logging to the console, making an HTTP request, etc...) that is triggered by a change in your component's data or in reaction to the component rendering…| Leigh Halliday's RSS Feed
GraphQL is a typed language, so why redefine all of the types ourselves inside our TypeScript code when we should be able to take advantage of the types coming from GraphQL and have them automatically generated for us? That's exactly what we can…| Leigh Halliday's RSS Feed
In this article we'll take a look at how to handle async code in React Testing Library, specifically at how to test and mock a call using Axios. Async code... waiting for an element In the example component shown in my article introducing React…| Leigh Halliday's RSS Feed
In this article we'll see how to fire and test events in our React components using the React Testing Library. With React Testing Library it's very easy to simulate browser events such as a click event. The library comes with a function called…| Leigh Halliday's RSS Feed
React Testing Library is an amazing yet simple testing library from Kent Dodds . It works alongside the testing library Jest to provide React specific testing for snapshots, verifying DOM attributes or content, triggering click (or other) events…| Leigh Halliday's RSS Feed
With React 16.7 we were introduced to hooks . A way to allow things like state, refs, and lifecycle functions to live inside functional components, functionality once only available in class based components. The great thing about hooks though is…| Leigh Halliday's RSS Feed
So you've updated your React code to use GraphQL, but there's those 2 RESTful API endpoints that you still have to integrate with... what do you do? You could use fetch or axios with your favorite state management tool, but now you have 2 ways of…| Leigh Halliday's RSS Feed
React gets its name from being reactive to changes in your data. When data changes, the UI reacts to those changes to re-render the page to match the data. Data is known as two things in React: state and props. State is data owned by the component…| Leigh Halliday's RSS Feed
In our tests we don't want to perform an actual HTTP request. To start with it is slow, but there are certain calls you really can't make with every test run, for example charging someone's credit card. In this article we'll look at a function that…| Leigh Halliday's RSS Feed
In this article below we will test a component which runs asynchronous code inside of its componentDidMount lifecycle event. We'll look at how to avoid making real AJAX requests through the mocking functionality provided by Jest, as well as learn a…| Leigh Halliday's RSS Feed
The new React Context API is touted (at least on Twitter and a number of articles) as solving the need to use a state management tool, when I think in reality what it solves is easy dependency injection: Take something that lives at the top of your…| Leigh Halliday's RSS Feed
Error boundaries were introduced in React 16.2 and provide a sort of declarative try/catch pattern for you to handle errors which occur during the render of a component. In this article we'll look at how to implement error boundaries, but we'll…| Leigh Halliday's RSS Feed
In this article we'll look at how to get up and running with testing React in a create-react-app . We'll look at how to configure your tests and tackle 3 common testing patterns. Config create-react-app comes with Jest pre-configured, but there…| Leigh Halliday's RSS Feed
React Motion is an animation library loved within the React community. I have to say that having some experience with libraries like GSAP, it isn't the easiest to comprehend, but its power comes from the ability to directly tie animations to your…| Leigh Halliday's RSS Feed
In this article/video we'll start with a simple React app made with create-react-app that uses component state (setState) as its state management. We'll then take it from component state to MobX, and then again from component state to Redux. During…| Leigh Halliday's RSS Feed
I wanted to compile an ultimate list of Ruby resources, books, courses, people to follow, etc... This list contains resources I have used over the years while learning and writing Ruby (on Rails) professionally. My goal is to keep this list up to…| Leigh Halliday's RSS Feed
I've always loved MobX because of it's lack of boilerplate in comparison to Redux. It just seems so effortless to modify state... so how does it fare with Async code? In Redux you'd reach for something like thunk , but in MobX there are a few easy…| Leigh Halliday's RSS Feed
Currently there are 3 distinct ways of using refs in React. A ref gives you access to the underlying DOM element. This is especially useful when interfacing with libraries which require the DOM element. An example of this is three.js , which wants…| Leigh Halliday's RSS Feed
MobX State Tree takes something which is awesome (MobX) and brings it to the next level. You can now define your own typed models, made up of typed fields, and have them all nested together in a tree. You still get all of the same beautifully hidden…| Leigh Halliday's RSS Feed
You do not have to eject from create-react-app to get support for decorators and other babel plugins. MobX works fantastic with decorators and I've always been ejecting to get that working... but there is no longer a need to do that! In this video we…| Leigh Halliday's RSS Feed
Create React App is a great way to get up and running with React. It comes configured with sane defaults which are great for most people, but unfortunately we'll need to make a few changes before we can use MobX. I'm a huge fan of MobX and it's been…| Leigh Halliday's RSS Feed
In Ruby we can use the match method which belongs to the String class to both check a string for a regular expression match but also to extract data using captures. Captures allow you to extract part of the string... to isolate it. You do this by…| Leigh Halliday's RSS Feed
In this video tutorial I show how to get up and running with Mobx in a React app. We will go from create-react-app all that way to having a fully functioning Mobx store connected to our components. If you would like to follow along, you will need…| Leigh Halliday's RSS Feed
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…| Leigh Halliday's RSS Feed
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…| Leigh Halliday's RSS Feed
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…| Leigh Halliday's RSS Feed
In this article we are going to look at method_missing and respond_to_missing? in order to see what they do and how they can be used. We're going to re-create the StringInquirer class in Ruby on Rails as a way to demonstrate what is happening…| Leigh Halliday's RSS Feed
I'm working with an API which requires a phone number to be in the format 555-555-5555. As much as you want your users to enter it in that format, they won't always do that... even with placeholder text showing the correct format. To make their lives…| Leigh Halliday's RSS Feed
What is a Stack? 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…| Leigh Halliday's RSS Feed
Today we're 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. Imagine a complicated maze and ask the question of whether you can…| Leigh Halliday's RSS Feed
Correcting for spelling mistakes 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…| Leigh Halliday's RSS Feed
Race conditions A race condition or race hazard is the behavior of an electronic, software or other system where the output is dependent on the sequence or timing of other uncontrollable events. It becomes a bug when events do not happen in the order…| Leigh Halliday's RSS Feed
Single page applications Single page applications (SPA) are becoming more and more popular, often replacing the more traditional server rendered websites that are common in Rails or PHP. You have options such as Angular, Ember, React, and there are…| Leigh Halliday's RSS Feed
Intro 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. Heads & Tails…| Leigh Halliday's RSS Feed
This article is the counterpart to one I wrote on Recursion in Elixir . What is recursion? 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…| Leigh Halliday's RSS Feed
Intro... learning Elixir This is my first post in the new Elixir category I've set up on my site. I'm new to Elixir and functional programming in general, aside from a Scala course I've done on Coursera. Ruby is the language I'm currently most…| Leigh Halliday's RSS Feed
The challenge Write a program that outputs all possibilities to put + or - or nothing between the numbers 1, 2, ..., 9 (in this order) such that the result is always 100. For example: 1 + 2 + 34 – 5 + 67 – 8 + 9 = 100. Apparently every Software…| Leigh Halliday's RSS Feed
How to ensure your values are unique It's often the case that you want to ensure that you've got uniqueness in your data. You only want an email address to be used once... otherwise what would happen when that person tries to log in? Which user…| Leigh Halliday's RSS Feed
As a way to better understand how Ruby works, I started to dive into how object hierarchies work in the language. We're going to be covering the default ancestry chain in Ruby, how to create your own ancestors, and what the base level objects in Ruby…| Leigh Halliday's RSS Feed
My problems today Today I was trying to write a test for a method, and I was expecting certain behaviour that I definitely wasn't getting. Why was this method returning me a valid value when it surely should be failing? So I started poking around…| Leigh Halliday's RSS Feed
Can you do this integration? Is what I was asked. Oh no... it's in SOAP? Instantly all the time I spent working with SOAP APIs in PHP flashed before my eyes, bringing back memories I would have rather left in the past. What is SOAP? SOAP, originally…| Leigh Halliday's RSS Feed
What is method_missing? method_missing is a method that ruby gives you access inside of your objects a way to handle situations when you call a method that doesn't exist. It's sort of like a Begin/Rescue, but for method calls. It gives you one last…| Leigh Halliday's RSS Feed
Creating Methods In this post I'll be discussing another aspect of metaprogramming in Ruby. The ability to create methods dynamically, during runtime. There are many reasons to do this, but one of them is to allow you to write generator methods to…| Leigh Halliday's RSS Feed
What is metaprogramming? You might have heard the term metaprogramming before, but what is it and what does it have to do with Ruby? To start off, let's look at the Wikipedia definition: Metaprogramming is the writing of computer programs with the…| Leigh Halliday's RSS Feed
Overview I've been in Colombia for the last month visiting family, and last week I had the opportunity to hang out with the Medellin.rb meetup . It was led by Oscar Rendon and it was all about DSLs in Ruby. It was also a fun challenge to try to…| Leigh Halliday's RSS Feed
What is a Struct? A Struct in Ruby is one of the built-in classes which basically acts a little like a normal custom user-created class, but provides some nice default functionality and shortcuts when you don't need a full-fledged class. Below I'll…| Leigh Halliday's RSS Feed
Intro to MongoDB MongoDB is an object or document based database... in other words, a NoSQL database. This puts it in contrast to databases such as MySQL, PostgreSQL, or SQLite, who store their data relationally in a tabular format. MongoDB stores…| Leigh Halliday's RSS Feed
Situation Maybe you originally wrote some code for a Rails project that you're trying to use in another framework, in an automation script, or in a Gem that you're extracting out of your project. Have you ever run into an error saying something along…| Leigh Halliday's RSS Feed
The basics of Rack Taken from the Rack website : Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks. It gives a large number of webservers (Unicorn, Puma, Phusion Passenger, WEBrick) a common way of…| Leigh Halliday's RSS Feed
My switch from PHP to Ruby as primary language About 3 years ago I started coding the first version of FlipGive, an online fundraising platform . It was written in PHP. Why? Because for the 7 years prior that is the language I had primarily been…| Leigh Halliday's RSS Feed
Deciding on technologies When deciding on which technologies to focus your time and energy on to learn, or whether it makes sense to use one over another on any given project, it comes down to a number of different factors. Here are some of the…| Leigh Halliday's RSS Feed
What are tree structures used for? Tree structures are needed any time you want to insert a hierarchy into your data. It's when you want to store relationships between data of the same type, vertically. Think of categories, org charts, and family…| Leigh Halliday's RSS Feed
Hi, Leigh, are you busy? The website is no longer responding... can you investigate? A phone call nobody really likes to receive on a Saturday. We launched a new website on Friday and it appeared to be working great! Little did we know that our…| Leigh Halliday's RSS Feed
Ruby's Collect method Ruby's collect method is part of the Enumerable mixin; a mixin which provides very useful and powerful methods for collection objects. collect is a method I use all the time and recently wrote about in my article Working…| Leigh Halliday's RSS Feed
What is the Tap method? Ruby's tap method allows you to "tap into" a method chain, modify an object and receive that same object as the result. An Engine Yard blog recently spoke about five ruby methods you should be using in which tap was one…| Leigh Halliday's RSS Feed
Why do this? Recently at work we had 1 data model that was getting a bit out of control. When we first modelled the data it made sense, but over time business requirements change and we discovered that the model made more sense to be split in half to…| Leigh Halliday's RSS Feed
What is an Enumerable? Enumerable is a Ruby mixin/module which provides a large set of functionality to collection classes. You already know of some objects which are enumerable that come standard in Ruby such as Array and Hash. You can also make…| Leigh Halliday's RSS Feed
Why does this site have I18n? It's a good question because my content is only available in English (perhaps I should write some articles in Spanish??). The answer is that the code for this site powers my wife's blog too, who does in fact write…| Leigh Halliday's RSS Feed
The life of a developer Working as a software developer is the decision to become a lifelong learner. What you learn today has a good chance of being obsolete a few years from now. What is more important is to build a strong foundation of skills and…| Leigh Halliday's RSS Feed
Using Angular in Rails App Single Page Applications (SPA) aren’t incredibly new any more, but there are a lot of people with Rails applications using a more traditional server-side Rails approach to the website’s architecture. So what happens when…| Leigh Halliday's RSS Feed
Our Goal In this article I'd like to discuss how to implement user authentication into this blog. In this article about modelling the data for our blog we talked about wanting to keep track of Authors, and that they would be stored in the User…| Leigh Halliday's RSS Feed
Background At FlipGive we use RSpec to handle all of our testing. Over the years we've built up quite a few tests... last count there are 2130 of them, which take 3 minutes and 20 seconds to run. Not the fastest test suite in the world, but…| Leigh Halliday's RSS Feed
Today's Goal: Creating an Admin Section This website, along with most of the other ones I create end up having an admin section; a place where data can be created and managed. It's only accessible to registered users (or possibly a subset of those…| Leigh Halliday's RSS Feed
What is PgHero? PgHero is a gem written by Andrew Kane for getting quick insights into how your Postgres database is performing and where there is room for improvement. It provides a quick overall status of your database, a look at the queries…| Leigh Halliday's RSS Feed
Deciding What Models are Needed In my last article in this series, getting started with ruby on rails , we worked through getting Rails installed and creating a new application, with some initial gems being chosen and installed. Now we're ready to…| Leigh Halliday's RSS Feed
Git Init The first thing I do when starting a new project is to create a new git repository. GitHub is great if you don't mind the code being public, or you don't mind paying to have a private repository. There is another option available called…| Leigh Halliday's RSS Feed
Overview PSQL is the command line tool for accessing the PostgreSQL database. I recommend anyone using Postgres to at least learn the basics of how to navigate around and feel comfortable working in this tool. Even for those used to only dealing with…| Leigh Halliday's RSS Feed
The Problem Say you have a table of people and you want to sort them alphabetically by their nickname in descending order (Z - A). That works great as long as everyone has a nickname, but what happens when one doesn't? What you'll get is a result…| Leigh Halliday's RSS Feed
What is a Mail Interceptor? When using ActionMailer in Rails, there is a way to hook into the outbound message after you call the "deliver" method, but before it is actually sent to the delivery agents. You can think of these interceptors a little…| Leigh Halliday's RSS Feed
Intro To Pull Requests A pull request is when you are wanting to merge code from one git branch to another, and instead of just merging it yourself, you send a request to another developer to review the changes and merge the code into the desired…| Leigh Halliday's RSS Feed
When building a RESTful API in Rails, there are many different options and gems you can use to format your JSON responses. This isn't a post about how to build an API, but rather about some of the different popular options on how to define and…| Leigh Halliday's RSS Feed
Block based configuration is a pattern you see quite a bit when using ruby. When I look at this website itself, there are 3 different gems that I am configuring using this approach. I think it provides a clean and encapsulated interface for…| Leigh Halliday's RSS Feed
10. Don't Feel Discouraged It's easy to feel discouraged when you first start at something... anything, not just programming. Lance Armstrong most likely started out with training wheels on his bike and fell quite a bit at the beginning. Things…| Leigh Halliday's RSS Feed
Having The Right Mindset When bringing on junior developers to the team, you obviously have some goals for them, but you shouldn't forget that they have goals for themselves too. It's important to find out what their goals and interests are so that…| Leigh Halliday's RSS Feed
Barby is a great gem for when you have to generate a barcode or QR code. You can choose to output it as any number of barcode types or as a QR code. This example will use a QR code but I have successfully used the Code128 barcode which is fairly…| Leigh Halliday's RSS Feed
Goal If you're planning to take over the world (or a smaller but no less noble task of taking over Canada), you'll either need to convince…| www.leighhalliday.com
GraphQL is an amazing new(ish) paradigm for communicating with APIs, made popular by Facebook but since then used by many companies…| www.leighhalliday.com
Data comes in all sorts and sizes, and one of the key skills a developer can have is how to convert it into the required format and shape…| www.leighhalliday.com
If you've ever pasted a URL from an article on dev.to into Slack, Twitter, Facebook or LinkedIn, you'll notice they have an awesome social…| www.leighhalliday.com