RSSAmplifier

Blog

Luca Guidi

Recent content on Luca Guidi

/RSS feed ↗120 posts

Latest posts

(untitled)

A starter note. Delete this and write your own — no title required. When a
thought outgrows the stream, promote it to a journal entry.

Why Your `app version` Golang CLI Command Loads Your Database Client (And How to Fix It)

You type myapp version to check the version number.
But behind the scenes, your application loads the database client, git service, API handlers, and file system watchers.
All that code initialization for a command that just prints a version string. 
 This is the hidden cost of traditional dependency injection in Golang CLI applications.
Every command pays the startup cost of all…

Setup Hanami with Sidekiq

Introduction 
 Sidekiq is the standard in the Ruby ecosystem for background jobs.
This short tutorial will show you how to set up Sidekiq in a Hanami application using Docker Compose. 
 For the basic setup, please look at my previous tutorial : Getting Started with Hanami and Docker Compose .
We’ll modify that demo application to support Sidekiq. 
 Steps 
 1. Add the…

Getting Started with Hanami and Docker Compose

Introduction 
 Hanami 2.0 is the perfect Ruby framework for building robust and fast API applications. The 2.0 version comes without a persistency layer (that will be a 2.2 feature). 
 Today we’ll learn how to set up a Hanami app with a secure Redis instance using Docker Compose in a few steps. 
 As a prerequisite, you’ll need Docker , cURL , Ruby 3.2+, and Hanami 2.0+.…

Getting Started with Hanami and GraphQL

Introduction 
 Hanami 2.0 is a productive Ruby framework that quickly supports you in building API applications. 
 Today we will see how to get started with Hanami and GraphQL in ten steps. 
 We will create the app and a simple code to support the GraphQL schema with a simple Query, including a request spec. The theme is a classic Star Wars schema. 
 As a prerequisite, you’ll…

2022: A Year of Growth and Accomplishments

It’s been a busy and rewarding year , both personally and professionally. 
 I turned 40 in June ! That was an opportunity to think about time passing. I’m committed to spending time doing the things I always wanted to do but never took the courage to do. 
 For example, I started taking swimming lessons . 🏊 For a person that was terrified by deep water, it’s a vast…

Striking a Balance: Why Prioritizing Both People and Processes is Key to Success in Agile Teams

As a software architect who has worked in Agile environments for several years, I have seen the benefits of the Agile Manifesto’s emphasis on “people over processes.” 
 However, there is also value in challenging this principle and considering the potential drawbacks of prioritizing people over processes in certain situations. 
 One of the main arguments for prioritizing…

Open Source Updates: Q1 2021

Hanami CI stability 
 I was one of the early adopters of Travis CI, but in more than a decade the service that served so well the Open Source community is not the first class solution that it used to be. 
 We decided to migrate to GitHub Actions, so I spent time to migrate all the Hanami gems to GitHub Actions . Not all the Open Source work is for the game of the fame.

Open Source Updates: December 2020

Brief 2020 recap 
 During 2020 due to the pandemic and new job role (software backend architect at Toptal) I had less time to dedicate to Open Source.
Luckily enough, other amazing people took care of projects that I care about. 
 Two people above all: Tim Riley for Hanami 2 and Tom Scott for redis-store . 
 
 Let’s start with the easy one: I don’t actively maintain…

Ruby Method Overloading

Method Overloading is a programming language feature that allows you to define multiple signatures (and implementations) of the same method. 
 Ruby doesn’t have such a feature. It was a shocking discovery when I switched from Java.. a very long time ago. 
 We can somehow trick the language using optional and keyword arguments. 
 But how can we have real isolated implementations…

Hanami::API on Amazon AWS Lambda

The Hanami team & I, recently announced Hanami::API : a minimal, extremely fast, lightweight Ruby framework for HTTP APIs. 
 Its minimalism, the small memory footprint and its performance, make Hanami::API a good candidate to build microservices . 
 Today, we’re gonna deploy a small service on Amazon AWS Lambda .
It’s an Amazon AWS product that allows to deploy an…

Introducing hanami-cli

Introducing hanami-cli : a general purpose Command Line Interface (CLI) for Ruby.
Learn why Hanami replaced thor in favor of hanami-cli and how to use it to build a CLI application in 5 minutes . 
 Why not thor ? 
 For long time we used thor 🔨 to build the Command Line Interface (CLI) of Hanami. But as the time passed, we needed more control on the internals of our implementation.…

How To Test Ruby CLI: Console

