Mark Chavez

Mark Chavez

Learning how to learn.

Using Zeitwerk as your autoloader

10 November, 2020

In the previous article, I talked about the different ways to load a ruby file and we’re not stopping there. Apparently, there’s an easier…

Loading Files in Ruby

09 November, 2020

With Ruby, there are always multiple ways to accomplish a thing — loading files being one of them. In this article, I’ll be talking about…

Understanding to_proc

05 November, 2020

Today, I learned about . If you’ve been a Ruby developer for quite some time, this block of code might look familiar to you. The above code…

Fixing inconsistent tests with RSpec

23 August, 2020

One of the things I use to fix inconsistent tests is to use RSpec’s command. What it does is divide the whole test suite into smaller…

Adding chunks of changes in Git

17 August, 2020

When I have multiple changes in one file and I plan to divide these into separate/multiple commits, I always rely on git’s patching…

Fix: Terminal shows ^M when pressing newline

15 August, 2020

Sometimes I get this issue when running certain commands in my terminal (on OSX) — and the only solution I find useful is running this…

Schema-only changes during Rails migration

16 May, 2020

Recently, I realized to write schema-only changes during migrations because it produces far less errors in the future. This means avoiding…

Using the `ar_after_transaction` gem in Rails

07 April, 2020

Maybe the easiest way is to start with an example: What’s wrong? Remember that calling in an ActiveRecord model is its own transaction…

Safer Queries with Rails Transactions

28 March, 2020

Consider the following example and feel free to identify what the problem is. This block of code sure has a major issue that’s not as…

Dividing Actions with LightService

25 March, 2020

To get a clear understanding of this, let’s add an example that most of us can relate to — onboarding an employee . Example What happens…

Storing sessions in JavaScript

05 February, 2020

There are three ways of storing sessions in your browser. Local Storage Session Storage Cookies In this article, I’ll try to explain their…

Running a specific Rails migration

30 October, 2019

Today I learned an important thing on Rails migration. So apparently, each and every migrations are actually also ActiveRecord models. For…

Using RSpec without Rails

07 September, 2019

Sometimes I find myself wanting to test a ruby code outside the context of Rails. If what I want to test is trivial and so simple, then…

Practice RESTful Rails

04 March, 2019

It’s best practice to be as RESTful as possible with our controller actions. It makes it easy for developers to understand, extend, and…

Using Page Object To Improve Feature Tests

26 February, 2019

Take a look at this feature test for a moment. One way of approaching this is using a page object. It looks something like this. Then you…

Using SimpleDelegator in Ruby

24 February, 2019

Using is easy. Let’s say for example after user creation, we want to send the user an email. Here’s one way we might approach this. Plain…

Ruby: Constants and Classes

22 February, 2019

Given the class as shown below. The goal of this article is to let you know an alternate approach about constants and classes. If you are…

Introduction to Vim Macros

02 February, 2019

What’s a Vim Macro? A vim macro is simply a recorded series of commands. It can be used to effectively repeat complex commands quickly…

RSpec: Using the `aggregate_failures` block

31 January, 2019

Sometimes I add multiple RSpec expectations in my tests. Here’s how it usually looks like. Running the test above will tell you that your…

Installing TailwindCSS in a Rails app

17 November, 2018

Supports Rails v4.2 and up. This article will explain the installation process of tailwindcss in the context of building a new Rails app…

Ruby: Binstubs

14 November, 2018

Binstubs are executable programs that act as a wrapper to their original executables. Let’s use for example. , by default, has an…

Best Practices: Installing Ruby Gems

13 November, 2018

1. Update one gem at a time Doing a is not recommended because it will attempt to update all gems listed in your . Make sure you’re…

Gemfile.lock

12 November, 2018

Today I want to share important things I learned about the . If working on a Rails project, commit to version control. If working on a…

Ruby: Memoization Done Better

11 November, 2018

If you have written some Ruby code for a while, this is probably how proper memoization looks like to you. Simple! But not 100% correct…

My Reflections on Working Remotely

26 July, 2018

I wrote about my experiences while working remotely with Bloom. Check it out. https://medium.com/bloomx/my-reflections-on-working-remotely…

Procs vs Lambdas

