Skip to content

Instantly share code, notes, and snippets.

View fernandocanizo's full-sized avatar
🎃
Working from home

Fernando Lucio Canizo fernandocanizo

🎃
Working from home
View GitHub Profile
@fernandocanizo
fernandocanizo / esm-package.md
Created February 15, 2024 13:15 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@fernandocanizo
fernandocanizo / sherpa-challenge-v0.js
Last active January 11, 2023 18:57
sherpawmc.cl interview challenge
// On-interview challenge: not working
// ratón encontrar queso en laberinto
// representación de datos corre por mi cuenta
// asumo laberinto cuadrado
// asumo no se mueve en diagonal
const laberinto = [
// [0, 0, 2],
// [0, 1, 1],
@fernandocanizo
fernandocanizo / util.parseArgs.mjs
Created August 18, 2022 15:36
a simple sample usage for node:util.parseArgs
#!/usr/bin/env node
// sample usage of util.parseArgs
import {parseArgs} from 'node:util';
const options = {
help: {
type: 'boolean',
@fernandocanizo
fernandocanizo / better-nodejs-require-paths.md
Created November 11, 2021 16:40 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@fernandocanizo
fernandocanizo / passgitgpg.md
Created June 18, 2021 09:11 — forked from flbuddymooreiv/passgitgpg.md
Setting up pass on git with a gpg key

The following shell transcript shows how to:

  • Create a GPG key
  • Create a pass database
  • Add git support to the pass database
  • Create a remote git repository
  • Push the pass database to the remote git repository
  • Fetch and display your passwords from another host

It is assumed that the pass package has been installed on both the first and second computers.

@fernandocanizo
fernandocanizo / not-working-hyperhtml-component
Created March 2, 2020 21:56
Non working hyperhtml component
// sample code taken from
// https://medium.com/easy-apps-with-hyperhtml/easy-apps-with-hyperhtml-2-1d60fd41bb67
// under "Components" subtitle
import hyperHTML from 'https://unpkg.com/hyperhtml?module';
const Table = {
html: hyperHTML.bind(document.getElementById('table')),
data: [
{ label: 'one', value: 1 },
@fernandocanizo
fernandocanizo / psql_useful_stat_queries.sql
Created February 20, 2019 15:33 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@fernandocanizo
fernandocanizo / adaptive.rounds.calculator.for.bcryptjs.js
Last active June 27, 2018 21:07
Calculate proper number of required rounds for bcryptjs hashing on current hardware
'use strict';
const bcrypt = require('bcryptjs');
const getCost = async () => {
// This code will benchmark your server to determine how high of a cost
// you can afford. You want to set the highest cost that you can
// without slowing down you server too much. 8-10 is a good baseline,
// and more is good if your servers are fast enough. The code below
// aims for ≤ 50 milliseconds stretching time, which is a good baseline
@fernandocanizo
fernandocanizo / fantasy.animal.generator.js
Last active May 8, 2018 13:36
fantasy animal generator
'use strict';
const randomItem = (itemsArray) => itemsArray[Math.floor(Math.random() * itemsArray.length)];
const makeFantasyAnimal = () => {
const animales = ['perro', 'gato', 'jirafa'];
const verbos = ['escupe', 'caga', 'estornuda'];
const elementos = ['fuego', 'hielo', 'moco'];
return `${randomItem(animales)} ${randomItem(verbos)} ${randomItem(elementos)}`;