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 / balanced.js
Last active Jan 18, 2020
test for balanced braces, parentheses, brackets
View balanced.js
// 10 Jan 2020
// beautiful's interview question
// better solution than https://gist.github.com/dfkaye/2e87303396fdd0402e01062594d4e89c from Consensus
function balanced(string) {
var p = string.length && string.length % 2 === 0;
if (!p) {
return false;
}
@dfkaye
dfkaye / resize-textarea.js
Last active Jan 7, 2020
textarea resize drag handle polyfill for Edge/Internet Explorer
View resize-textarea.js
// 2-6 January 2019
// Minimal textarea resize thumb support for Edge/Internet Explorer.
// Inspired by https://github.com/CezaryDanielNowak/css-resize-polyfill
function resize(textarea) {
// True in browsers that support the resize capability on textareas.
if (document.createElement('textarea').style.resize != null) {
return;
}
@dfkaye
dfkaye / immutability.md
Last active Dec 23, 2019
Immutability in JavaScript
View immutability.md

Short Attention Span Theater

Gratuitous introductory section you can skip

In certain programming languages, some values are said to be "immutable," meaning that once assigned to a variable name, they cannot be changed in part.

var s = 'string';
s += ' bean';

s will still be 'string' even though we tried to alter it with the concatenation operator.

@dfkaye
dfkaye / things-to-tell-interviewers-about.md
Last active Jan 9, 2020
Tell your interviewers about TLA+, SAM pattern, OWL selector
View things-to-tell-interviewers-about.md
@dfkaye
dfkaye / safe-eval-workers.md
Last active Jan 4, 2020
Use a Worker() for eval() and Function() when Content-Security-Policy does not allow 'unsafe-eval'
View safe-eval-workers.md

'safe-eval' with Worker

Before we get started…

Prefer script-src-elem over script-src for better cross-browser support of this solution.

The problem

You want to do this:

@dfkaye
dfkaye / csp-key-features.md
Last active Nov 22, 2019
Table version of Content Security Policy (CSP) keys slide at performance.now() conference 2019
View csp-key-features.md
@dfkaye
dfkaye / hugo.md
Last active Dec 18, 2019
Switching to the Hugo static site generator - reasons, resources, more
View hugo.md

Switching to the Hugo static site generator - reasons, resources, more

Background

@dfkaye
dfkaye / data-store-using-http-verb-methods.js
Created Oct 21, 2019
BOREDOM IS THE MOTHER OF REINVENTION
View data-store-using-http-verb-methods.js
// 20 OCT 2019
// PLAYING WITH DATA STORE USING HTTP VERBS AS METHOD NAMES
// NO SCHEMA
// IMMUTABLE via Object.create
// NEED TO CHANGE ERROR CONCEPT
// NEED TO USE STRUCTURE SHARING MERGE (PATCH) - MAYBE
// NEED TO ADD HISTORY
var cache = Data.cache = {};
@dfkaye
dfkaye / elements-up-next.md
Last active Oct 18, 2019
todo list of html elements to create next
View elements-up-next.md
@dfkaye
dfkaye / eric-rey-it-gen-examples.js
Created Oct 18, 2019
Notes from Eric Rey, "Iterators and Generators do have a place in modern JavaScript"
View eric-rey-it-gen-examples.js
// 17 Oct 2019
// Notes from Eric Rey, "Iterators and Generators do have a place in modern JavaScript" (25 Aug 2018)
// https://itnext.io/iterators-and-generators-do-have-a-place-in-modern-javascript-d4cb589b491
// I LIKE THE FIRST USE
// Custom Collections
function EvenNumbers(values = []) {
values = [...values];
You can’t perform that action at this time.