Posts

.NET: offline NuGet packages

Image
Spanish version / Versión en Español Usually, a .NET project consumes standard and third-party libraries from nuget.org . For context, NuGet is .NET's de facto package manager, like npm for Javascript, PyPI for Python, Maven for Java, Conan for C++, and so on. It's common practice for an organization to own a NuGet repository hosted in a binary hosting service such as Artifactory or Nexus . If the organization develops its own libraries, they will be hosted in that particular repository. This way, libraries can be used across different development teams inside the organization, and also beyond it if libraries are chosen to be made public. This is all well and good, but sometimes the hosting service goes down, or it is desirable to tinker with the libraries locally before deploying them. In scenarios like these, it's helpful to have an extra NuGet source that lives in the developer's machine and can be used when building and developing .NET applications. T...

.NET: paquetes NuGet offline

Image
Versión en inglés / English version Típicamente, un proyecto .NET consume bibliotecas estándar y de terceros a través de nuget.org . Contextualizando un poco, NuGet es el gestor de paquetes o ( package manager ) de facto del ecosistema .NET, como npm para Javascript, PyPI para Python, Maven para Java, Conan para C++, etcétera. Es una práctica bastante establecida que las organizaciones tengan un repositorio NuGet privado alojado en un servicio de hosting de binarios como Artifactory o Nexus . Si la organización desarrolla sus propias bibliotecas, las alojará en dicho repositorio. Así, podrán ser reusadas entre distintos equipos de desarrollo dentro de la organización, e incluso fuera de la misma si se opta por hacerlas públicas. Todo esto está muy bien, pero a veces el servicio de alojamiento de binarios se cae, o se desea modificar las bibliotecas localmente antes de desplegarlas. En escenarios así, resulta útil tener una fuente NuGet adicional alojada en la máquina de...

GNU Autotools II - "Hello world" project with tests

Spanish version / Versión en Español In order to explore the concepts from the first post in a more practical fashion, today we will look at a step by step guide for creating a C programming language project built and tested using Autotools . 1: Application entry point This will be src/main.c . It's typical to have a src directory for source code, because when the project grows, it will probably need other top-level directories such as man for man pages , data for data files, and so on. src/main.c #include <config.h> #include <stdio.h> int main (void) { puts("Hello World!"); puts("This is " PACKAGE_STRING "."); return 0; } Including config.h is necessary because that's where PACKAGE_STRING will be defined. In turn, config.h will be generated by Autotools. 2: Top-level configure.ac file All configure.ac files contain Autoconf instructions which control the generation of the configure script. These...

GNU Autotools II - Hola mundo con tests

Versión en inglés / English version Para bajar a tierra los conceptos del primer post , hoy seguiremos paso a paso la creación de un proyecto en lenguaje C usando Autotools como sistema de build . 1: Punto de entrada En primer lugar, se crea el punto de entrada del programa, src/main.c . Es típico tener un directorio src para el código fuente, ya que al evolucionar el proyecto, probablemente se agreguen directorios como man para páginas de ayuda ( man pages ), data para archivos de datos, etc. src/main.c #include <config.h> #include <stdio.h> int main (void) { puts("Hello World!"); puts("This is " PACKAGE_STRING "."); return 0; } La inclusión de config.h viene dada porque ese archivo será generado por Autotools, y es donde estará definido PACKAGE_STRING. 2: Archivo configure.ac raíz Los archivos configure.ac contienen instrucciones Autoconf que controlan la generación del script configure . Dichas instru...

C++: Adding unit tests to Arduino code

Spanish version / Versión en Español One of the advantages of pure unit testing is validating logic in isolation from external dependencies. In the case of Arduino, it's possible to test an entire sketch without a physical board and (almost) without modifying the original code. In his book "Working effectively with legacy code" , Michael Feathers introduces the concept of seams . He defines them as places in the source code where it's possible to swap out an external dependency for a fake object in order to isolate the calling code for testing purposes. In today's post, we'll walk through a concrete example of some techniques that exploit these seams. In particular, we will do this for a simple Arduino project. As a starting point, let us consider the following Wokwi project . For the sake of context, Wokwi is a website that allows users to create Arduino projects using just a web browser, without a physical board or even installing any software. Wo...

C++: Agregando tests unitarios a código Arduino

Versión en inglés / English version Una gran ventaja de tener tests unitarios puros es poder validar la lógica del código de manera aislada de las dependencias externas. En el caso de Arduino, es posible probar el sketch completo sin una placa física, y además, sin modificar el código original. En el libro "Working effectively with legacy code" , Michael Feathers habla del concepto de seam (costura). Para Feathers, un seam es un punto del código donde se puede reemplazar una dependencia externa con un objeto falso a fin de poder ejecutar el código en un ambiente de test. En el post de hoy, se verá un ejemplo concreto de técnicas para aprovechar estos seams . En particular, para un proyecto Arduino sencillo. Como punto de partida, considérese el siguiente proyecto Wokwi . Contexto: Wokwi es un sitio que permite crear proyectos Arduino en un navegador web, sin necesidad de placas físicas. Permite insertar y conectar componentes virtuales, y escribir código Arduino ...

