Skip to content

Instantly share code, notes, and snippets.


Jim Montgomery jimmont

View GitHub Profile
jimmont / polyfill.Events.js
Created Apr 27, 2021
Event related polyfills (for evergreen browsers)
View polyfill.Events.js
if( !('SubmitEvent' in self && 'submitter' in SubmitEvent.prototype) ){
// polyfill SubmitEvent.submitter (a Safari issue as-of 2021)
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 / .dockerignore
Created Feb 19, 2021
Deno on Cloud Run
View .dockerignore
# TODO cleanup
jimmont / ReactHTM.html
Created Nov 16, 2020
use HTM to reduce work in React apps by removing the need for JSX translation in build processes
View ReactHTM.html
<!doctype html>
<html lang="en">
<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">
jimmont / websockets.js
Created Jul 27, 2020
http upgrade websocket
View websockets.js
running with Deno 1.2
deno run --inspect --allow-net ./websockets.js
import { Application, Router, HttpError, send, Status } from "";
import { isWebSocketCloseEvent } from "";
const port = 8123;
const users = new Set();
const app = new Application({state:{users}});
View linkedlist.js
add,remove,length, reverse
class List{
class Node{
jimmont / jsx-template-transformer.js
Last active Feb 26, 2020
transform jsx to tagged template literals
View jsx-template-transformer.js
transform JSX to tagged template literals
2019-01-25 initial working draft
jimmont / flat-arbitrary.js
Last active Feb 22, 2020
array flat arbitrary
View flat-arbitrary.js
Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
Your solution should be a link to a gist on with your implementation.
When writing this code, you can use any language you're comfortable with. The code must be well tested and documented. Please include unit tests and any documentation you feel is necessary. In general, treat the quality of the code as if it was ready to ship to production.
Try to avoid using language defined methods like Ruby's Array#flatten or JavaScript's Array.flat.
View amazing.js
// I always do this. Always.
Object.values(Array(6,7,8)).length === Number(Object.keys([7,6,4]).pop()) + 1
jimmont / validations.js
Last active Sep 18, 2019
validate email addresses, dates, etc in JavaScript
View validations.js
take an approach leveraging the platform implementation's internal parser for things to validate,
if it works in these on the user-experience side confirm the input is as-intended
possibly by entering the same value twice or similar user-controlled validation
email and date validation is too complex for pattern matching;
function validEmail(email=''){
var $0, url, isValid = false, emailPatternInput = /^[^@]{1,64}@[^@]{4,253}$/, emailPatternUrl = /^[^@]{1,64}@[a-z][a-z0-9\.-]{3,252}$/i;
jimmont / the-controls.js
Created Jun 28, 2018
SF muni map for code review feedback (and self-improvement)
View the-controls.js
// see
class TheControls extends HTMLElement{
// {tags: {N: {}...}, taglist: []} = {};
this.addEventListener('click', this.clicked);