String conversion bug in Ruby

This a bug is a rare edge case. Usually in Ruby when you convert a string into an integer it returns 0, but this specific string (7Q8GPSJMKF) converts into the number 7. Using the Integer class would be nice if it did not raise an exception: I could have used Integer and then a rescue, […]

Read More String conversion bug in Ruby

React devs VS the world

A team assembles to discuss the implementation a new feature … Dev #1: We will have this new component which fetches the webhooks from the database. Dev #2: Well, this data will have to be sorted and it should be done on the backend. React Dev: NO, YOU’RE WRONG! THAT IS NOT THE REACT WAY! […]

Read More React devs VS the world

JavaScript .sort() is broken

I am currently playing with Node.js and started to do some code challenges in JavaScript.In one of these challenges, an array is given and it asks for the smallest number, for example: arr = [85, -572, -1, 99] arr.sort() => [-1, -572, 85, 99] WHAT!? In ruby arr = [85, -572, -1, 99] arr.sort => […]

Read More JavaScript .sort() is broken

A simple checksum

I was watching The Grand Unified Theory talk by Jim Weirich yesterday and was inspired to do a simple checksum on Python. Here follows the use: add_check_digit(‘2352366246’) # => ‘23523662461’ check(‘23523662461’) # => True check(‘23523662467’) # => False Here is the implementation: def add_check_digit(digits): check_digit = ((10 – check_sum(digits)) % 10) return digits + str(check_digit) […]

Read More A simple checksum

Proxy Object – Python Koans

I came back to Python once again and to start I used a magnificent tool that I used on the past. Koans! This was inspired on Ruby Koans built by Jim Weirich which by himself was a great mind with all sorts of contributions to the Ruby community. This is the former lesson and I […]

Read More Proxy Object – Python Koans

Extract Value Object

One more on our clean code series (I think every post I make is about clean code, at least I do my best). The last one was about the Null Object Pattern. Today will be about the Extract Value Object. class SummaryCard attr_accessor :reviews def initialize(attributes = {}) @stars = attributes.fetch(:stars, nil) @reviews ||= review_scores […]

Read More Extract Value Object

Null Object Pattern

Another one, follows from the clean code series I am making. The last post was about Extract Class. Today we are going to talk about the Null Object Pattern and how we can implement it in ruby. Below we have an example of a music platform subscription pattern with the classes: class User include ActiveModel::Model […]

Read More Null Object Pattern