Skip to content

Instantly share code, notes, and snippets.

View ourmaninamsterdam's full-sized avatar

Justin Perry ourmaninamsterdam

View GitHub Profile
@ourmaninamsterdam
ourmaninamsterdam / gist:8957212
Created February 12, 2014 15:10
Log Backbone history
var history = [];
this.listenTo(this, 'route', function (name, args) {
history.push({
name : name,
args : args,
fragment : Backbone.history.fragment
});
});
@ourmaninamsterdam
ourmaninamsterdam / gist:560ccdf106d96b620eb0
Created May 13, 2014 10:12
Partially applied fn [WIP]
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 August 29, 2015 14:03
CSS horizontal/vertical unit parser (for horizontal/vertical rhythm)
// ----
// Sass (v3.3.9)
// Compass (v1.0.0.alpha.20)
// By @ourmaninamsterdam
// ----
@function px-to-rem($px){
@return ( $px / $base-font-size ) * 1rem;
}
@ourmaninamsterdam
ourmaninamsterdam / gist:a241b99911b42a36f9eb
Created July 9, 2014 09:44
Sass concatenate arguments
@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 August 29, 2015 14:05
Method chaining with arguments - demonstrating a simple conversion pipeline utility
var Editor = function(){};
Editor.prototype.convert = {};
Editor.prototype.convert.from = function(type) {
this.fromType = type;
return this;
};
Editor.prototype.convert.to = function(type) {
// ----
// 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 August 29, 2015 14:05
Iframe resizer (using jQuery)
(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 / iframe-resizer.js
Last active August 29, 2015 14:05
Iframe Resizer (no dependencies) with AMD/global definitions
(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 / ExternalComponent.js
Last active August 29, 2015 14:07
Initialising 3rd-party components in Dough
define('ExternalComponent', ['jquery', 'DoughBaseComponent'], function($, DoughBaseComponent){
'use strict';
var defaultConfig = {},
/**
* Call base constructor
* @constructor
*/
ExternalComponent = function($el, config) {
@ourmaninamsterdam
ourmaninamsterdam / SuperTabSelector.js
Last active August 29, 2015 14:07
[proposal] Dough component
Dough.component('SuperTabSelector', {
extends: 'TabSelector',
deps: ['lodash _'],
config: {
selectors: {},
uiEvents: {}
},
constructor: function($el, config) {
},