Skip to content

Instantly share code, notes, and snippets.

Avatar

Justin Perry ourmaninamsterdam

View GitHub Profile
View gist:8957212
var history = [];
this.listenTo(this, 'route', function (name, args) {
history.push({
name : name,
args : args,
fragment : Backbone.history.fragment
});
});
View gist:560ccdf106d96b620eb0
function delegateEvent(selector, handler) {
var that = this;
return function(e) {
var elem = e.target;
if(new RegExp(selector,'gi').test(elem.className)){
if(typeof handler === 'function'){
return handler;
}
}
return this;
@ourmaninamsterdam
ourmaninamsterdam / SassMeister-input.scss
Last active Aug 29, 2015
CSS horizontal/vertical unit parser (for horizontal/vertical rhythm)
View SassMeister-input.scss
// ----
// Sass (v3.3.9)
// Compass (v1.0.0.alpha.20)
// By @ourmaninamsterdam
// ----
@function px-to-rem($px){
@return ( $px / $base-font-size ) * 1rem;
}
View gist:a241b99911b42a36f9eb
@function str-concatenate($args){
$str: '';
@for $i from 1 through length($args){
$str: $str + str-slice(nth($args,$i),1, str-length(nth($args,$i)));
}
@return $str;
}
.example {
width: str-concatenate("hello" "goodbye" "tarrah" "ciao");
@ourmaninamsterdam
ourmaninamsterdam / gist:80fdb88e16a324c0c598
Last active Aug 29, 2015
Method chaining with arguments - demonstrating a simple conversion pipeline utility
View gist:80fdb88e16a324c0c598
var Editor = function(){};
Editor.prototype.convert = {};
Editor.prototype.convert.from = function(type) {
this.fromType = type;
return this;
};
Editor.prototype.convert.to = function(type) {
View SassMeister-input.scss
// ----
// Sass (v3.3.14)
// Compass (v1.0.1)
// ----
$unit: 1px;
$item-context: ''; // Set here to make it available in entire scope - NOTE not sure if using global vars like this is good practice
$context: (
device-large: (
gutter-width: 20
@ourmaninamsterdam
ourmaninamsterdam / iframe-resizer.js
Last active Aug 29, 2015
Iframe Resizer (no dependencies) with AMD/global definitions
View iframe-resizer.js
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define('iframeResizer', function (iframeResizer) {
return (root.iframeResizer = factory());
});
} else {
root.iframeResizer = factory();
}
}(this, function () {
return function(msgPrefix, targetOrigin, minFrameHeight,) {
@ourmaninamsterdam
ourmaninamsterdam / iframe-resizer.js
Last active Aug 29, 2015
Iframe resizer (using jQuery)
View iframe-resizer.js
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(['jquery'],function (jQuery) {
return (root.iframeResizer = factory(jQuery));
});
} else {
root.iframeResizer = factory(root.jQuery);
}
}(this, function ($) {
return function(messageId, minPageHeight, $animatedElements) {
@ourmaninamsterdam
ourmaninamsterdam / ExternalComponent.js
Last active Aug 29, 2015
Initialising 3rd-party components in Dough
View ExternalComponent.js
define('ExternalComponent', ['jquery', 'DoughBaseComponent'], function($, DoughBaseComponent){
'use strict';
var defaultConfig = {},
/**
* Call base constructor
* @constructor
*/
ExternalComponent = function($el, config) {
@ourmaninamsterdam
ourmaninamsterdam / SuperTabSelector.js
Last active Aug 29, 2015
[proposal] Dough component
View SuperTabSelector.js
Dough.component('SuperTabSelector', {
extends: 'TabSelector',
deps: ['lodash _'],
config: {
selectors: {},
uiEvents: {}
},
constructor: function($el, config) {
},