Skip to content

Instantly share code, notes, and snippets.

View christophemarois's full-sized avatar

Christophe Marois christophemarois

  • Pathway Medical
  • Montreal
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. 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.
@christophemarois
christophemarois / post-checkout
Created April 29, 2021 20:47 — forked from betorobson/post-checkout
git hook to run a command after `git pull` and `git checkout` if a specified file was change for example, package.json or bower.json
#!/usr/bin/env bash
# fork from https://gist.github.com/jakemhiller/d342ad51505addf78ec628a16fd3280f
changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
check_run package.json "npm prune && npm install"
@christophemarois
christophemarois / encode.py
Created October 28, 2020 16:11 — forked from gasman/encode.py
Encoding a file as a Youtube video - https://www.youtube.com/watch?v=hyqLv2_zBdA
# Encode inputfile.tar.gz as a series of video frames
# Frames are written to frames/frameNNNN.png
from PIL import Image
with open('inputfile.tar.gz', 'rb') as f:
data = f.read()
WIDTH = 120
HEIGHT = 90
CHUNK_SIZE = int((WIDTH * HEIGHT) / 8)
@christophemarois
christophemarois / jsbin.tinevo.css
Last active November 9, 2016 20:04 — forked from anonymous/index.html
Pronounceable hashes from integers with optional hash. Demo: http://jsbin.com/tinevo
html, body {
margin: 15px;
font-family: 'Helvetica Neue';
font-weight: 200;
}
* {
box-sizing: border-box;
}
@christophemarois
christophemarois / animate.js
Last active October 15, 2016 22:41 — forked from anonymous/index.html
Triggers a CSS animation from JS without class manipulation. Wrapped in a promise that resolves when animation is completed. Easily chainable. >IE10 when transpiled. Demo: http://jsbin.com/qibilaxehi
function animate (el, animationName, durationMs) {
return new Promise(res => {
const fn = e => {
if (!e.target.isEqualNode(el)) return false
el.removeEventListener('animationend', fn)
el.removeEventListener('webkitAnimationEnd', fn)
el.style.animationDuration = ''
el.style.webkitAnimationDuration = ''
el.style.animationName = ''
@christophemarois
christophemarois / horizontal-curve.js
Last active August 30, 2016 19:01 — forked from anonymous/index.html
Horizontal SVG curve generator http://jsbin.com/cimoqob/13
function horizontalCurve (w, h, opts = {}) {
let { fromBottom, vertical, offset } = Object.assign({
fromBottom: false,
vertical: false,
offset: 0
}, opts)
@christophemarois
christophemarois / generator.js
Last active August 29, 2016 23:44 — forked from anonymous/index.html
Curved SVG path generator. Demo: http://jsbin.com/cimoqob
function generateCurve (x1, y1, x2, y2, verticalBias) {
var line = []
var mx = x1 + (x2 - x1) / 2
line.push('M', x1, y1)
if (verticalBias) {
var my = y1 + (y2 - y1) / 2
line.push('C', x1, my, x2, my, x2, y2)
input[type="text"][role="password"] {
width: 200px;
padding: 5px 7px;
font-size: 14px;
}