Skip to content

Instantly share code, notes, and snippets.

View ehaynes99's full-sized avatar

Eric Haynes ehaynes99

View GitHub Profile
@joepie91
joepie91 / es-modules-are-terrible-actually.md
Last active May 19, 2024 12:14
ES Modules are terrible, actually

ES Modules are terrible, actually

This post was adapted from an earlier Twitter thread.

It's incredible how many collective developer hours have been wasted on pushing through the turd that is ES Modules (often mistakenly called "ES6 Modules"). Causing a big ecosystem divide and massive tooling support issues, for... well, no reason, really. There are no actual advantages to it. At all.

It looks shiny and new and some libraries use it in their documentation without any explanation, so people assume that it's the new thing that must be used. And then I end up having to explain to them why, unlike CommonJS, it doesn't actually work everywhere yet, and may never do so. For example, you can't import ESM modules from a CommonJS file! (Update: I've released a module that works around this issue.)

And then there's Rollup, which apparently requires ESM to be u

@sindresorhus
sindresorhus / esm-package.md
Last active May 28, 2024 03:56
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.
@mkweskin
mkweskin / gist:e531e65791c1d8036dd720ef3baf8af6
Created January 22, 2020 20:12
Github markdown to Jira/Confluence markup using pandoc
pandoc -f gfm -w jira -o outfile.jira infile.md
# To import converted file into Confluence:
# - Create new page
# - Click on the body of the page, click on the " + \/" dropdown in toolbar ("Insert more content") and select "Markup"
# - Paste the contents into the pop-up window (select "Confluence wiki" as the format)
# - Note: The "Markdown" option in the import pop-up doesn't seem to work for Github flavored markdown (gfm).

Demo:

Spoiler warning

Spoiler text. Note that it's important to have a space after the summary tag. You should be able to write any markdown you want inside the <details> tag... just make sure you close <details> afterward.

console.log("I'm a code block!");
@hugosp
hugosp / app.js
Created April 4, 2016 22:37
Minimal express-ws broadcast to all clients
var express = require('express');
var expressWs = require('express-ws');
var expressWs = expressWs(express());
var app = expressWs.app;
app.use(express.static('public'));
var aWss = expressWs.getWss('/');
app.ws('/', function(ws, req) {
@Ajido
Ajido / ioredis-sample.js
Last active August 4, 2022 14:30
Node.js Redis Sentinel
'use strict';
let Redis = require('ioredis');
let redis = new Redis({
sentinels: [
{ host: '127.0.0.1', port: 15379 },
{ host: '127.0.0.1', port: 15380 },
{ host: '127.0.0.1', port: 15381 }
],
name: 'mymaster'
@Kartones
Kartones / postgres-cheatsheet.md
Last active May 27, 2024 08:12
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)