Skip to content

Instantly share code, notes, and snippets.

View nateabele's full-sized avatar

Nate Abele nateabele

View GitHub Profile

(Re)-inventing on (un)-principle

A super popular activity in the JS ecosystem is to reinvent things.

Sometimes for fun, sometimes for style pickiness, but usually out of ignorance that the problem domain has already been explored and broken down into fundamental Named Things™—not based on the whims of the moment, or the pendulum-swing reaction to the design pattern you got burned by in your last big work project, or looking at The Popular Thing™ and thinking of all the things you hate about it.

Some people call this reasoning from first principles vs. reasoning by analogy (hint: people call it that because That's What It's Called—this is going to come back as a theme later).

One example of this that has a long and distinguished history is programmers poisoned influenced by OO style finding lots of different ways to reinvent function composition.

html, body {
background: gray;
color: white;
}

Li3 2.0 Migration Guide

Li3 2.0 is a maximally-API-compatible upgrade from Li3 1.3 and 1.2, which provides support for PHP 8.1 and above. See the CHANGELOG for an exhaustive list of differences. What follows are guidelines for migrating application code.

Base classes

Base classes lithium\core\Object and lithium\core\StaticObject (and their *Deprecated aliases) have been removed from the framework.

Object initialization

setInterval(() => { let b = Array.from(document.querySelectorAll('div[role=button]')).filter(b => /show \d+ tweets/i.test(b.innerText))[0]; b && b.click() }, 1000)
@nateabele
nateabele / Posts.10.js
Last active March 20, 2019 20:47 — forked from beardedtim/Posts.10.js
Forked in response to this article: https://medium.com/let-s-learn/lets-learn-composing-react-components-with-ramda-5db457997554 — I'm not sure I translated the code 100% correctly, but, you get the idea.
/**
* This is a forked and annotated example. I think it gets a lot of stuff right in terms
* of best practices on composition.
*
* There are a few things that I think could be better organized... that doesn't mean that
* the author is wrong; the things I'm calling out probably aren't even related to the point
* of the article.
*
* One of my issues with React is that it encourages decomposition for no good reason, which
* just makes your UI harder to maintain because you have to piece together dozens of tiny

AI Labs Open Source Contributor Guide

Last Update: Apr 4, 2018

Introduction

Thanks for your interest in helping out! AI Labs is committed to building the best possible software, and we believe that one of the best ways to do this is to contribute to the development community and (hopefully) benefit from wide peer review. Please feel free to reach out to [email protected] with any questions.

class GridLayout extends React.Component {
resizeHandler = this.resizeAll.bind(this);
grid = null;
hasRendered = false;
componentDidMount() {
window.addEventListener('resize', this.resizeHandler);
}
@nateabele
nateabele / file_map.js
Created August 23, 2017 01:53
Just reads a list from standard in to an array.
#!/usr/bin/env node
// --Usage--
// Bash: find `pwd` -type f | ./file_map.js
// Fish: find (pwd) -type f | ./file_map.js
const readline = require('readline');
const files = [];
var rl = readline.createInterface({
@nateabele
nateabele / trace.js
Created December 1, 2016 07:19
Generates friendly trace info for pipe() / compose()
// Use like: trace("Friendly name", pipe)(map(...), filter(...), etc(...))
export const trace = (name, comp) => (...fns) => comp(...fns.map((fn, i) => {
return (...args) => {
try { return fn(...args); } catch(e) {
e.message = `Error in ${comp.name}() sequence ${name} at step ${i} (${fn.name || '<anon>'}()): ${e.message}`;
throw e;
}
};
}));