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 / 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 / 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 / index.js
Created March 7, 2017 13:34 — forked from mpmckenna8/index.js
Super simple webpage with budo
// try to do some stuff here
var d3 = require('d3');
d3.select('body').append('text')
.text('hey now thats somethin a webpage without any writing any htmml')
console.log('yoyo')
@fernandocanizo
fernandocanizo / destructuring.js
Created September 9, 2016 12:17 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => {
return [1, 2, 3];
@fernandocanizo
fernandocanizo / xyz_vs_tms.md
Created August 26, 2016 20:05 — forked from tmcw/xyz_vs_tms.md
The difference between XYZ and TMS tiles and how to convert between them

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.

@fernandocanizo
fernandocanizo / json_postgres.js
Created July 28, 2016 16:14 — forked from gerzhan/json_postgres.js
Example of json document storage in postgresql and querying (with knex.js)
var connectionString = 'postgres://localhost:5432/postgres';
var Promise=require('bluebird');
var knex = require('knex')({
client: 'pg',
connection: {
user: 'postgres',
database: 'postgres',
port: 5432,
@fernandocanizo
fernandocanizo / gist:86d2430ae9b8d416ab19
Created December 21, 2015 02:29 — forked from mapio/gist:1050635
A test comparing defaultdict and groupby for grouping
from timeit import Timer
from operator import attrgetter
from random import randint
def timeit( stmt, setup ):
t = Timer(stmt=stmt, setup=setup)
print "%.2f usec/pass" % (100000 * t.timeit(number=10000)/10000)
class Person(object):
def __init__(self, age):