Skip to content

Instantly share code, notes, and snippets.

david kaye dfkaye

Block or report user

Report or block dfkaye

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
dfkaye / is-value.js
Last active Jun 5, 2020
isValue() checks that a value is not undefined, not null, not NaN, and not an empty string.
View is-value.js
// 4 June 2020
// Value check that cuts through tiresome debates.
// Counterpart to isEmpty() which checks for empty containers.
// @see
// Stricter version of noValue() from July 2019 which treats empty arrays and empty objects as
// not-containing-values.
// @see
dfkaye / fetch-gists.js
Created Jun 3, 2020
q&d fetch-gists from github
View fetch-gists.js
// 3 June 2020
// memorializing this helper to track my too numerous gists
function fetchGists({ url, per_page, page, fn }) {`fetch ${ url } at ${ }`);
// url must be at least a string
if (Object(url).toString() !== url) {
console.error("param url should be a string");
dfkaye /
Last active Jun 5, 2020
Twitter is not a discussion medium, it is a notation medium, and that's it.

A billion post-it notes...

Started May 29, 2020.

The nature of Twitter

Twitter is not a discussion medium, it is a notation medium, and that's it.

A billion post-it notes on a board do not make a discussion.

dfkaye / schedule-dom-init.js
Created May 27, 2020
bare bones dom init using readyState checks
View schedule-dom-init.js
// 27 May 2020
// pulled from the SAM patter calculator codepen
// Enables us to call view.init() multiple times, even after document is ready.
var view = (function() {
function schedule(fn) {
document.addEventListener('readystatechange', function (e) {
if (document.readyState == "complete") {
dfkaye /
Last active May 23, 2020
Keyboard navigation is a function of the View and *only* the View.

Keyboard navigation is not a state, action, or model activity

OK, an update on my evolving understanding of [SAM done right]. I've added a keydown handler in the calculator app I posted about earlier (scroll up) and it struck me that while keyboard input on a button-driven app can send data to the next Action, keyboard navigation should not do that. Tab and arrow navigation should be handled by the View entirely. Is there a case for sending a next action after keyboard navigation (storing a new focus position, for example)? Any comments are welcome.

(Visit the calculator codepen.)

Answering my own question

Keyboard navigation is a function of the View and only the View.

dfkaye / top-level-await-vs-async-iife.js
Created May 17, 2020
top-level await vs. async IIFE
View top-level-await-vs-async-iife.js
// 17 May 2020
// top-level await vs. async IIFE
// Works in Chrome & Firefox
// Does not work in Edge (throws 'await' is not defined)
await (function() { return Promise.resolve('top-level await') })().then(console.warn);
// > "top-level await"
// async IIFE works across all 3 browsers here
dfkaye / zip.js
Created May 16, 2020
merge 2 or more arrays into a matrix.
View zip.js
// 16 May 2020
// Killing time again.
// merge 2 or more arrays into a matrix.
// zip(a,b,c) returns
// [
// [a[0], b[0], c[0]],
// [a[1], b[1], c[1]],
// ... etc ...
// ];
dfkaye / is-number.js
Created May 13, 2020
isNumber() checks that a value is functionally a number and not NaN
View is-number.js
// 13 May 2020
// inspired by tweet about npm i is-number...
// see
* Strategy is to wrap the value in its object constructor without coercion,
* and test 3 conditions:
* 1. NaN does not equal itself (===)
* 2. If the object concatenates (+), it's not a number
dfkaye / jsconfig.json
Last active May 11, 2020
Boilerplate for using TypeScript as a type checker on JavaScript files containing JSDoc annotations.
View jsconfig.json
"compilerOptions": {
"noImplicitAny": true,
"allowJS": true,
"checkJS": true,
"noEmit": true
"files": [
dfkaye / html-skeleton-with-csp-aria.html
Last active May 13, 2020
Expanded version of Josh W. Comeau (2020), HTML Skeleton (adds CSP, ARIA, custom tag name)
View html-skeleton-with-csp-aria.html
<!DOCTYPE html>
<html lang="en">
<!-- Josh W Comeau (2020), HTML Skeleton (starter for every web page) → -->
<!-- see also my HTML5 boilerplate gist → -->
<title>Your Page Title</title>
You can’t perform that action at this time.