Skip to content

Instantly share code, notes, and snippets.

View dgraham's full-sized avatar
💭

David Graham dgraham

💭
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active May 3, 2024 10:19
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.
@muan
muan / details-links.md
Last active December 21, 2019 10:34
Details on details cheatsheet.
@dgraham
dgraham / osx-setup.sh
Last active April 6, 2024 17:18
A setup script for macOS development.
xcode-select --install
if [ ! -x /opt/homebrew/bin/brew ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew tap 'homebrew/bundle'
brew tap 'homebrew/services'
brew install automake clang-format cmake icu4c libressl libxml2 openssl pkg-config readline sqlite yajl
@jcgregorio
jcgregorio / How_to_use.html
Last active July 17, 2023 14:44
HTML Templating using the HTML <template> element and exactly 100 lines of JS. A cleaned up version of this code is now available at https://github.com/jcgregorio/stamp/.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="templating.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<template id=t>
@dgraham
dgraham / fetch.js
Last active March 24, 2023 15:44
Simple window.fetch wrapper.
(function() {
function status(response) {
if (response.ok) {
return response
} else {
var error = new Error(response.statusText || response.status)
error.response = response
throw error
}
}
@dgraham
dgraham / template.js
Last active February 2, 2018 10:17
Minimum Viable Mustache
// $ traceur --experimental --out template-es6.js template.js
function escape(text) {
let el = document.createElement('p')
el.textContent = text
return el.innerHTML
}
function node(html) {
let parser = new DOMParser()