24 February, 2018

Procs and Lambdas are simply, blocks in ruby. The only difference between these and a simple block (which uses yield) is that the former can…

What I Learned In 2017

20 December, 2017

The year is coming to an end and I’m excited about it. What have you learned? Have you reached your goals? What are your plans for the…

Path to Learning React

04 December, 2017

With all the existing resources and tutorials surrounding React.js , it is pretty hard or rather overwhelming to start off. Unfortunately…

Public APIs resources

03 December, 2017

Today, I developed an app that uses @toddmotto ’s valuable API list. Good thing is he provided us with a JSON dump of all available API…

React Lifecycles. When Do I Use Which?

27 November, 2017

React comes together with a number of lifecycle methods. These methods are basically functions that gets called on a specific phase of a…

Making Reusable Components with React

24 November, 2017

Building a component-based application is fairly reasonable. It can’t be that hard and at the same time, it can’t be that trivial…

Introduction: JavaScript Event Loop

25 October, 2017

Today I want to talk a bit about the Event Loop . If you want to get deeper with JavaScript, it is very essential to understand the…

Learning JavaScript

23 October, 2017

I’ve been learning JavaScript for the past few days and I found a reasonable article about the important things we should know as a…

Notes on Redux

14 October, 2017

I decided to make this article for the purposes of actually learning the fundamentals of redux. Technically speaking, it is a container that…

Arrow Function and When To Use It

18 September, 2017

Since the release of ES6, there has been a number of new and exciting features. One of those is the arrow function . In the surface, arrow…

Finally Loving Mobile Development

28 August, 2017

Looking back during the last 10 years or so, mobile apps are nothing but a stranger of this world. Then suddenly, it boomed and went crazy…

A Quick Demo of Javascript Promises

11 August, 2017

Using fetch Using fetch, but with error checking The above code looks good but lacks an error checking mechanism. What if we provided a…

10 Commandments of Egoless Programming

07 August, 2017

I came upon an article that has inspired me more to work better as a programmer and just in case you haven’t read it yet, kindly do so. It…

Avoid Conditionals in Elixir

04 August, 2017

I used to love conditionals. I think everybody did. It gave us the ability to decide what the system should do depending on many factors. It…

Anonymous Functions with Elixir

01 August, 2017

Anonymous functions are simply functions or methods that is not assigned a name. While named functions are very much a common thing…

How Phoenix Define an Application?

26 July, 2017

Hey there. How are you? It’s been a while since I last published an article! Well, that’s because I am currently involved in a JavaScript…

Building a Mock Database Server from Scratch in Elixir

13 July, 2017

Hello again! So I decided to build a mock database server in Elixir without using GenServer . In the real world, this is probably something…

Concurrency vs Parallelism

10 July, 2017

Concurrency and Parallelism are two of the most talked-about topics in computer science. The reason why is because these are very important…

Writing a RESTful Rails Controller

28 June, 2017

It is very important to keep your controllers clean. It must be readable, concise and RESTful in a sense. With Rails, it is pretty easy to…

Why You Should Avoid Rails Callbacks?

21 June, 2017

tl;dr - Just avoid them at all costs Callbacks are evil. Well, maybe at this point in time, you haven’t realized that yet but I want you to…

Functional Programming & Elixir

14 June, 2017

Looks like functional programming is gaining a lot of traction for quite some time now. I just started reading about Elixir and it seems…

Rails & Russian Doll Caching

10 June, 2017

Let’s show a list of products. This works fine. Until…there are thousands of records. So, let’s apply caching. With caching Now using…

Lesson Learned: The Importance of Code Reviews

05 June, 2017

As one of the developers on our team, writing efficient and well-written code is a serious responsibility. Our current setup assumes that…

Tell, Don't Ask

29 May, 2017

Rubyists often write a block of code that is similar to the one below. This is a code smell. Here’s a better way to do it. The above example…

The Hidden Complexity of Ruby

28 May, 2017

Ruby’s simplicity has reached a whole new level. It has given developers a new approach to writing code. For me, coding should be fun and…

The Power of Ruby's Struct

25 May, 2017

I like Structs. They are simple and useful. They provide the same functionalities like classes do. I normally use a Struct if I only need to…