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
View tevko-task-runtime-problem.js
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
// This version, 5 Sept 2019
// First version, 18 Dec 2018
// See original Math Problem gist by @tevko
// https://gist.github.com/tevko/20f8fc446d219f4714517aab19c5dd71
// See postscript at the end of this gist for next thoughts...
// Set up our constraints first.
@dfkaye
dfkaye / bodil-miracle-of-generators.md
Last active Sep 5, 2019
Notes from Bodil Stokke's "The Miracle of Generators" presentation from the Front Conference Zurich
View bodil-miracle-of-generators.md

Notes from Bodil Stokke's "The Miracle of Generators"

Presented at Front Conference Zurich 31 August - 1 September 2017

Video at https://vimeo.com/232221648

Our little data

var ponies = [
@dfkaye
dfkaye / regex-ascii-plus.js
Created Aug 19, 2019
Shorthand regex [A-z] to match all ASCII letters, backtick, caret, underscore, opening & closing square brackets...
View regex-ascii-plus.js
// 19 August 2019
// Just learned something new:
// Shorthand regex [A-z] will find all ASCII letters, lower- and uppercase.
// And will also find backtick, caret, underscore, opening and closing square brackets...
// Who knew?
// @jessitron => https://twitter.com/jessitron/status/1163481184413913088
var re = /[A-z]+/;
var tests = `09aZ~!@#$%^&*()_+\`-={}|[]\:;"'<,>.?/'"`.split('');
@dfkaye
dfkaye / CSS-files-in-JSX.md
Last active Aug 9, 2019
Using CSS files in React/JSX
View CSS-files-in-JSX.md
@dfkaye
dfkaye / relative-selectors.css
Created Aug 6, 2019
CSS relative selectors
View relative-selectors.css
/* 5 Aug 2019 */
/* https://twitter.com/dfkaye/status/1158602465345884160 */
/*
* Figure out why there are no CSS selectors for the following and - suddenly - you will "get" CSS:
*
* - previous adjacent sibling
* - previous general sibling
* - direct ancestor (parent)
@dfkaye
dfkaye / insert-at.js
Created Aug 4, 2019
insert-at - exercise in es5
View insert-at.js
// 4 Aug 2019
// prompted by
// https://www.linkedin.com/posts/sifat-haque-9a3028b1_javascript-simpleabrjavascript-coding-activity-6561302165493780480-6A1F
// Here is an way to insert a new item to an Object at any specific position.
function insertAt(obj, key, value, at) {
if (Array.isArray(obj)) {
var a = obj.slice();
at === +at ? a.splice(at, 0, value) : a[at] = value;
@dfkaye
dfkaye / no-value.js
Last active Aug 3, 2019
no-value: check whether value translates to null, undefined, NaN, or an empty string.
View no-value.js
// 2 Aug 2019
// check whether value translates to null, undefined, NaN, or an empty string.
// Examples:
// false is a value.
// [], and [''] have noValue.
function noValue(o) {
return !String(o == null || o !== o ? '' : o).length;
}
@dfkaye
dfkaye / uuid-generator.js
Created Jul 28, 2019
UUID generator function - by deepak gupta (2018)
View uuid-generator.js
// 27 July 2019
// UUID generator function
// from https://codeburst.io/javascript-generator-yield-next-async-await-e428b0cb52e4
function* UUIDGenerator() {
let d, r;
while (true) {
yield 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
@dfkaye
dfkaye / utc-date-string.js
Last active Jul 24, 2019
format date as a UTC date string - yyyy-mm-ddThh:mm:dd.mmsZ
View utc-date-string.js
/**
* @function formatUTCDateString accepts a string or a number and attempts to
* create a YYYY-MM-DDTHH:MM:DD.MSZ string and return it. If the input cannot
* be parsed into a valid date, the original value is returned.
*
* Function also supports a quoted timestamp as the argument, tries to coerce
* it to produce a valid date string.
*
* Note the JavaScript's Date object does *not* accept a quoted timestamp, as
* follows:
@dfkaye
dfkaye / graph-query.js
Last active Aug 2, 2019
graphQL query builder helper and test (not entirely done yet) plus graphRequest example
View graph-query.js
/* graphQL query builder */
/**
* @function buildGraphQuery takes a map of field values, and other items for a
* graphQL query string, and returns an object containing each part, plus the
* `toString()` method that produces the graph query.
*
* The returned object can be tested on each of its parts that the `toString()`
* method uses to construct the final graphQL query string.
*
You can’t perform that action at this time.