• Featured post

C# Async ops

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

Primero hay que reconocer si el codigo se usa para trabajos enlazados a I/O o si 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

Async / Await (Operaciones I/O)

La palabra clave importante aqui es await. Lo que hace es suspender la ejecucion del metodo actual y devolver el control hasta que está lista para seguir.

public async Task Main()
{
	string contenido = await LeerPaginaWebAsync("http://example.com");
}

private async Task<string> LeerPaginaWebAsync(string url)
{
	using (HttpClient client = new HttpClient())
	{
		return await client.GetStringAsync(url);
	}
}

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

Patterns implementation

Implementation of several patterns in Java, which may be used as future example on how to technically implement them.

Database

DAO & DTO

Data Access Object & Data Transfer Object. DAO - Design pattern, used to encapsulate the access to a persistence resource (e.g a database) and eliminate dependencies which come with the implementation of the code. DTO is the object which representates an entity of the database, with all its own properties to be manipulated.

Read More

Personal Blog

personal-blog-old-image

Which problem does it solve?

Since the start of my programming career I’ve been writing little notes and programming how-to’s in Markdown. This way I don’t need to relearn the same thing twice and I don’t need to find the solution to an obscure problem twice.

After some time, that collection really grew and I needed a new way to be able to index, access and search all my information faster.

Technology Stack

You’re inside.