To-do list using only turbo-stream (Rails Hotwire)
ANOTHER TO-DO LIST IMPLEMENTATION 😂. There are many examples of to-do lists on the Internet, but this one is special because my idea is to use only the turbo-stream to update the list! Should I use turbo-stream to create a to-do list? Probably not, you can get almost the same result with just o...
Read moreUsing turbo events to wait for a form to be submitted
Using Turbo to develop WEB applications is a really cool thing, it's simple and the best part is that you don't need to add complexity where you don't need it, the true meaning of the Progressive Enhancement concept. At this point, after working for a year and a half with Rails 7 and Hotwire Tur...
Read moreStoring objects in SQL databases
Sometimes it's a good idea to store objects in the database, even if you're using a relational database. In fact, nowadays, most SQL databases support objects. For example: • Postgres - You can use jsonb columns • Mysql - You can use JSON columns And not only does it store objects, but the bes...
Read moreValidate params with Pattern Matching
I want to study and understand Pattern Matching and nothing is better than writing some code that can be useful for a real project, for me is the best way to understand something. First of all, let's contextualize what Pattern Matching is - Pattern matching is a mechanism for checking a value ag...
Read moreManage Docker with HTTP API
Today I'm going to talk about one of the good features of docker that's not too popular, this is the ... .... 🥁🥁🥁 ... ... HTTP Docker API - https://docs.docker.com/engine/api. Yes! Docker provides an HTTP API for interacting with the Docker daemon. The concept is simple and powerful, docker has...
Read moreImprove your problem solving skills
In this post, I would like to give a tip that helped me a lot. If you are at the beginning of your career, is very important to expose yourself to a lot of different problems. A good way to do this is to find a site with algorithm problems. A very good is https://www.beecrowd.com.br. Problems are...
Read moreInsert multiple records into the database (Rails and PostgreSQL)
To complete the feature that I'm developing, I have to insert a large list of items into the database, it's simple but I would like to insert it in the shortest possible time. To do this I have enumerated two ways and I will compare the time for operations to decide which is the best. To measure...
Read moreWhy do I use Service Object?
Service Object is about a class (PORO - Pure Old Ruby Object) with just only one public method, normally this method is called call or perform, for example, imagine that when the user completes the registration on your app, you need to create a subscription, this subscription has to send an email...
Read moreActive Job with huge payload
Today's problem involves active job with sidekiq. We have to enqueue a job with a huge payload (more than 10MB). Remember that when you create a job in sidekiq you actually put a new element in a Redis queue and if the params are big you will put that very large payload in the Redis. Is it a prob...
Read moreModal with image carousel using Turbo-Frames
Today's challenge is to create a modal with an image carousel using just the Hotwire turbo (no JS). Something similar: [Example] The idea is to have a list of galleries, when the user clicks on the gallery, the modal will open and the user will be able to navigate the list of photos. The first ...
Read moreRuby AWS Lambda Functions to generate NDVI maps
In my company, we have an application that generates NDVI (normalized difference vegetation index) maps using Sentinel2 scenes, this is a very complex operation that requires a lot of RAM and CPU. To understand the process, imagine that you have a polygon and you want to have the NDVI map for t...
Read moreA simple technique for trying out new things in Rails
One of the most interesting things to do in the development area is to try new things, some new library or even a new technique to improve performance. I really like doing this in Rails because it's very simple, in fact, you only need a few minutes to have a complete application with a few screen...
Read moreRails Global ID
A Global ID is an identification that uniquely identifies a model instance, very simple to understand. For example (Link is the model): Link.find(1).to_global_id.to_s # gid://link-share/Link/1 You can find a record by Global ID only: GlobalID::Locator.locate('gid://link-share/Link/1') # Returns t...
Read moreLists and group_by (Ruby)
The method group_by is a very useful and easy feature for working with lists - https://apidock.com/ruby/Enumerable/group_by For the examples, we use this simple list of cities. cities = [ { id: 1, description: 'Porto Alegre', country: 'Brazil' }, { id: 2, description: '...
Read moreAutocomplete with Rails 7 (Hotwired turbo)
I watched the great video https://www.youtube.com/watch?v=PfCU0Nni8fI and after that, I tried to create a simpler auto-complete, without explicit turbo-stream. The project consists of having a text field, when the user fills in and submits, the screen will show the filtered results. The first s...
Read moreHello World
I'm currently on vacation at Balneário Arroio do Silva and I decided to create a mini-blog to share some things related to development. The important highlight is that: I wrote the source code for this "blog" in about an hour, and when I started I just wanted to learn some new features availabl...
Read more