3 June 2023
<iframe id="blankiframe"
title="blank iframe example"
width="0"
height="0"
sandbox="allow-scripts"
// 11 July 2023 | |
// call or apply: which do I use? | |
// should I distinguish between a single argument vs. an array of arguments? | |
// I've seen code like the following too many times used to determine whether to | |
// use `call()` or `apply()` on a function based on the number of arguments to | |
// be passed into that function: | |
/* | |
``` |
// gist 700! | |
// 7 July 2023 | |
// Using XHR to parse local HTML strings into DOM documents | |
// to get around "trusted HTML" and other DOMParser/innerHTML hogwash. | |
// 22 July 2023 | |
// Added <img src="evil" onerror="alert('pwnd')"> | |
// If src is blocked by CSP img-src or default-src, Firefox does not execute onerror, | |
// but Chrome still executes it. |
// 7 July 2023 | |
// using setHTML to get around the Trusted HTML CSP restricted apps. | |
// Our HTML fragment text | |
var source = ` | |
<section id="x-fragment"> | |
<fake>&& < < title</fake> | |
<meta charset="UTF-8"> | |
<script>alert(1);</script> |
// 21 June 2023 | |
// poc: create a worker that enforces access by address | |
var source = ` | |
self.address; | |
self.onmessage = function (e) { | |
console.warn("init"); | |
if (e.data.action !== 'init') { |
// 14 June 2023 | |
// latest: 16 July 2023 | |
// `touch` makes objects with dynamic access-definable pathnames, | |
// for potentially deep undefined object paths in JavaScript, | |
// using the Proxy constructor. | |
// So instead of optional?.chaining, we can get a proxy as with |
// 14 June 2023 | |
// an equals function for comparing two arrays in JavaScript | |
// how we compare two arguments for equality: | |
// both are arrays | |
// with same length | |
// with same items at same indexes | |
// why this does not exist in the JavaScript built-in space: sorting. |
21 May 2023
Thinking about this for a couple weeks.
21 May 2023
Two giants. Both wrong. Tell me why.
Parnas: Software ages and decays and must be maintained, even corrected. https://www.cs.drexel.edu/~yfcai/CS451/RequiredReadings/SoftwareAging.pdf
Lamport: Software is a mathematical expression. Its correctness never changes.
// 13 May 2023 | |
// SHA3 512-bit encoding function in JavaScript | |
// expanded version of filip dimitrovsky's answer on stackoverflow | |
// using the browser's crypto API | |
// https://stackoverflow.com/a/55926440 | |
function sha512(src, fn) { | |
var s = '' + src; | |
var e = new TextEncoder('utf-8'); | |
var c = e.encode(s); |