This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* support ES Modules in Nodejs, | |
* running modules like we might in browsers and Deno | |
* | |
* works + tested in Nodejs 23 | |
* Nodejs 20.6 and up use --import and older use --experimental-loader: | |
node --import './node-esm.mjs' ./your-script.js | |
node --experimental-loader './node-esm.mjs' ./your-script.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
async fetch(req, env, ctx) { | |
let text = '-text-'; | |
const { url, method } = req; | |
if(req.method==='POST'){ | |
text = await req.text(); | |
console.log(`req>`, {url, method, text}); | |
debugger; | |
} | |
return new Response(` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sudo edit /etc/network/interfaces | |
# This file describes the network interfaces available on your system | |
# and how to activate them. For more information, see interfaces (5). | |
source /etc/network/interfaces.d/* | |
# The loopback network interface | |
auto lo | |
iface lo inet loopback | |
# allow hotplug | |
allow-hotplug enpos1 iface enposi inet dhep | |
# fallbacks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* convert lit templates and all their stuff and things to strings: | |
const things = 'things'; | |
lit_toString(html`<b>stuff and ${ [ things ] }</b>`) | |
// `<b>stuff and things</b>` | |
*/ | |
export function lit_toString(data) { | |
// template | |
const {strings = null, values = []} = data ?? {}; | |
// if not a template | |
if(!strings) return data ?? ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// astral alternative to puppeteer and playwright, similar API | |
// run: deno run -A ./uitest.js | |
// more at https://github.com/lino-levan/astral | |
import { launch } from "jsr:@astral/astral"; | |
const browser = await launch({ | |
headless: true, | |
// note will attempt to auto-install... to use local options use the path value | |
// macos | |
// path: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome' | |
// debian: sudo apt install chromium-browser chromium-codecs-ffmpeg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
needed to manage tab focus (focusin) events leading to the following selector to adjust; | |
reference | |
* https://html.spec.whatwg.org/multipage/dom.html#interactive-content | |
additional info: | |
* https://www.tpgi.com/using-the-tabindex-attribute/ | |
* https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex | |
and various linked/related in the above (or simply Google a bit) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
if (typeof document === 'undefined' || 'adoptedStyleSheets' in document) { | |
return; | |
} | |
var hasShadyCss = 'ShadyCSS' in window && !ShadyCSS.nativeShadow; | |
var bootstrapper = document.implementation.createHTMLDocument(''); | |
var closedShadowRootRegistry = new WeakMap(); | |
var _DOMException = typeof DOMException === 'object' ? Error : DOMException; | |
var defineProperty = Object.defineProperty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
REPLACED BY astral version at https://gist.github.com/jimmont/d70845b0fc7e673b1676fb08dd70d025 | |
*/ | |
import puppeteer from 'https://deno.land/x/puppeteer/mod.ts'; | |
import { assert } from 'https://deno.land/std/testing/asserts.ts'; | |
/* | |
related: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if( !('SubmitEvent' in self && 'submitter' in SubmitEvent.prototype) ){ | |
// polyfill SubmitEvent.submitter (a Safari issue as-of 2021) | |
// https://developer.mozilla.org/docs/Web/API/SubmitEvent | |
const submitter = Symbol.for('submitter'); | |
Event[ submitter ] = null; | |
const submitterSelector = 'input[type=submit], input[type=image], input[type=button], button'; | |
Object.defineProperty(Event.prototype, 'submitter', { | |
get: function(){ | |
if('submit' === this.type){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO cleanup | |
log/ | |
logs/ | |
**/log/ | |
**/logs/ | |
**/*.log | |
secrets.txt | |
.git |
NewerOlder