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
dfkaye / utc-date-to-locale-date-string.js
Last active Jul 16, 2019
UTCDate(ms) - convert 1363358559454 to "March 15, 2013 at 7:42:39 AM"
View utc-date-to-locale-date-string.js
// 16 July 2019
export { UTCDate };
/**
* @function UTCDate accepts a datetime number or string in milliseconds since
* 1 January 1970 UTC and returns a formatted human-readable date string.
*
* Given: UTCDate(1363358559454)
* Returns: "March 15, 2013 at 7:42:39 AM"
*
@dfkaye
dfkaye / accessible-loading-spinner.html
Created Jul 13, 2019
a11y - accessible-loading-spinner - borrowed from paul j adam @ http://pauljadam.com/demos/loading-indicator.html
View accessible-loading-spinner.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>accessible loading spinner</title>
<!-- see http://pauljadam.com/demos/loading-indicator.html -->
<style nonce="4AEemGb0xJptoIGFP3Nd">
html {
font-size: 1em;
@dfkaye
dfkaye / august-2019.md
Last active Jul 16, 2019
dev-links for august 2019...
View august-2019.md

August 2019

  • coming soon eventually...

Designing Robust Systems

@dfkaye
dfkaye / flexbox-fieldset-supported.js
Last active Jul 4, 2019
Does your browser support flexbox on fieldset elements? Here's a test for that
View flexbox-fieldset-supported.js
// 28 June 2019
// Does your browser support flexbox on fieldset elements?
// Chrome doesn't, according to Eric Meyer tweet today:
// see https://twitter.com/meyerweb/status/1144656888707125248
// We ran into this a few months back. Here's a supports test for it.
function flexboxFieldsetSupported(/* tagName */) {
@dfkaye
dfkaye / csv.js
Last active Jul 15, 2019
csv helpers and tests - thanks to Ben Nadel whose csv-to-array function (2009) lives
View csv.js
export { transform, parse, match };
/* TRANSFORM DATA TO CSV */
/**
* @function transform accepts an array of objects and returns a string of
* comma-separated values based on the object's key-value entries. Each row in
* the output ends with the newline character. If the array argument is nothing
* or empty, function returns an empty string.
@dfkaye
dfkaye / multiline-strings.js
Last active Jun 19, 2019
3 ways to generate multiline strings in JavaScript
View multiline-strings.js
// 16 June 2019
// 3 ways to generate multiline strings in JavaScript
// see also string templates
// https://gist.github.com/dfkaye/088f0d5cc76d387c1357
// and "stateless" components
// https://gist.github.com/dfkaye/2d5cbd87f6bbf4976762
// 1. template literals (es6)
@dfkaye
dfkaye / create-selector.js
Created Jun 4, 2019
derive state from selectors
View create-selector.js
// 4 June 2019
// ES5 version of create and test taken from Nick Scialli's articl,
// "Calculating Derived State in JavaScript Using Selectors"
// @see https://hackernoon.com/calculating-derived-state-in-javascript-using-selectors-7f6ce06ac247
function createSelector(functions) {
var len = arguments.length;
if (!len || (len == 1 && typeof functions == 'function')) {
throw new SyntaxError("expects more than one function: " + functions);
}
@dfkaye
dfkaye / shuffle.js
Created Jun 4, 2019
fisher-yates shuffle
View shuffle.js
// 4 June 2019
// fisher-yates shuffle
// array and array-like structures
// modified from very nice implementation at
// https://stackoverflow.com/questions/2450954/how-to-randomize-shuffle-a-javascript-array/2450976#2450976
function shuffle(items) {
var array = Object.keys(items);
var currentIndex = array.length, temporaryValue, randomIndex;
@dfkaye
dfkaye / update.js
Last active Jun 19, 2019
update() sets values at key paths in data, returns new data
View update.js
// 29 May 2019
// another deep setter function but that first clones the target object before
// setting a new value at the key path - essentially an 'immutable' version of
// _.set @see https://gist.github.com/dfkaye/1b277589b04753cf0211eca25ea25b1d
// companion to resolve() function
// @see https://gist.github.com/dfkaye/5828ef43e2dccea576c78bb4eeb9747e
// Note: handles a single key path rather than a batch of updates making it
// potentially expensive (clone explosion).
@dfkaye
dfkaye / generator-example.js
Created May 27, 2019
generator example refactored from James H. Fisher's "JavaScript generators are also consumers!" post May 18, 2019
View generator-example.js
// 27 May 2019
// The generator example refactored from
// James H. Fisher's "JavaScript generators are also consumers!"
// https://jameshfisher.com/2019/05/18/javascript-generators-are-also-consumers/
function send(data) {
console.log(data);
}
You can’t perform that action at this time.