Skip to content

Instantly share code, notes, and snippets.

View raglan-road's full-sized avatar

Adam J. McIntyre raglan-road

View GitHub Profile
### Keybase proof
I hereby claim:
* I am raglan-road on github.
* I am adamjmcintyre (https://keybase.io/adamjmcintyre) on keybase.
* I have a public key ASAQ_I--as0dAL2K5NOQFWOro1gtROlUr6P8lzzlKPvJIwo
To claim this, I am signing this object:
// Some file, like layout-constants.js
export default BASE_PADDING = '1';
export default BASE_UNIT = 'rem';
// Another file, like blahcomponent.jsx
import * as CSS from 'layout-constants';
const Componet = css(`
margin: 1.5*${BASE_PADDING}${BASE_UNIT},
padding: ${BASE_PADDING}${BASE_UNIT}
`);
var used = [];
var people = {
tony: [],
dan: [],
adam: [],
jamal: [],
kevin: [],
dave: []
}
var toassign = ['tony', 'dan', 'adam', 'jamal', 'kevin', 'dave'];
var jeremylew = window.jeremylew = (typeof window.jeremylew !== "undefined") ? window.jeremlew : {},
foo = jeremylew.foo = (typeof jeremylew.foo !== "undefined") ? jeremylew.foo : {},
bar = jeremylew.foo.bar = (typeof jeremylew.foo.bar !== "undefined") ? jeremylew.foo.bar : {};
(bar.baz = function(){ }());
@raglan-road
raglan-road / animation
Last active December 17, 2015 09:09 — forked from mbutler-cs/animation
/* the css here */
@include keyframes(fadeIn) {
from {
height: 0;
opacity: 0; }
to {
height: auto; /* Not sure how well this will work */
opacity: 1; }
}
@raglan-road
raglan-road / gist:3959086
Created October 26, 2012 14:19
promises thing
initMap = function(){
var self = this;
return $.Deferred(function(dfd){
if(self.mapLoaded){
// Map is loaded y'all.
dfd.resolve();
}
else{
$.ajax( // load your thing)
.done(function(){
@raglan-road
raglan-road / available.js
Created September 28, 2012 15:32
Promised-based poll for element's availability in the DOM
// Poll until an element is "available" in the DOM, returning a promise that resolves when the element is in the DOM and scriptable.
$.available = function (id) {
var _poll = function(id, dfd) {
if(document.getElementById(id)) {
dfd.resolve(document.getElementById(id));
}
else {
setTimeout(function() {
_poll(id, dfd);
}, 100);
@raglan-road
raglan-road / jq-plugins.js
Created September 21, 2012 16:23
Patterns for building jQuery plugins!
// Why plugins? Think about using a plugin when you need a piece of reusable functionality that will be applied to
// an element - and potentially many elements - in a given UI.
// Resource: http://docs.jquery.com/Plugins/Authoring
// The basic plugin boilerplate
;(function($){
$.fn.plugin = function(){
// If your plugin needs to be chainable, return this!
return this; // this -> reference to calling jQuery Object e.g. $('.foo').plugin() => $('.foo')
@raglan-road
raglan-road / gist:3258270
Created August 4, 2012 15:08 — forked from adamjmcintyre/gist:3098766
Using CSS keyframe animationend event cross-browser with jQuery
$('.some-els').bind('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd', function(){
// Do something!
$(this).removeClass('animation-class');
})
.addClass('animation-class');
// One works, too
$('.some-els').one('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd', function(){
// Do something once!
console.log('this would show once');
@raglan-road
raglan-road / animationend.js
Created August 4, 2012 14:47
Cross-browser jQuery support for CSS3 animationend event
// jQuery support for CSS3's animationend, which fires when a keyframe animation completes.
// This covers all of the combinations of vendor prefixes for the event, so it will work cross-browser.
// transitionend would work the same way.
$('.some-el-that-you-are-animating').bind('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd', function(){
// this => element that just animated
});