One of the most interesting challenges I met during Hanami development is to write isolated integration tests. The framework ships with an extensive Command Line Interface (CLI) to generate (or destroy) code, start the server, open a Ruby (or a database) console, create/drop the database, run the migrations, precompile assets, and print informations. 
 Console 
 Hanami console is an…

How To Test Ruby CLI: Code Generators

One of the most interesting challenges I met during Hanami development is to write isolated integration tests. The framework ships with an extensive Command Line Interface (CLI) to generate (or destroy) code, start the server, open a Ruby (or a database) console, create/drop the database, run the migrations, precompile assets, and print informations. 
 Code Generators 
 Code generators is…

How To Test Ruby CLI: The Setup

One of the most interesting challenges I met during Hanami development is to write isolated integration tests.
The framework ships with an extensive Command Line Interface (CLI) to generate (or destroy) code, start the server, open a Ruby (or a database) console, create/drop the database, run the migrations, precompile assets, and print informations. 
 Full Isolation 
 As I want to…

Lessons Learned In Open Source: The Motivations

It was a rainy Wednesday. That 5th of Oct 2011, I was driving to work, stuck in the traffic, while the radio announced it: Steve Jobs was died. 
 I was shocked. For me and more than one generation, he was the iconic leader, whom fame and success went beyond his tech career. 
 “Can I achieve the same?” I thought. 
 Since that day, we self-proclaimed visionaries, we tried to…

Isolate Global State

Using global state in software programs, is handy for development, but evil to maintain. 
 It can easily become source of bugs that are triggered by edge cases which are hard to track down. 
 Let’s see why, and how we can mitigate the problem. 
 An Example Of The Problem 
 For instance, in Hanami code base we need to test how the framework configures itself according to…

The Penguin That Can't Fly

A short story about OOP, interfaces and soft typing 
 
 Today is the day at the headquarters of Spectacular Foo Ltd. The rising firm of the indie gaming scene is going to release its next blockbuster title: Banal Birds . 
 The year is 2019, Ruby 3 is three times faster and has soft typing , what a crazy coincidence that solves everything! It was a nostalgic decision but, you, as the…

25,000+ Req/s for Rack JSON API with MRuby

Last month I gave the closing keynote at RubyDay 2015 by talking about Lotus and the future of Ruby. 
 For the attendees, the most surprising part of my speech was about MRuby . It’s a minimal version of Ruby, that can be embedded in any system that supports C. 
 I think that this technology can play a key role for Ruby in the next years. The simplicity of the language can be used within…

JSON API Apps With Lotus

Do you need a fast and lightweight JSON API app? It must be powerful, flexible, quick to develop and easy to deploy? 
 There is a simple solution for all these requirements: to use Lotus gems to build it. 
 Lotus is well known for full stack web applications (via lotusrb ), but all the gems of this toolkit can be used as standalone components in existing Ruby applications. 
 It this…

Effective TDD With Ruby: Tmux Setup

Do you find Test Driven Development (TDD) good in theory but hard to practice? Do you think it requires too much discipline and you don’t have time? Or, are you just struggling to get your workflow streamlined? Fighting to glue your tools together? 
 Well, you can improve a lot , by borrowing some tricks from me. I’ve practiced TDD with Ruby for many years now, and built an entire web…

Effective TDD With Ruby: Vim Setup

Do you find Test Driven Development (TDD) good in theory but hard to practice? Do you think it requires too much discipline and you don’t have time? Or, are you just struggling to get your workflow streamlined? Fighting to glue your tools together? 
 Well, you can improve a lot , by borrowing some tricks from me. I’ve practiced TDD with Ruby for many years now, and built an entire web…

Effective TDD With Ruby: Time & Flow

Do you find Test Driven Development (TDD) good in theory but hard to practice? Do you think it requires too much discipline and you don’t have time? Or, are you just struggling to get your workflow streamlined? Fighting to glue your tools together? 
 Well, you can improve a lot , by borrowing some tricks from me. I’ve practiced TDD with Ruby for many years now, and built an entire web…

Effective Remote Working

Going remote is an appealing lifestyle, but without a guidance we can easily get lost. What’s the right balance between professional and personal life? How to make sure that you’ll finish your tasks by the end of the day? 
 You can get it right without too much effort. It’s just a matter of forming the right habits. 
 I work as a remote software engineer for three years now. During this…

Lotus And Microservices

The monolith is good (at the beginning) 
 The easiest and convenient way to build a complex system is to use message passing .
When all the components live in the same process, engineer’s life is easier. 
 Development cycles are shorter, interfaces can change quickly.
