Skip to content

Instantly share code, notes, and snippets.

Avatar
🎃
Working from home

Fernando Lucio Canizo fernandocanizo

🎃
Working from home
View GitHub Profile
View better-nodejs-require-paths.md

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 Jun 18, 2021 — forked from flbuddymooreiv/passgitgpg.md
Setting up pass on git with a gpg key
View passgitgpg.md

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.

View not-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 Feb 20, 2019 — forked from anvk/psql_useful_stat_queries.sql
List of some useful Stat Queries for PSQL
View psql_useful_stat_queries.sql
--- 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
View fantasy.animal.generator.js
'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)}`;
View gist:2d3026a448a703e799346c5b9e8e6eaf
'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)}`;
@fernandocanizo
fernandocanizo / test2.geojson
Last active Sep 28, 2017
Testing geojson gist 2
View test2.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fernandocanizo
fernandocanizo / test.geojson
Created Sep 28, 2017
Testing geojson gists
View test.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View See the stack trace from unhandled promise rejections
'use strict';
// Comment `process` usage to see the cryptic message
const process = require('process');
process.on('unhandledRejection', reason => console.error(reason));
const foo = () => {
return new Promise((undefined, reject) => {
reject(new Error('RECHAZÁU!'));
});