Elastic IP Address (EIP) and ECS (EC2 Container Service) cluster, a naive solution

Recently I had the opportunity to set up another ECS cluster for a Ruby on Rails application that exposes a few API endpoints and a backend to manage some contents, i.e. images, videos and so on.

Considering our previous experience we decided to automate the provisioning of the infrastructure by using Ansible and after a bit we ended up with a few playbooks that allowed us to bring up everything we needed, from the DB to the instances, ELB, task definitions and services.

Everything was working quite well until we were asked to provide a static IP that could be used to access the aforementioned API endpoints.

Continue reading “Elastic IP Address (EIP) and ECS (EC2 Container Service) cluster, a naive solution”

How to create and customize a slider

A few days ago I had to work as a frontend developer because I needed to create some html static pages for mobile devices. One requirement was to have a scrollable component that mimics a calendar interface.

Building a slider from scratch takes a long time for sure, so I decided to use Swiper, an open-source slider compatible with most browsers and platforms.

I chose Swiper among many other candidates because it can be easily installed via Bower, which is currently one of the most popular package manager tools. Continue reading “How to create and customize a slider”

Flask and python-saml on Amazon Elastic Beanstalk

In the past weeks I have worked on something different than usual, a python project. This project was started a couple a years ago with Flask and I need to make some improvements.

Back in the days I used to work with Django, so it wasn’t difficult getting familiar with Flask. The major problem was to get python-saml work on Amazon Elastic Benstalk correctly and after a lot of googling I managed to get all the pieces work togheter, but I couldn’t find a solution with all the information in one place, so I decided to write this post.

Continue reading “Flask and python-saml on Amazon Elastic Beanstalk”

Specs on ErrorsController in Rails

There are different approaches to respond to failed requests in Rails.
By default Rails handles exceptions serving static HTML documents stored in the public directory. In particular, 500 (server error) and 404 (not found) responses result in the application’s rendering 500.html and 404.html, respectively.

In our application usually we build custom 404 and 500 error pages served trough ErrorsController. Several guides illustrate how to move your error pages from static html to dynamic views, here some examples:

This article wants to be a simple reminder for execption pages testing. Remember to test expected error pages behaviour inside a inside a request spec.

The request spec provides a couple of nice things not available in a controller spec. First, it actually hits your application’s HTTP endpoints, as opposed to calling controller methods directly. Running this test insisde a request spec allow us to check the entire functionality specially the options that tells Rails to serve error pages from routes config.exceptions_app = self.routes.

For example if you want to test a simple ActiveRecord::RecordNotFound for a specific resource:

require 'rails_helper'

RSpec.describe 'Show Post', type: :request do
  context 'when post is not present' do
    get '/post/not_existing'
    it { expect(response).to have_http_status :not_found }

    it 'returns an error message' do
      expect(response).to have_content('This is not the page you are looking for.')


Project Jacquard, smart clothes for Google

Presented at the Google I/O 2015, Project Jacquard is a project born in the ATAP Division (Advanced Technology and Products), the father of Project Ara and Project Tango, whose purpose is to create smart clothing that can interface with our devices via Bluetooth.

Continue reading “Project Jacquard, smart clothes for Google”

How to customize Solidus and its extensions

Since many years I had the passion for online shop. When I approached to Ruby on Rails, I found Solidus, an open source eCommerce application. I already have written another article more generic about it, to describe most of the features and potentialities of the ruby gem of Solidus, which gives you, once installed, a framework ready to be used and customized.

In a short time, I was able to create a fully functional platform, mainly by doing changes on the frontend-side. In fact, the other components provided by the gem, such as the backend, are perfectly arranged and comprehensive of all the main features needed for the management of an online store.

However, after I started to customize the platform by writing a lot of code, I discovered that there is a myriad of extensions that you can add in a few steps in your project. For example, I needed to print the invoice, and so I started coding this new feature, when in halfway, by searching on Google, I found out this gem: solidus_print_invoice. Continue reading “How to customize Solidus and its extensions”