Skip to content

Instantly share code, notes, and snippets.


Dennis Morhardt gglnx

View GitHub Profile

Pure ESM package

The package linked to from 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.
View tlsa.js
'use strict';
const fs = require('fs');
const os = require('os');
const Path = require('path');
const hdns = require('hdns');
const {encoding} = require('hdns/node_modules/bcrypto');
const {pem} = encoding;
const host = process.argv[2];
tigt / git-branch-to-favicon.js
Created Mar 18, 2020
Creates an SVG string that can be used as a favicon across different Git branches. Actually getting this into the browser is sadly project-specific.
View git-branch-to-favicon.js
const { execSync } = require('child_process')
const { createHash } = require('crypto')
const invertColor = require('invert-color')
const branchName = execSync('git rev-parse --abbrev-ref HEAD')
const hash = createHash('sha256')
const color = '#' + hash.digest().toString('hex').substring(0, 6)
const invertedColor = invertColor(color, true)
monachilada / gatsby-config.js
Last active Oct 16, 2020
Sample gatsby-config.js enabling live preview in Craft CMS
View gatsby-config.js
const { createHttpLink } = require('apollo-link-http');
const fetch = require('node-fetch');
const store = require('store');
const sourceNodes = require('gatsby/dist/utils/source-nodes');
const craftGqlUrl = process.env.CRAFT_GQL_URL;
const craftGqlToken = process.env.CRAFT_GQL_TOKEN;
module.exports = {
lisawolderiksen /
Last active Sep 28, 2022
Use a Git commit message template to write better commit messages

Using Git Commit Message Templates to Write Better Commit Messages

The always enthusiastic and knowledgeable mr. @jasaltvik shared with our team an article on writing (good) Git commit messages: How to Write a Git Commit Message. This excellent article explains why good Git commit messages are important, and explains what constitutes a good commit message. I wholeheartedly agree with what @cbeams writes in his article. (Have you read it yet? If not, go read it now. I'll wait.) It's sensible stuff. So I decided to start following the

philipboomy / gist:b4f22c26cca62f0779714ac97ebe7cb2
Last active Oct 25, 2019
Laravel Mix 4 with Tailwind and Purge
View gist:b4f22c26cca62f0779714ac97ebe7cb2
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
.postCss('src/css/main.css', 'css')
postCss: [tailwindcss('tailwind.config.js'), require('autoprefixer')],
processCssUrls: false,
View handshake-cli-walkthrough
# set an env var to the path to a config
export REGTEST_CONFIG=$HOME/.config/hsd/regtest.conf
# this assumes you have git cloned and npm installed handshake
# be sure to start your handshake node with the same config
# ./bin/hsd --config=$REGTEST_CONFIG
# the cli tools live in node_modules/.bin
# also depends on jq
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
oliveratgithub / emojis.json
Last active Oct 1, 2022
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
View emojis.json
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family: woman, woman, girl, girl", "shortname": ":woman_woman_girl_girl:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128103;", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family: woman, woman, girl, boy", "shortname": ":woman_woman_girl_boy:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F466", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128102;", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family: woman, woman, boy, boy", "shortname": ":woman_woman_boy_boy:", "unicode": "1F469 200D 1F469 200D 1F466 200D 1F466", "html": "&#128105;&zwj;&#128105;&zwj;&#128102;&zwj;&#128102;", "category": "People & Body (family)", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family: man, woman, girl, girl", "shortname": ":man_woman_girl_girl:", "unicode": "1F468 200D 1F469 200D 1F467 200D 1F467", "html": "&#128104;&zwj;&#128105;&z
simevidas / App.js
Last active Jan 8, 2017
Autobound async class method (minimal example in Preact)
View App.js
import { h, Component, render } from 'preact';
import autobind from 'autobind-decorator';
import 'normalize.css';
import 'App.scss';
import Header from 'Header';
class App extends Component {