Matheus Marabesi website, sharing ideas about software development - Listing posts on page 6

Tips for writing docker files

Docker has revolutionized how developers build and deploy applications, being one of the most popular container engine [1]. Docker has support for different programming languages and runs native on linux, as opposed to virtual machines that mimics an entire operational system, docker containers run on linux namespaces, removing the overhead that virtual machines have, for example, the boot time. The virtual machine needs time to boot, while docker is a service that starts on the host operational system. As opposed to the official best practices [2] on writing docker files, the goal here is to share tips on approaches in...

PHP import checker - VScode extension to support PHP developers

Vscode is one of the most used editors for web development [1], which supports various programming languages, including PHP. As its goal is not to be a full featured PHP IDE, it lacks a few characteristics that help PHP developers to be more productive. In that list, we can name one: the lack of checking if an imported class is being used or not. On the other hand, PHPStorm [2] has the ability to check imports being used built-in - This is a long discussion between editors x IDE’s. PHP import checker [3] fills this gap, which offers PHP developers...

Configuring reactjs and relay 2019 version

Recently GraphQL started to gain attention from the open source community as a production ready platform focused on the communication between client and server. One of the advantages of GraphQL over REST is how the data is fetched from server to client, avoiding over fetching as well as under fetching. Relay is an open source library that abstracts away the data fetching from the developer and offers a render component to the developer. Though, to configure relay and reactjs a few steps are needed. Even when following the official relay documentation to get up and running with React, problems can...

MySQL 5.7 on Ubuntu 19.04 and 19.10

Ubuntu 19.04/19.10 as default comes with MySQL 8.0 as it’s default version to work with. Projects that need to use a 5.* version might run into problems in the downgrade process. This post aims to guide the installation of MySQL 5.7 on ubuntu 19.04 and ubuntu 19.10. After trying to set up MySQL following different sources [1] [2] and fail over everyone, an alternative might be the installation via .deb packages through the official MySQL website, which is explored in detail here. Also, another approach is offered using docker instead of setting up everything from scratch. Set up For this...

e2e testing with Cypress, ReactJs and Firebase

Cypress is a e2e testing tool that interacts with chrome based browsers (and electron) to execute its test suite [1]. E2e testing is known by its complexity, and often it is related to the top in the test pyramid [2]. The complexity comes from the amount of work and setup to do before performing the test itself. To put in context, unit test usually is the easiest in the spectrum, whereas the developer write test methods to cover a class behavior. The setup to be done is the smallest. The havy setup is due the interaction between components, in a...

Introduction to OOP with PHP (Classes, Encapsulation, Inheritance)

The following content aims to introduce the concepts of OOP (Object Oriented Programming), complementing these concepts the PHP language is used to demonstrate practical examples, but can be written in any programming language. This is also a companion for the talk I gave on this subject (available in PT-BR). Introduction Object-oriented programming is a paradigm used in programming to approximate reality. In comparison to structured programming where each line of code executes a statement, object-oriented programming is distinguished by representing code in classes. Classes: represents a prototype of an object. To create an object it is necessary to define a...

Strategies to test legacy code - PART 1

Often developers have to deal with code base without test, which might lead to discomfort in maintaining the code base. In one hand there is the business that needs a new feature or a bug fix ready for the users to use, and in the other hand there is the developer without a guide to make sure that the change in the code doesn’t make any side effect. To refactor is the ability to change the code, without affecting it’s behavior [1]. If the code is changed and it’s behavior change, it is not refactoring, it is changing code without...

Errors compiling PHP 7.2 from source on a Raspberry Pi

The PHP version used is 7.2 directly from the git repository from github. Newer version might not work as expected. The version used to compile is the Raspbian (Raspbian Stretch with desktop and recommended software): Version: November 2018 Release date: 2018-11-13 Kernel version: 4.14 Getting the source code git clone https://github.com/php/php-src Entering the cloned repository to start the compilation process cd php-src Change to the version 7.2 (maybe newer or older, as you wish) git tag php-7.2.0 The following errors are sequential when trying to install PHP in a Raspberry Pi, the errors show up in the following commands: ./buildconf...

30 days of VIM - One month after

After one month using vim, I am clearly addicted to it. It has everything I need and I can always find a plugin to make it even better. Though, it is true that depending on the plugin it makes vim to slow. To give an example, I tried to use the auto-save plugin, but it turns out to turn my vim slow when saving. That’s because every time I touched one keystroke it was saving the file. I just decided to go without the plugin and it is fine. Productivity I feel that my fingers are faster while typing, and...