- Install https://pngquant.org/
$ brew install pngquant
const files = { | |
"m1.js": `import {func} from './m2.js'; console.log(func());`, | |
"m2.js": `export function func() { return 'abc'; }` | |
} | |
const urls = new Map | |
function getURL(filename) { | |
let url = urls.get(filename) | |
if (!url) { |
$ brew install pngquant
GitHub uses the following CSS font stack to display code:
font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, Courier, monospace;
Chrome will use SFMono-Regular
when that font is installed locally, but Firefox will not. Workaround: Add the following CSS to your Firefox profile's userContent.css
file:
@font-face {
<!doctype html> | |
<html> | |
<head> | |
<title>Custom elements test</title> | |
</head> | |
<body> | |
<h3>Custom elements from HTML</h3> | |
<ol class="from-html" start="0"> |
This is the example webpack.config.js
on https://webpack.js.org/:
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
}
}
getHexColor = (color) -> | |
return "" unless color | |
return color if /^#/.test(color) | |
rgbValues = getRGBValues(color) | |
hexValues = rgbValues.map(numberToHex) | |
"#" + hexValues.join("") | |
numberToHex = (number) -> | |
"0#{number.toString(16)}".slice(-2).toUpperCase() |
(async () => { | |
if (await mutionObserverIsBuggy()) { | |
patchInnerHTML() | |
} | |
})() | |
function mutionObserverIsBuggy(): Promise<boolean> { | |
return new Promise(resolve => { | |
const element = document.createElement("div") | |
element.innerHTML = "<a><em></em></a>" |
https://github.com/rails/activestorage/pull/81
// direct_uploads.js
addEventListener("direct-upload:initialize", event => {
const { target, detail } = event
const { id, file } = detail
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
</head> | |
<body> | |
<div style="margin: 20px;"> | |
<p> | |
<webview> visibilityState: <strong id="visibility-state"></strong> | |
<button id="update-visibility-state">Update</button> |
BC.registerElement "bc-require", | |
createdCallback: -> | |
@setAttribute("pending", "") | |
attachedCallback: -> | |
BC.ready => | |
if Loader.find(@script)?.loaded | |
@activate() | |
else | |
@deactivate() |