Skip to content

Instantly share code, notes, and snippets.

🤑
Looking for work

Barney Carroll barneycarroll

🤑
Looking for work
Block or report user

Report or block barneycarroll

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 NowThen.js
export default () => {
const queue = []
let then
return {
onbeforeupdate : () => !blocker,
oncreate : resolve,
onupdate : resolve,
view : ({
instance,
@barneycarroll
barneycarroll / .js
Last active Aug 2, 2019
Functor Mithril!
View .js
import m from './functor-mithril'
function Async(){
let cache
return ({content, setup, teardown}, dom) => {
if(content && !cache && teardown)
dom(node => {
void node.clientHeight
View Refresher.js
import {m} from './deps.js'
import viewOf from './viewOf.js'
// View component exposing a single function:
// Once invoked, the function causes the subtree to be reinitialised
export default () => {
let timestamp
const refresh = () => {
@barneycarroll
barneycarroll / tabitha.js
Created Oct 10, 2018
Get user-focusable elements within a context in tab order
View tabitha.js
// Source
const tabitha = (context = document) =>
[
...context.querySelectorAll('*')
]
.filter(element => {
const style =
window.getComputedStyle(element)
return (
View OffFocus.jsx
class OffFocus extends React.Component {
constructor(){
super()
const handler = e => {
if(
this.state.focused
&&
e.target.nodeType
&&
@barneycarroll
barneycarroll / Drizzle.md
Created Sep 6, 2018
Drizzle, a short story by Hjalmar Söderberg
View Drizzle.md

Drizzle

Autumn is here again with its dismal days, and the sun is hiding himself in the darkest corner of the heavens so that no one shall see how pale and aged and worn he has grown in this latter time. But while the wind whistles in the window-chinks and the rain purls in the rainspouts and a wet dog howls in front of a closed gate down below on the street and before the fire has burned down in our tile stove, I will tell you a story about the drizzle. Listen now!

For some time back the good God had become so angered over the wickedness of men that he resolved to punish them by making them still wickeder. He should, in his great goodness, have liked above all things to have drowned them all together in a new Deluge: he had not forgotten how agreeable was the sight when all living creatures perished in the flood. But unfortunately in a sentimental moment he had promised Noah never to do so again.

"Harken, my friend I" he therefore said to the Devil one day. "You are assuredly no saint, but occasionall

@barneycarroll
barneycarroll / drizzle.txt
Created Sep 6, 2018
Drizzle by Hjalmar Söderberg
View drizzle.txt
THE DRIZZLE
AUTUMN is here again with its dismal days,
and the sun is hiding himself in the darkest
corner of the heavens so that no one shall see how
pale and aged and worn he has grown in this
latter time. But while the wind whistles in the
window-chinks and the rain purls in the rain-
@barneycarroll
barneycarroll / README.md
Created Jun 4, 2018
A Mithril inspector overlay
View README.md

Mithril debugger

Prioritised features:

  1. Pointer-based hover-overlay to highlight elements generated by Mithril
  2. With a view of their corresponding vnode & associated path
  3. That allows travel through path and vnode tree interface to highlight other elements

Followed by:

  • Patch reporter:
    • Receive inspectable logs for changes that occur on render
@barneycarroll
barneycarroll / README.md
Last active Apr 24, 2018
Of many sequential promises, only the last is worthy of consequence
View README.md

There are many scenarios where a particular interaction makes repeated calls to an asynchronous, and each subsequent call invalidates the previous. For example, typing in a field which can query an HTTP service for insights: if I type 'a', and wait long enough, a call should be sent to ask for pertinent suggestions; but if I'm still waiting on that response when I type 'b', then the results of the last call are impertinent. Only the last call's response should resolve.

Calling latest creates a 'promise debouncer' function. Either you pass in the async function there and then and call it without arguments, or you instantiate it empty and pass in the async function upon request. In either case, calling the function before its last promise has resolved will ensure that promise never resolves: only the last request will ever resolve.

You can’t perform that action at this time.