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 OffFocus.jsx
class OffFocus extends React.Component {
const handler = e => {
barneycarroll / drizzle.txt
Created Sep 6, 2018
Drizzle by Hjalmar Söderberg
View drizzle.txt
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 / Location.es6.min.js
Last active Aug 24, 2018
An ultra-small URI parsing function that accepts a URI-like string & returns an object with all the string properties of the native Location object for that string. Works using native property detection, without received wisdom (ie dictionaries, inference, etc).
View Location.es6.min.js
export default x=>document.createElement('a').href=x
barneycarroll / html.loading.snippet.html
Created May 19, 2011
Hide the page body until page & dependencies have finished loading
View html.loading.snippet.html
// add a class of 'loading' to the HTML, then remove it once the page has finished loading
c('scripted loading')
window.onload = function(){setTimeout(function(){
var h = document.lastChild
return c ? h.className = c : h.className
View calendar.es6.js
const calendar = {
controller : ( date = moment() ) => {
const weeks = []
const end = date.endOf( 'month' ).startOf( 'week' )
let current = date.startOf( 'month' ).startOf( 'week' )
do {
weeks.push( {
start : current.clone()
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.

You can’t perform that action at this time.