Distintos formatos para módulos en JavaScript

Existen distintos formatos ya que JavaScript originalmente no incluía el concepto de modulos.

Asynchronous Module Definition (AMD)

Es usado por los navegadores.
Utiliza define como palabra reservada.

// suma.js
define(function() {
  return suma = function(r) {
    return r + r;
  }
});


// index.js
define(function(require) {
  require('./suma');
  suma(4); // = 8
}

CommonJS (CJS)

Se usa en npm y Node.js.
Utiliza require y module.exports para definir las dependencias de los modulos.

// utils.js
function suma(r){
  return r + r;
}
exports.suma = suma;


// index.js
var utils = require('./utils.js');
utils.suma(4); // = 8

ES Module (ESM).

Es parte del lenguaje nativo a partir de ECMAScript 6.
Utiliza import y export para definir las dependencias de los modulos.
La keyword System.register se diseño para dar soporte a los modulos en ECMAScript 5.

// suma.js
 export function suma(r) {
   return r + r;
 }


 // index.js
 import suma from "./suma";
 suma(4); // = 8

Universal Module Definition (UMD)

Se puede usar en el navegador y en Node.js.
https://github.com/umdjs/umd/tree/master/templates

CI con .Net y GitHub Actions

Crear un archivo .yml en el directorio .github\workflows

vs code

Se deben definir las acciones, revisar la documentación para definir las acciones.

name: Integration

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Setup .NET SDK
        uses: actions/setup-dotnet@v1.7.2
        with:
          dotnet-version: 5.0.x

      - name: Restore
        run: dotnet restore

      - name: Build
        run: dotnet build --configuration Release --no-restore

      - name: Test
        run: dotnet test --no-restore

Al subir el archivo yml github actions ejecuta la compilacón del codigo.

github

Nullish coalescing operator

Is a binary operator that is part of the syntax for a basic conditional expression in several programming languages, the null coalescing operator generally returns the result of its left-most operand if it exists and is not null, and otherwise returns the right-most operand. This behavior allows a default value to be defined for cases where a more specific value is not available.

1
string pageTitle = suppliedTitle ?? "Default Title";

Exclude a column using select all from table?

https://stackoverflow.com/questions/729197/sql-exclude-a-column-using-select-except-columna-from-tablea

Relevant answers:

If you want to exclude a sensitive case column like the password for example, I do this to hide the value :

SELECT * , "" as password FROM tableName;

A modern SQL dialect like BigQuery proposes an excellent solution

SELECT * EXCEPT(ColumnNameX, [ColumnNameY, ...])

This is a very powerful SQL syntax to avoid a long list of columns that need to be updated all the time due to table column name changes.

You could create a view that has the columns you wish to select, then you can just select * from the view.

Conventional Commits

The Conventional Commits specification is a lightweight convention on top of commit messages. It provides an easy set of rules for creating an explicit commit history; which makes it easier to write automated tools on top of. This convention dovetails with SemVer, by describing the features, fixes, and breaking changes made in commit messages.

The commit message should be structured as follows:

1
2
3
4
5
<type>[optional scope]: <description>

[optional body]

[optional footer(s)]

Deshabilitar el tooltip de las pestañas de Google Chrome

A partir de la version 78 de chrome el navegador introdujo un tooltip para las tabs que incluye el titulo de la pagina y la dirección URL.
En el futuro este tooltip va a incluir una vista previa de la pagina abierta en la pestaña.

image

Si no estas comodo con este cambio aqui te mostrare como revertir a las tooltips clasicas de chrome.

Pasos para deshabilitar el nuevo tooltip.

  1. Abrir chrome y colocar la siguiente direccion en la barra de direcciones

    1
    chrome://flags/#tab-hover-cards
  2. Seleccionar lo opción deshabilitar de la lista que aparece.

image

  1. Cerrar, abrir el navegador y comprobar que el tooltip es el clasico.

image