Skip to content

Instantly share code, notes, and snippets.

View jimmont's full-sized avatar

Jim Montgomery jimmont

View GitHub Profile
@jimmont
jimmont / etc-network-interfaces.txt
Created March 12, 2025 01:15
utm debian network working-fix (wifi, phone tethering, etc)
# 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
@jimmont
jimmont / lit_toString.js
Created February 24, 2025 15:58
lit templates toString: a template and its content converted to a string (LitElement)
/* 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 ?? '';
@jimmont
jimmont / uitest.js
Last active August 6, 2024 12:28
async Deno.test() tests
/*
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:
@jimmont
jimmont / uitest.js
Created August 6, 2024 12:26
browser ui testing, scraping, etc
// 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
/*
add,remove,length, reverse
{value,next}
*/
class List{
constructor(){
}
}
class Node{
@jimmont
jimmont / interactivecontent.js
Created December 13, 2021 18:00
interactive content HTML elements where tab through document gives focus
/*
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)
*/
(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;
@jimmont
jimmont / polyfill.Events.js
Created April 27, 2021 20:14
Event related polyfills (for evergreen browsers)
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){
@jimmont
jimmont / .dockerignore
Created February 19, 2021 05:17
Deno on Cloud Run
# TODO cleanup
log/
logs/
**/log/
**/logs/
**/*.log
secrets.txt
.git
@jimmont
jimmont / ReactHTM.html
Created November 16, 2020 07:42
use HTM to reduce work in React apps by removing the need for JSX translation in build processes
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" >
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
<title>use HTM to reduce work in React apps</title>
<meta name="description" content="example using HTM with React to replace JSX and reduce work">
<style>
html,body{margin:0;padding:0;min-width:320px;min-height:320px;box-sizing:border-box;background-color:#cf0;}
body{