Skip to content

Instantly share code, notes, and snippets.

@dfkaye
dfkaye / flip-string.js
Created Mar 24, 2021
flipString: Turn a string upside-down in JavaScript
View flip-string.js
// This is not mine.
// It was first published in 2005 or so by David Faden
// at http://www.revfad.com/flip.html.
// 23 March 2021 - ES6-ified
function flipString(aString) {
return String(aString)
.split("")
.map(c => flipTable[c] || c)
@dfkaye
dfkaye / array-at.js
Last active Mar 4, 2021
polyfill for the Array.prototype.at() method
View array-at.js
// 3 March 2021
// polyfill for the Array.prototype.at(index) method
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at
typeof Array.prototype.at == 'function' || (function() {
Array.prototype.at = function (index) {
// return this.slice(index)[0] // 3 March 2021: First impl.
return this.slice(index).shift() // 4 March 2021: Nicer.
}
})();
View rAssign-refactored.js
// 21 February 2021
// rAssign library, slightly refactored
// r-assign by micnic applies Object.assign() to a series of sources,
// then uses a schema against which to extract defined properties by type and name.
// see https://github.com/micnic/r-assign/
function rAssign(schema, ...sources) {
// Check for valid schema provided
@dfkaye
dfkaye / multistable-cognitive-phenomena.md
Created Feb 9, 2021
Multistable Cognitive Phenomena - book list
View multistable-cognitive-phenomena.md

Multistable Cognitive Phenomena

https://en.wikipedia.org/wiki/Multistable_perception

@dfkaye
dfkaye / spreadsheet-math.md
Last active Feb 14, 2021
Math functions and operators in spreadsheets via spreadsheetclass.com
View spreadsheet-math.md
@dfkaye
dfkaye / symbolic-logic-entities.md
Last active Feb 25, 2021
HTML entities for symbolic logic operators, plus temporal logic fairness, liveness, and safety
View symbolic-logic-entities.md

HTML entities for symbolic logic operators

See full reference at W3Schools HTML Math entities.

Mathematical

  • + - plus
    • HTML: +
    • CSS: \002B
  • − - minus
@dfkaye
dfkaye / metasyntactic-variables.md
Last active Feb 2, 2021
foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud
View metasyntactic-variables.md

Metasyntactic Variables

foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud

Or so I have read…

In list form:

  • foo
  • bar
@dfkaye
dfkaye / reactive-jquery.md
Last active Mar 18, 2021
JQuery has all we need to make it reactive, if we add these four things.
View reactive-jquery.md

Reactive JQuery

28 January 2021

Turns out JQuery has almost everything we need to make it reactive (render-on-change-to-data). The virtual DOM is unnecessary if we have guards against unnecessary rendering. We don't need JSX to make it all look more like HTML templates.

This is heresy and not well thought out yet. Certain projects may do this already. None, I would bet serious Gamestop options, uses the SAM pattern.

JQuery has...

@dfkaye
dfkaye / behavioral-class.js
Last active Mar 24, 2021
2 refactorings (class and factory) of the behavioral.js class by Luca Matteis @lmatteis
View behavioral-class.js
// 22 January 2021
// Refactoring of class function in behavioral at
// https://github.com/lmatteis/behavioral/blob/master/index.js
// TODO add tests
export { BProgram }
function BProgram() {
this.running = [];
@dfkaye
dfkaye / actor-model-in-a-tweet.js
Created Dec 29, 2020
Updated Dale Schumacher's "Actor Model in a Tweet"
View actor-model-in-a-tweet.js
// 28 December 2020
// https://twitter.com/dfkaye/status/1343784103674400769
// Updated @dalnefre's actor model in a tweet:
var Actor = (a, e) => function c(b) {
a = d => setTimeout(() => e.behavior(d)),
e = { self: a, behavior: b, sponsor: c };
return a
}