• Featured post

C# Async ops

El nucleo de la programacion asincrona son los objetos Task y Task<T>. Ambos son compatibles con las palabras clave async y await.

Primero hay que identificar si el codigo se usa para trabajos enlazados a I/O o si estos son CPU intensivos.

  • Si el codigo espera algo como una BBDD o una response de un servidor, es codigo I/O. En este caso hay que usar async y await
  • Si el codigo realiza un calculo costoso, es CPU intensivo. Use await para esperar una operacion que se ha comenzado en background con Task.run

Read More

Programming Templates

personal-templates-image

Which problem does it solve?

  1. Every time I wanted to start a new project, I needed to spend the first few days setting everything up. Java11, maven configuration, docker, microservices communication, databases config etc. This took way too much time.

  2. Every time I learned a new programming language or framework, for the time I finally got to use it, I already forgot how to set everything up and running. This saves me time (at the end) and forces me to really learn how to use this new technology.

  3. For technical tests when job hunting it saves me a lot of time, so I can focus entirely on the code challenge.

Which templates do you have?

There are multiple versions for each technology, the mains are:

  • Docker with docker-compose and: Java Apps, Jekyll, Python3, MySQL and MongoDB databases.
  • Android App with Kotlin
  • Java8 and Java11 with: Spring/boot, in-memory databases (H2), rest services, microservices (Vert.x), maven multi-modules
  • Kotlin
  • Full app with React for frontend, MySQL for database and Kotlin for backend.

Github Repository

Jekyll

Jekyll is a blog-aware static site generator, written in Ruby. It’s used for Github Pages and it transforms files written in markdown and liquid into a full HTML web.

Installation

Pre-requirements

sudo apt-get install ruby-full build-essential zliblg-dev
sudo gem install jekyll bundler

Configuration

The basic config is under _config.yml

# shows any config mishap
bundle exec jekyll doctor

Read More

Docker best practices

List of things to do, to improve your Docker experience

Never map the public port on a DockerFile

If you map it, you’ll only be able to have one instance of this container running. If the user wants to map the port, he’ll be able to do it in a compose script or with -p option.

# public and private mapping
EXPOSE 80:8080 # don't do this

# private mapping
EXPOSE 80

Read More

Docker, DockerFiles and docker-compose

Working docker-compose and DockerFile examples to complement this information
Interesting tool to analyze custom Image layers size

Basic Definitions

Image Executable package that includes everything needed to run an application. It consists of read-only layers, each of which represent a DockerFile instruction. The layers are stacked and each one is a delta of changes from the previous layer.
Container Instance of an image.

Stack Defines the interaction of all the services
Services Image for a microservice which defines how containers behave in production

DockerFile File with instructions that allows us to build upon an already existing image. It defines:

  • the base image to build from
  • our own files to use or append
  • the commands to run

At the end, a DockerFile will form a service, which we may call from docker-compose or standalone with docker build.

DockerFiles vs docker-compose A DockerFile is used when managing a single individual container. docker-compose is used to manage an application, which may be formed by one or more DockerFiles. Docker-compose may also be used as support to input large customization options, which otherwise would be parameters in a really long command.

You can do everything docker-compose does with just docker commands and a lot of shell scripting

Read More

Git advanced

Config

  • see config git config -l
  • modify username git config --global user.name "newName"
  • modify email git config --global user.mail "new@mail.com"

Git bisect

Is a tool to find the exact commit where a bug was introduced.

Usage

I have a file with the following content and an obvious bug

Row row row your car at the river

Read More

HateOAS

Rest levels

Model of restful maturity used to help explain the specific properties of a web-style system.

Level 0

The starting point for the model is using HTTP as a transport system for remote interactions, but without using any of the mechanisms of the web.
We publish a document on how to use our API. We declare only one endpoint and do all the communication through this endpoint.

Read More

Liquid

Liquid is a template engine for HTML. It’s used by Jekyll.

Variables Usage

  1. Declaration in a config.yml file with home_sidebar: Home
  2. Usage with liquid in file.html as {{ site.home_sidebar }}

Functions

Show liquid code snippets

When writing liquid code snippets, jekyll process this code instead of showing it. To solve this, wrap the code snippet with the tags

{percent raw percent}
{percent endraw percent}

Read More