• 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. Whenever I started a new project, I would spend the first few days setting everything up - Java11 (.NET with c# nowadays), maven configuration, docker, microservices communication, databases config etc. This process took way too much time.

  2. When learning a new programming language or framework, by the time I needed to use it, I had often forgotten how to set everything up. This approach saves me time in the long run and forces me to really learn how to use the new technology.

  3. For technical tests during job hunting, it allows me to save time and focus entirely on the code challenge.

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