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
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.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 / 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
barneycarroll / html.loading.snippet.html
Created May 19, 2011
Hide the page body until page & dependencies have finished loading
View html.loading.snippet.html
<script>
// add a class of 'loading' to the HTML, then remove it once the page has finished loading
(function(c){
c('scripted loading')
window.onload = function(){setTimeout(function(){
c(c().replace('loading',''))
},30)}
}(function(c){
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
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 / 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){
var
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){
if(i==1)
prop = prop.slice(0,1).toUpperCase() + prop.slice(1);
@barneycarroll
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 = [
'preventDefault',
'stopPropagation',
You can’t perform that action at this time.