Skip to content

Instantly share code, notes, and snippets.

View dgp1130's full-sized avatar
💭
🐶

Douglas Parker dgp1130

💭
🐶
View GitHub Profile
@dgp1130
dgp1130 / README.md
Last active December 7, 2023 06:14
HydroActive Class vs Functional Syntax Optimizations

HydroActive Class vs Functional Syntax Optimizations

This attempts to analyze the optimziation behavior in V8 when using HydroActive class and functional components to try to quantify the performance difference. It uses a local build of d8 and follows advice in An Introduction to Speculative Optimization in V8

functional.js and class.js contain simplified implementations of defining custom element methods with the two designs. functional.output and class.output contain the output of running d8 on each file.

This file has been truncated, but you can view the full file.
[{"args":{"name":"swapper"},"cat":"__metadata","name":"thread_name","ph":"M","pid":0,"tid":0,"ts":0},
{"args":{"name":"Compositor"},"cat":"__metadata","name":"thread_name","ph":"M","pid":14332,"tid":15760,"ts":0},
{"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":14968,"tid":14284,"ts":0},
{"args":{"name":"Compositor"},"cat":"__metadata","name":"thread_name","ph":"M","pid":14968,"tid":15636,"ts":0},
{"args":{"name":"CrBrowserMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":10536,"tid":8436,"ts":0},
{"args":{"name":"ThreadPoolForegroundWorker"},"cat":"__metadata","name":"thread_name","ph":"M","pid":20416,"tid":7900,"ts":0},
{"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":14332,"tid":8892,"ts":0},
{"args":{"name":"CrRendererMain"},"cat":"__metadata","name":"thread_name","ph":"M","pid":20416,"tid":14496,"ts":0},
@dgp1130
dgp1130 / pquery.bzl
Last active June 5, 2022 14:07
Bazel Starlark query providers for target
"""Starlark script to nicely format providers of a target.
Usage:
bazel cquery --output starlark --starlark:file ${PATH_TO_THIS_FILE} //path/to/pkg:target
If you get "ERROR: --starlark:file :: Unrecognized option: --starlark:file", make sure you are
using `bazel cquery` **not** `bazel query`.
If you get "Error: Starlark computation cancelled: too many steps", you can try adding
`--max_computation_steps=9223372036854775807` to raise the limit to its maximum value.
@dgp1130
dgp1130 / dom.js
Last active March 8, 2022 05:27
HTML Fragments
/**
* Parse a network response as an HTML document fragment, then returns each
* top-level element.
*/
export async function parseDomFragment(res) {
// Parse a fully rendered document fragment from the network response.
const html = await res.text();
const contentType = res.headers.get('Content-Type');
if (!contentType)
throw new Error('Response has no Content-Type.');
@dgp1130
dgp1130 / LICENSE
Last active June 23, 2023 00:47
Better type inference of `querySelector()` via inferred Template Literal Types
Copyright (c) 2023 Douglas Parker
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
async function renderPromise(promise) {
if (promise.isResolved()) {
renderValue(promise.value);
} else {
renderLoading();
const value = await promise;
renderValue(value);
}
}
@dgp1130
dgp1130 / data.json
Created May 30, 2020 02:38
Lists all open bugs in the Angular CLI repo
{
"userName": "<github-username>",
"pat": "<personal-access-token-generated-from-github>"
}
@dgp1130
dgp1130 / README.md
Created April 30, 2020 04:04
Prototype Browser Extension Protocol Buffer Service

Prototype Browser Extension Protobuf Service

Gist can't have subdirectories, but this contains two packages.

All the files named protoc-plugin__* should actually be protoc-plugin/*.

Build

(cd protoc-plugin/ &amp;&amp; npm run build) &amp;&amp; npm run build
@dgp1130
dgp1130 / file.js
Last active August 7, 2016 07:42
Karma Babel Preprocessor cannot parse ES6 lambda syntax () -> {};
window.temp = "world";
let test = "hello";
window.test = test;
var { one, two } = { one: 1, two: 2 };
window.one = one;
window.two = two;
window.foo = function (bar = "bar") {