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
@mbostock
mbostock / .block
Last active Jul 30, 2019
Margin Convention
View .block
license: gpl-3.0
@cowboy
cowboy / isprimitive-no-strict.js
Created Sep 18, 2012
JavaScript: isPrimitive
View isprimitive-no-strict.js
var isPrimitive = function(val) {
return val !== function() { return this; }.call(val);
};
@desandro
desandro / transition-scroll-to.js
Created Dec 4, 2012
Use CSS transitions to scroll to element
View transition-scroll-to.js
( function( window, undefined ) {
'use strict';
// helper function
function capitalize( str ) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
// ========================= getStyleProperty by kangax ===============================
@umpirsky
umpirsky / A.markdown
Last active Apr 13, 2019 — forked from olivierlacan/An_example.markdown
Sublime Text Monokai Sidebar Theme.
View A.markdown
@barneycarroll
barneycarroll / jquery.target.js
Last active Dec 19, 2015
NB: This code has all sorts of edge cases, and any code that attempts to leverage it on a holistic framework level is likely to run into bugs fast. Do not use. Creates a custom `target` event, matching the CSS `:target` pseudo-selector, which can be used to determine when an element in the page becomes the current target of the URI's fragment id…
View jquery.target.js
/* Provides a jQuery 'target' event that fires in all conditions that would
* result in an element becoming the target of the URI fragment identifier or
* hash as it is often called. It aims to provide a behavioural hook to emulate
* CSS3's :target selector [1] (more here [2] and here [3]: good demos include
* this proof of concept [4] and Wikipedia's styling of targeted footnotes and
* citations [5]).
*
* [1] https://developer.mozilla.org/en-US/docs/Web/CSS/:target
* [2] http://css-tricks.com/on-target/
* [3] http://blog.teamtreehouse.com/stay-on-target
@lttlrck
lttlrck / gist:9628955
Created Mar 18, 2014
rename git branch locally and remotely
View gist:9628955
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
View mithril.utils.js
// Mithril utilities
// Multi allows you to execute multiple functions as one.
// Especially useful when you want to bind several event handlers
// or run several config functions, for example binding a DOM plugin
// & assigning routing to a link.
//
// m( 'a.select2', {
// config : multi( m.route, select2plugin )
// }, [] );
@StephanHoyer
StephanHoyer / gist:de107b794c43f28ffd75
Last active Nov 14, 2019
SVG Icons with mithril.js
View gist:de107b794c43f28ffd75

Icons have been part of applications since ages. Also most websites rely on icons. There were several ways to use them. First we used plain files then image sprites to reduce requests. Nowadays everyone uses icon fonts like font-awesome or glyphicons.

They are infinetly scaleable and styleable with css. The downside is they use pseudo elements for displaying. This is not only difficult to handle but also non-optimal for accessibilty.

A famous CSS-Tricks post brings SVG icons into play. The are also scalable and they behave like normal images. But we also want to have a sprite to not load any images seperatly and kill our servers and our sites performance. The proposed version is to create sprites with grunt or gulp using the symbol-trick. It's basically add every icon to a hidden sprite-image and give every icon an id-property.

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  
  <symbol id="beaker" viewBox="214.7 0 182.6 792">
@barneycarroll
barneycarroll / grid.js
Created Nov 13, 2014
A grid vm for Mithril
View grid.js
'use strict';
function grid( axis ){
var items = [];
var pending;
var container;
function queue(){
if( pending ) ( window.cancelAnimationFrame || window.clearTimeout )( pending );
@barneycarroll
barneycarroll / animator.js
Last active Mar 9, 2017
A factory for decorating Mithril modules / views / elements with incoming and outgoing animations.
View animator.js
var animating = false;
// Define an animator consisting of optional incoming and outgoing animations.
// alwaysAnimate is false unless specified as true: false means an incoming animation will only trigger if an outgoing animation is also in progress.
// forcing dontClone to true means the outward animation will use the original element rather than a clone. This could improve performance by recycling elements, but can lead to trouble: clones have the advantage of being stripped of all event listeners.
function animator( incoming, outgoing, alwaysAnimate, dontClone ){
// The resulting animator can be applied to any number of components
return function animate( x, y, z ){
var config;
var parent;
You can’t perform that action at this time.