Skip to content

Instantly share code, notes, and snippets.

Jim Montgomery jimmont

Block or report user

Report or block jimmont

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jimmont
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
jimmont / the-controls.js
Created Jun 28, 2018
SF muni map for code review feedback (and self-improvement)
View the-controls.js
// see https://www.jimmont.com/sfmuni/
class TheControls extends HTMLElement{
constructor(){
super();
this.attachShadow({mode:'open'});
// {tags: {N: {}...}, taglist: []}
this.data = {};
this.addEventListener('click', this.clicked);
}
clicked(e){
@jimmont
jimmont / zfs-filesystem-basics.md
Last active Dec 9, 2018
zfs basic usage notes
View zfs-filesystem-basics.md

late 2018 encrypted disk per https://openzfsonosx.org/wiki/Encryption

create new encrypted disk
plug in device
$ diskutil list
important to be absolutely certain of the device
$ sudo zpool create -f -o ashift=12 -O compression=lz4 -O casesensitivity=sensitive -O atime=off -O normalization=formD -O encryption=on -O keylocation=prompt -O keyformat=passphrase NAMEOFIT /dev/disk####
will interactively prompt for passphrase
next time importing plug in the device
@jimmont
jimmont / mssql.notes.txt
Last active Sep 20, 2018
mssql on macos setup notes
View mssql.notes.txt
§ install
1. install Homebrew https://docs.brew.sh/Installation.html
2. install Docker
$ brew cask install docker
this places the Docker.app in the Applications folder, and can be launched directly to start the service
3. install mssql per the instructions https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker
$ sudo docker pull microsoft/mssql-server-linux:2017-latest
4. run the image, check the status
$ sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_PID=Developer' -e 'MSSQL_SA_PASSWORD=<password>' -p 1433:1433 --name mssql0 -d microsoft/mssql-server-linux:2017-latest
View reading-list.html
<pre>
* https://google.github.io/styleguide/jsguide.html
* nytimes.com
* washingtonpost.com
*
</pre>
@jimmont
jimmont / normal.js
Last active Aug 27, 2017
collection to sync various api details in Safari-current and Chrome-current
View normal.js
if(!Event.prototype.hasOwnProperty('path')){
/*
in event handlers use the event.path which looks like:
for attached DOM nodes [target,target.parentNode,...<ancestors>...,document,window]
for unattached DOM nodes [target]
for window and document: [window] [document, window]
*/
Object.defineProperty(Event.prototype, 'path', {
// for Safari
get:function(){
@jimmont
jimmont / v8-notes.txt
Last active May 21, 2017
Nodejs general notes.
View v8-notes.txt
authoritative sources:
https://github.com/nodejs/node/wiki
https://nodejs.org/en/security/
https://nodejs.org/
https://nodejs.org/en/docs/
TODO (arguably) the wiki could use more material currently spread across the internet
injection/input escaping:
TODO what are the modules/strategies necessary for managing input that moves through the application
@jimmont
jimmont / webcomponents.html
Last active Jul 6, 2018
web component v1 notes
View webcomponents.html
web components v1 (not v0)
~July 2018
various npm installed components which use named imports like `import "@name"`;
instead of a build tool or service just do a one-time conversion when updating for predictability and simplicity using standard stuff:
cd node_modules && cp -R @polymer @webcomponents @vaadin lit-html pwa-helpers ../modules/
cd ../modules/ && rm -f `find . -iname '*.map'` && rm -f `find . -iname '*.ts'`
find . -type f -name '*.js' -print0 | xargs -0 perl -plwe 's/([\\"\\'"'"'])(\@(?:polymer|webcomponents|lit-html|lit-element|vaadin\/))/$1\/modules\/$2/g' -i
View sv650s-2nd-generation-torque.tsv
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 1 column, instead of 4. in line 5.
# WARNING
# UNCOMFIRMED VALUES
# USE AT YOUR OWN RISK
# Suzuki sv650s TIGHTENING TORQUE
# ENGINE
ITEM N-m kgf-m lb-ft
Cylinder head cover bolt 14 1.40 10.0
Spark plug 11 1.10 8.0
Camshaft journal holder bolt 10 1.00 7.0
@jimmont
jimmont / customelements.js
Last active Dec 10, 2016
create new things and stuff
View customelements.js
/* this last updated 2016 Dec 9
v1 available:
2016 Nov in WebKit, Safari Tech Preview
2016 Chrome 54
curious when this lands on ios/macos
Chrome devtools show shadow DOM by default
Safari devtools must enable it in elements by selecting the icon
You can’t perform that action at this time.