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
barneycarroll /
Created Jun 4, 2018
A Mithril inspector overlay

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 / detectCSS.js
Created Jul 21, 2011
Simple function to determine whether a given CSS property is supported or not. Useful for conditional execution of JS animations, rounded corners, etc.
View detectCSS.js
// Is the passed CSS property supported?
// eg. detectCSS('transition')
function detectCSS(prop){
prop = prop.replace(/-(\w)/g,function(s,g){return g.toUpperCase()}),
pre = ',Icab,Khtml,Moz,Ms,O,Webkit'.split(',');
for (var i = 0; i < pre.length; ++i){
prop = prop.slice(0,1).toUpperCase() + prop.slice(1);
barneycarroll / jquery.whichclick.js
Last active May 8, 2018
Internet Explorer's click event's `which` property won't indicate which mouse button was clicked. To get around this, create distinct `leftclick`, `rightclick` and `middleclick` events which reliably prevent default behaviour. Also creates the `anyclick` event for convenience, which is essentially equivalent to `click` with `event.which` polyfil…
View jquery.whichclick.js
void function whichClickClosure( $ ){
var events = {
1 : 'leftclick',
2 : 'middleclick',
3 : 'rightclick'
// List of interruption events for symbolic linking between custom and native events
interrupts = [
barneycarroll /
Last active Apr 24, 2018
Of many sequential promises, only the last is worthy of consequence

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.

barneycarroll / BornToDie.js
Created Apr 11, 2018
A component which redraws on post-creation & pre-removal, providing `{born, to, die,}` as flags to the supplied function
View BornToDie.js
const BornToDie = v => {
born = true,
to = false,
die = false,
let query
let draw
View Historian.js
const Historian = Object.assign(
Component => {
const histories = new WeakMap
return {
onbeforeupdate({}, old){
if(Component.onbeforeupdate && Component.onbeforeupdate.apply(this, arguments) === false)
return false
histories.set(old.state, old)
barneycarroll / broken.js
Last active Mar 10, 2018
Break a promise
View broken.js
const broken = (promise, state = {
pending: true,
settled: false,
resolved: false,
rejected: false,
value: undefined,
error: undefined,
}) => (
barneycarroll /
Created Mar 2, 2018
When a nested expression is the desired return value

Written to avoid the noisome pattern of

input => {
  const reference = expression with input


  return reference 
View mimix.js
const {assign, keys} = Object
const scope = fn =>
return fn(x => x.apply(this, arguments))
const compose = (key, values) => (
key === 'view'
You can’t perform that action at this time.