Lately, I have been working on a project in which I needed to pretty print some data on the console. That was how I discovered Rich, a Python library for rich text and beautiful formatting in the terminal.
In this story I will show you some of the features of this library, and how you can use it in your projects.
First, we need to install the library in our environment using pip.
pip install rich
Once installed we can try some of the features of the library.
One of the features that I use the most is to print…
Python 3.5 introduced Type Hints, a new feature that allows developers to use static type checking in python.
Python is a duck typed programming language. Duck typing in computer programming is an application of the duck test:
If it walks like a duck and it quacks like a duck, then it must be a duck.
Duck typing is a concept related to dynamic typing, where the type or the class of an object is less important than the methods it defines. When you use duck typing, you do not check types at all. …
In C/C++ applications it’s usual to use structures to group related data registers. The data contained into these structures can be persisted/loaded into/from a file through a serialization/deserialization process.
During the development of one of my pet projects I needed to analyze my workout statistics registered in my Geoanute ONMove 220 GPS watch. In a previous research, I discovered that this watch stores the workout statistics and the GPS track log into binary files. The content of these files is defined by C structures, so I had to do some more research. …
In this post I will cover a brief introduction to WebGL for all those who want to get started with 3D web graphics. I will explain how the Rendering Pipeline works and we will render a simple graphic as an example.
WebGL is a cross-platform, royalty-free API used to create 3D graphics in a Web browser. Based on OpenGL ES 2.0, WebGL uses the OpenGL shading language, GLSL, and offers the familiarity of the standard OpenGL API.
The main features of WebGL are the following:
During the development of one of my React projects I made a mistake using the useState hook by saving a third-party object in the component state. It took me some time to fix it because the error trace in the browser console was confusing.
In this project I used the react-admin library, a web framework to build B2B applications. The library provides user interface components and data providers to communicate with backend APIs. Thanks to these data providers we don’t need to implement the API clients ourselves: we only need to code our API using a standard format and set…
In this story, we will learn how to deploy a Flask application with Gunicorn and Docker. Also, we will discover how we can use HTTPS with free SSL/TLS Let’s Encrypt certificates.
Let’s go!
First of all, we will write a very simple flask application that we will deploy later:
The Pipfile should look like this:
Now, you can test the application running the following commands:
$ pipenv install
$ env FLASK_APP=hello.py pipenv run flask run
Security is essential when we build web applications. SSL/TLS certificates are a very important part of web security, allowing secure connections over HTTPS…
In this story we’ll learn how to implement a JWT authentication in flask with the Flask-JWT library. All the code implemented is available at this github repository.
We’ll start the project from scratch, so the first step will be to initialize it and install some required dependencies using pipenv:
$ mkdir jwt-auth-test-project
$ cd jwt-auth-test-project
$ pipenv --three
$ pipenv install flask flask-jwt flask-sqlalchemy
We’ll use the flask-sqlalchemy ORM library to manage the user data from the database.
Before continuing it’s recommended that we spawn a shell within the virtualenv running the following command:
$ pipenv shell
In this story we’ll learn how to use the Docker Engine API through the network in a secure way. The Engine API is an HTTP API served by the Docker Engine. It’s the API the Docker client uses to communicate with the Engine, so everything the Docker client can do can also be done with the API.
In order to use the Docker Engine API, a TCP socket must be enabled when the engine daemon starts. By default, a unix
domain socket (or IPC socket) is created at /var/run/docker.sock
. …
Currently I am managing two little servers and I need to keep some data in sync. Until now, I was performing this task using the rsync tool and a cron task. This approach is simple and functional, but there is a problem: the sync must be bidirectional if we need to keep two identical replicas and avoid integrity issues. Rsync does not support this.
There are several options to carry out this task, such as clustered file systems, but I have chosen a simple approach using Unison, a user-level tool that can be used to sync two replicas.
Unison is…
Most of our Java projects share a quite common persistence stack: a bunch of Spring Data JPA repositories which store information in a relational database, using Hibernate as JPA provider.
When it comes to handling and storing dates, the common standard for server applications is to handle and store all dates in UTC format, or at least in some kind of standard and deterministic format such as ISO 8601. Recently though, we had a bit of a struggle getting one of our applications to work with dates.
On one side, this application relied on JVM defaults for timezones, in this…
Software developer @trabe