Posts

Generative AI (GenAI) aplicada al código

Image
En mi artículo Generative AI (GenAI) aplicada al código me refiero a una expresión específica que son los campos de tipo texto en componentes Angular. Este artículo trata de la exploración primera que hice para entrenar a GenAI en la generación del código para esos campos de texto. Por supuesto, se aplica a cualquier tipo de código, pero por algún lugar hay que comenzar así que: tercera llamada, tercera...¡comenzamos! Cualquiera que haya codificiado componentes Angular puede dar testimonio de la uniformidad a la que tienden. Después de los primeros, cuya creación aporta la alegría del aprendizaje, los subsecuentes dejan poco o nada, pero sí se llevan el valioso recurso del tiempo. Supóngase que se tiene que crear una página web que permita hacer transferencias entre cuentas bancarias. El usuario verá tres campos de tipo texto que son: cuenta origen, cuenta destino y monto de la transferencia. Los tres campos son requeridos. Las cuentas son de tres dígitos y el monto puede ser hast...

Software, the war, the battles

In general terms, the word "War" has a bad connotation. Many lives have been lost and so much suffering caused since the very first dispute over some land or water source, don't make an easy task to argue in favor of war. However, bitter experiences leave lessons and learnings that I can list but, sincerely, I doubt myself doing a better job than what the excellent Lean Enterprise book does as follows: Napoleon used a style of war known as maneuver warfare to defeat larger, better-trained armies. A key element in maneuver warfare, the goal is being able to learn, make decisions, and act faster than your enemy. The Prussian Army, following its defeat by Napoleon, led by Carl von Clausewitz, David Scharnhorst, and Helmuth van Moltke, not only was reconstructed but improved through the idea of Auftragstaktik or Mission Command. Mission Command details go beyond this article but I extract the following as its main contributions: To recognize the authority to make decis...

Unit Testing Solidity Smart Contracts

Image
Hello, world! I consider unit testing one of the most important techniques and habits to create quality in applications from the very beginning. With the advent of Blockchain and Solidity smart-contracts, I keep the habit and continuously looking for improve it. In particular with Blockchain , I don't think the way to test a smart contract is through deploy it to Ganache , set breakpoints through the code of interest, printf-like debug, and tricks like that. There's nothing wrong with them except that this requires to develop a client application (say, an HTML page with web3.js ) and, when testing is against a running Blockchain , it consumes more time and resources. Unit testing works better, is cheaper, and increases productivity while makes the smart contract more resilient to adapts and changes. This article is about using JavaScript to unit test a Solidity smart contract. It assumes you are familiarized with Truffle Framework , the Solidity programming language, Mocha ...

Angular, Azure AD, and Microsoft Graph

Image
Hello, world! In this post I do a 101 intro on Microsoft Graph , an important part of Azure AD and related platforms like Office 365 , and it assumes you have read Angular6 and Azure AD and Angular and Azure AD with a better UX . Microsoft Graph is extensively documented by Microsoft and I extend an invitation to read it starting here . Here is my highly irresponsible definition of Microsoft Graph : I like to think of it as a repository made of nodes connected with each other with the user node being the main. Every node contains data about it and more can be found by traversing the net (graph). For example, a user node contains her name, phone, and email whereas, by traversing the graph, we can find the list of meeting attendees in a given calendar day scheduled through Office 365 . In this post, Microsoft Graph is used to honor a Marketing requirement for greeting the user with the shorter first name instead of the full name because that leaves more room for pleasant ads ;). Th...

Angular and Azure AD with a Better UX

Image
Hello, world! In this post I improve the user experience by adding Bootstrap and greeting the user by her name once she is logged in. It assumes you have read Angular6 and Azure AD . A Better UX It makes little or no sense to have both Login and Logout buttons visible at the same time. Essential state management: the Login button must be visible when the user is not authenticated and Logout must be when she is. This will be accomplished by modifying AuthService and AppComponent . Let's start with AuthService where the userLoggedIn property is added and set when a successful authentication took place and unset when the user logs out: import * as Msal from 'msal'; import { Injectable } from '@angular/core'; import { Observable, from } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class AuthService { private userAgentApplication: Msal.UserAgentApplication; private _userLoggedIn: boolean; get userLoggedIn(): boolean { ...

Angular and Azure AD

Image
Hello, world! In this post I do a basic implementation of an Angular6 Single Page Application (SPA) using Azure AD to authenticate users. It assumes you have an Azure AD domain and Angular6 experience. Note: I strongly recommend you to read about OpenID , OAuth2 , and how Microsoft supports those. In particular, take a look at "OAuth 2.0 - Looking Back and Moving On" by Eran Hammer. It's awesome! Azure AD Azure AD plays the role of an Identity Provider or IdP. It supports OpenID and OAuth so everything you learn about those are more than very welcome to have a better understanding of what is setup and configured in the Azure portal starting with the app registration in the domain where it will be used. In this case, it is an Angular6 SPA web app in my domain (illyum). Below is the Azure portal page where the registration takes place: Azure AD Application Registration By clicking on New application registration , a form is displayed with some inform...