Skip to content

Instantly share code, notes, and snippets.

@JanMiksovsky
JanMiksovsky / launch.json
Created July 12, 2024 21:56
VS Code launch configuration to run the "start" script when you select Start Debugging
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
// This configuration tells VS Code to launch the project via `npm start`.
"type": "node",
"request": "launch",
@JanMiksovsky
JanMiksovsky / writeFileString.js
Created June 27, 2024 21:46
Measure difference in performance of writeFile(string value) vs writeFile(String object)
import fs from "node:fs/promises";
// Create a 1MB string value to a file
const string = "a".repeat(1000000);
const startValue = performance.mark("string");
await fs.writeFile("1MB.txt", string);
const measureValue = performance.measure("write string value", startValue);
console.log(`${measureValue.name}: ${measureValue.duration}ms`);
// Write the string as a String object
@JanMiksovsky
JanMiksovsky / tenHundredWords.txt
Last active January 22, 2023 18:24
The list of 10 Hundred words from Randall Monrole's book "Thing Explainer" (https://xkcd.com/thing-explainer), verified against the list provided at the back of the book
a
able
about
above
accept
across
act
actually
add
admit
@JanMiksovsky
JanMiksovsky / index.html = this().ori
Last active October 18, 2022 23:20
A trivial site using data and templates
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Reviews</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<h1>Reviews</h1>
<div class="cards">
@JanMiksovsky
JanMiksovsky / reviewSite.yaml
Last active August 30, 2023 15:53
A trivial self-contained demo site built with Graph Origami
# This is a trivial self-contained demo site built with Graph Origami.
reviews.yaml:
- summary: Positive reinformement and insight.
rating: 5
location: Southampton, NY
coach: Sue
text: |
Thanks for allowing me to talk things out. It makes it easier to get some
clarity.
@JanMiksovsky
JanMiksovsky / site.yaml
Created September 6, 2022 23:39
Simple toy site packaged as a YAML file
index.html: |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="styles/styles.css" />
</head>
<body>
<h1>Home page</h1>
@JanMiksovsky
JanMiksovsky / abTest.meta
Last active October 18, 2022 23:53
Graph Origami demo of an A/B test overlaying experimental files on top of control files
control:
index.html: |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="styles/styles.css" />
</head>
<body>
@JanMiksovsky
JanMiksovsky / elementReferences.md
Created February 10, 2021 19:16
Exploring indirect AOM element references to bridge light/shadow DOM

Indirect ARIA element references

This illustrates the possibility of indirecting AOM element references so that they work across shadows. The main ideas are:

  1. Use custom element code to coordinate references light DOM and shadow DOM.
  2. Ensure that AOM references can be indirected: if element A references B for a label, and B references C for a label, then A ends up getting its label from C.
  3. Let the custom element host serve as an indirection point between the light and shadow DOM.
  4. Define fallback AOM properties on elementInternals that are used if the corresponding properties are not set on the host. This lets a host reference elements in its own shadow without exposing those references.

Adapting a combo box example from Alice Boxhall.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<script
type="module"
src="https://cdn.jsdelivr.net/gh/elix/elix@main/define/ListComboBox.js"
></script>
@JanMiksovsky
JanMiksovsky / StoryBrowser.js
Created October 27, 2020 00:10
Lightweight demo/story browser web component in plain JavaScript, no dependencies
/**
* Lightweight demo/story browser in plain JavaScript, no dependencies.
*/
// Semi-private fields stored via Symbol keys on an element instance.
const defaultPathKey = Symbol();
const linksKey = Symbol();
const pathKey = Symbol();
// The template for the component's shadow tree.