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 rich text. …
Python 3.5 introduced Type Hints, a new feature that allows developers to use static type checking in python.
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 the endpoint in the frontend. The library supports several data providers, and we can add our own if needed. …
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. …
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
Before continuing it’s recommended that we spawn a shell within the virtualenv running the following command:
$ pipenv shell
Next, we’ll create a python package that will contain the application source…
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
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.
Unison is a file-sync tool for OSX, Unix, and Windows. It allows two replicas of a collection of files to be stored on different hosts (or different disks on the same host), modified separately, and then brought up to date by propagating the changes in each replica to the other. …
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 case Europe/Madrid which can translate into GMT+1 or GMT+2 depending on the time of the year. On the other side, the same application exposes an API that receives dates in UTC format. This resulted in the application handling two kinds of dates: internal dates in GMT+1/+2 format and external dates in UTC format. These dates are internally represented as