New syntax highlighter: PrismJS

Spanish version / Versión en Español Who would have thought that this blog would live long enough to see a third change of syntax highlighter? Incredibly enough, Blogger is also alive and kicking. This site's administration has decided to retire highlightjs , which seems to be still alive, but has lost ground to prismjs . Obviously, it's subjective, but personally I have decided to favor Prism due to the following reasons: It managed to handle VB.NET code blocks better. Yes, I know it's not the most modern language, but we still hold some affection for it. It looks better: it's more compact, with a better color selection. It also highlights more keywords, at least for the languages we use here. It offers an extensible architecture, including a plugin system which allows, for example, adding line numbers. HighlighJS has no such feature. All of these extra features, and still Prism has a very small footprint. Without fu...

Nuevo resaltador de sintaxis: PrismJS

Versión en inglés / English version ¿Quién habría pensado que este blog viviría lo suficiente para ver un tercer cambio de resaltador de sintaxis? Increíblemente, también Blogger sigue vivo y coleando. La administración de este sitio ha decidido jubilar a highlightjs , que parece seguir con vida, pero ha perdido terreno ante prismjs . Obviamente es una cuestión subjetiva, pero personalmente me he decantado por prism por los siguientes motivos: Logró resaltar mejor los bloques de código VB.NET. Sí, sé que no es un lenguaje muy moderno que digamos, pero lo queremos igual. Se ve mejor: más compacto y con mejor selección de colores. También destaca más palabras. Ofrece una arquitectura extensible, incluyendo plugins para, por ejemplo, agregar números de línea. HighlightJS carece de esto. Todo esto y más, con un tamaño muy pequeño. Sin más preámbulo, veamos los pasos para empezar a usar prims en Blogger: En Blogger, seleccionado...

GNU Autotools I - Introduction

Spanish version / Versión en Español First thing first: what are GNU Autotools , and what are they used for? The moniker "GNU Autotools" refers to a collection of software packages: Autoconf , Automake and Libtool . These packages include programs aimed at standardizing and automating the build, test, release and installation processes across multiple platforms. In that sense, it shares a lot of goals and purpose with other tools such as CMake . Most of the GNU software is built using Autotools; git is a famous example. More specifically, what the Autotools do is generate configure scripts and Makefiles from certain configuration files. When generating these files, portability across different platforms is considered in order to allow the package to be built in as many different environments as possible. A user's perspective In this context, we will consider a user a person who downloaded a source tarball for some package, and wants to build it and inst...

GNU Autotools I - Introducción

Versión en inglés / English version En primer lugar: ¿qué son las Autotools de GNU , y para qué sirven? El nombre "GNU Autotools" se refiera a una colección de paquetes de software : Autoconf , Automake y Libtool . Estos paquetes contienen programas cuyo objetivo es estandarizar y automatizar los procesos de compilación, prueba, entrega e instalación a través de distintas plataformas. En ese sentido, comparte propósito con otras herramientas como CMake . Gran parte de el software de GNU ha sido creado con Autotools; git es un ejemplo célebre. Más específicamente, lo que las Autotools hacen es generar scripts y Makefiles a partir de archivos de configuración de entrada escritos por el desarrolador. Al generar estos scripts y Makefiles , se considera la portabilidad a través de distintas plataformas a fin de que el paquete funcione en la mayor cantidad de entornos posible. La perspectiva del usuario En este contexto, se considerará al usuario como una per...

Debug a C/C++ application which requires root privileges using Eclipse CDT

Image
Spanish version / Versión en Español Hi! It's been a long time, but this blog is not dead! It just happened that so far, I haven't ran into a case which hadn't been documented by someone else already. I am glad to inform that today, I found good enough reason to make a post, since the information was already in the web, but scattered among different sites. So I am putting it together here for future reference. Going back to the problem described in the title: initially, you would think that for a scenario like this, the only way is to run Eclipse itself with root privileges. However, security concerns aside, doing so would imply losing all the Eclipse settings, because they would be associated to the original non-root user. The optimal solution would be to refactor the application to avoid requiring root privileges. Sometimes, that can be achieved without even touching the app's source code. For example, it might be possible to define a user group with the...

Depurar una aplicación C/C++ que requiere privilegios de root usando Eclipse CDT

Image
Versión en inglés / English version ¡Hola! Ha pasado mucho tiempo, ¡pero este blog sigue con vida! El problema fue que en todo este tiempo, todos los temas con los que me topé ya estaban documentados en detalle en la web. Es un placer informar que hoy encontré una buena razón para postear, ya que la información estaba en la web, pero desperdigada entre diversos sitios. Así que la recopilé aquí para referencia futura. Volviendo al problema mencionado en el título: inicialmente, uno pensaría que para un escenario así, la única solución sería ejecutar Eclipse con privilegios administrativos, o sea como root . Sin embargo, más allá de los potenciales problemas de seguridad, hacer eso implicaría perder toda la configuración de Eclipse, porque la misma está asociada al usuario original, que no es root . La mejor solución sería refactorizas la aplicación para que no requiera privilegios administrativos. A veces, eso puede hacerse incluso sin tocar el código fuente. Por ejemplo, ...