When deploy time arrives, we will have only one deliverable to push.
This is just great. 
 {% twitter There…

A New Roadmap For Lotus

Last year was great , and 2015 brings new challenges to Lotus. 
 Learn from mistakes 
 When I released the first version back in June it was a wild, unexpected success.
There was an uncommon hype for the initial version of a “yet another web framework for Ruby” . 
 Probably, Lotus’ vision met the needs of a lot of developers in our Community.
The demand of a…

2014 Retrospective: A Year Of Lotus

This has been a great year for Lotus . 
 At the beginning of 2014 I decided to open source this less invasive and simple framework for Rack. 
 Back in the day, it was just a software stored in my hard drive.
An experiment that turned to be a fresh take for web development with Ruby.
It had in it the seminal work of what is Lotus today, but it required patience for its blossoming.

Introducing Lotus::Validations

Data validation is an important piece in software architecture.
It guarantees that the successive layers will operate on correct input.
In the existing Ruby frameworks we’re used to see this responsibility flatten down into models. 
 The problem with this approach is that we end to mix a lot of validations for different use cases in a single place .
When the application grows…

Meaningful Exceptions

Writing detailed API documentation helps to improve software design. 
 We already know that explaining a concept to someone leads us to a better grasp. This is true for our code too. 
This translation process to a natural language forces us to think about a method from the outside perspective.
We describe the intent, the input, the output and how it reacts under unexpected…

Introducing Lotus

A year and a half ago I felt frustrated by the state of the art of web development with Ruby.
Secretly, in my spare time, I started hacking with new ideas, taking nothing for granted, destroying and starting from scratch several times, until the software was distilled in a beautiful API. 
 It took me a decade to get here, by following a process of subtraction of what isn’t essential…

Three Things To Know About Composition

A few days ago Aaron Patterson wrote a in interesting article about composition vs inheritance with Ruby. 
 He says that when inheriting our classes directly from Ruby’s core objects such as Array , our public API for that object will become too large and difficult to maintain. 
 Consider a powerful object like String which has 164 public methods, once our library will be released,…

Rails Is Not Dead

A few years ago, my lead develop of the time, told me: “Beware of the coupling that you’re introducing in your models” .
My answer was: “Hey, you don’t know what you’re talking about, this is ActiveRecord” . 
 I was an unexperienced developer fascinated by the innovation that Rails introduced.
After all, my technology was able to get rid of all…

We Are All Wrong About Software Design

We are all wrong. When it comes to talk about opinions this is the way that things work.
Everyone has her or his own beliefs shaped by years of experience in the field, frustrating code, books, successes, etc.
How can all these backgrounds fall into a one unified theory? They just can’t. 
 You’ve always been told to pick the right tool for the job.
But what’s the…

Introducing Lotus::Model

Almost all the Ruby frameworks for the Model layer mix up business logic with database details.
This kind of architecture leads to god classes , slow build times and to a general bad design .
These problems are well known to legacy projects’s maintainers. 
 What if we assign these roles to smaller components that are able to collaborate together ?
Imagine how life changing…

Thread Safety With Ruby

Moore’s law is over .
Modern computation is exploited by running processes on multiple cores.
Ruby has always ignored this trend, and the community didn’t put enough attention on this topic. 
 Ruby’s model for concurrency is based on threads.
It was typical approach for object oriented languages, designed in the 90s.
A thread is sequence of instructions that…

Introducing Lotus::View

The missing part of all the Ruby web frameworks is the distinction between views and templates .
A view is an object that encapsulates the presentation logic of a page.
A template is a file that defines the semantic and visual elements of a page.
In order to show a result to an user, a template must be rendered by a view. 
 Keeping things separated, helps to declutter templates and…

Redis Scripting with MRuby

MRuby is a lightweight Ruby.
It was created by Matz with the purpose of having an embeddable version of the language.
Even if it just reached the version 1.0, the hype around MRuby wasn’t high.
However, there are already projects that are targeting Nginx , Go , iOS , V8 , and even Arduino . 
 The direct competitor in this huge market is Lua : a lightweight scripting…

Introducing Lotus::Controller

Lotus development is going well.
The experiment of open source a framework per month is sustainable .
I have the time to cleanup the code, write a good documentation and deliver great solutions. 
 This month, I’m proud to announce Lotus::Controller . 
 It’s a small but powerful and fast framework.
It works standalone or with Lotus::Router and it implements the Rack protocol.…

Building Sinatra with Lotus

The beauty of Lotus is the composition of its frameworks. Each of them is well designed to achieve one and only one goal.
The main advantage of this architecture is that delevopers can easily use and reuse those frameworks in countless ways. 
 Lotus::Router accepts anonymous functions as endpoints.
This feature can be used to build Sinatra with it. 
 Initial setup 
 We need to…

Introducing Lotus::Router

For me, the first step in the long path of building a web framework was an HTTP router.
By understanding requests coming from an user, it pays back with an immediate gratification: start it, open a browser and see a result. 
 My hope was to embark on a short journey, and reuse as much as possible existing libraries.
But I soon discovered that the biggest problem of Ruby web frameworks…

Announcing Lotus

I’m pleased to announce Lotus: the Open Source project I’ve conceived, hacked and built during the last year. 
 Lotus is a full stack web framework for Ruby , built with lightness, performances and testability in mind.
It aims to bring back Object Oriented Programming to web development, leveraging on stable APIs, a minimal DSL, and plain objects. 
 Standalone frameworks…

On Happiness

As a naive younger man, I have always been disappointed by how many year resolutions have missed in the past.
Mostly because they are a failure by design: the wishful self is delighted to dictate the new agenda of change , where all the lazyness, tiredness, and unforeseen accidents will magically disappear to leave room to a bright, joyful and productive future.
This will never happen.…

Introducing Redis Store

[ I wrote this post for Redis ToGo, you can find the original article here and the related discussion on Hacker News . ] 
 Redis Store aims to be a toolkit for your Ruby applications, it natively supports sharding, master/slave replication, marshalling, timeouts and namespaces. Plus, it s really easy to use with the most popular frameworks, such as Ruby on Rails. 
 If you love modularity,…

Lean Rails App Setup

I m currently working as a consultant for an UN agency ( IFAD ) and we have a portfolio of ~15 Rails apps, developed in the last four years. The environment is heterogeneous and an half dozen of these projects are interfacing with legacy software and they are legacy themselves. As counterpart, the new apps we are developing are running on the latest bleeding edge technologies (Ruby 1.9.3, Rails…

HTML5 Geolocation Testing with Cucumber

[ I wrote this post for frestyl , you can find the original article here . ] 
 
Here at frestyl we're working hard, using cutting edge technologies to promote their wider-scale adoption and to help set the new standards with our direct experience. In the past months our geolocation service has been changed from a somewhat flaky IP lookup to the new HTML5 W3C draft . Our users noticed the…

Why Customer Service Matters

A few months ago I bought a flash music player for my music blog . 
 Surprisingly, it doesn’t support .m4a files. I noticed that lack, once I payed for it. Just for curiosity (and to know if I was missing something in the documentation), I filed an issue in their support forum (as of the 30rd of June), asking if their player can reproduce other formats rather than the aforementioned one. I…

How to install ruby-debug on Ruby 1.9

One of the major problem which prevent the migration to Ruby 1.9 is the lack of the porting of ruby-debug. 
 Here the steps I followed to made it working on my MacBook with Multiruby: 
 
sudo gem install rake-compiler ruby_core_source --no-rdoc --no-ri 
sudo gem install ruby-debug19 --no-rdoc --no-ri 
 I hope it works for you too!

Rails: Unobtrusive and i18n Javascript confirm

How many times do you heard you should separate content from behavior ? Never? Hmmm don t try to cheat me.. So, why do you still use :confirm option for link_to helper? &#xA; Here a little snippet to archive our goal, and as extra bonus, you get it i18n: &#xA; &#xA;<script type='text/javascript'> &#xA;window._authenticity_token = ''; &#xA;</script> &#xA; t(: asset.destroy ), &#xA; :class => delete…

Memoria: Statistics for Redis

A couple of days ago I setup this blog with Redis as cache container, thanks to my Ruby gem: redis-store . &#xA; Now, following the old itch-your-own-scratches rule, I created a little Sinatra web application for Redis statistics: Memoria . &#xA; &#xA; # Getting Started &#xA;(sudo) gem install sinatra dm-core do_sqlite3 rspec &#xA;(sudo) gem install ezmobius-redis-rb jodosha-memoria -s…

Hanoi: Automated jQuery tests with QUnit

About a month ago, we have released adva-cms 0.2.0, the most relevant change was the migration from Prototype to jQuery . I always been a loyal Prototype fan, and, until then, I always tested my code with `unittest.js`, combined with `jstest.rb`.&#xA; Like other rewrite we needed to rely on a solid test layer, but what I noticed was the lack of a valid automation support for QUnit , the test…