Skip to content

Instantly share code, notes, and snippets.

View krambuhl's full-sized avatar
❤️
I love you!

Eevee Kreevee krambuhl

❤️
I love you!
  • Boogie Woogie Industrial Complex
  • Portland, Oregon
  • 22:23 (UTC -07:00)
View GitHub Profile
@krambuhl
krambuhl / gist:5139824
Last active December 14, 2015 19:49
Mustache/jQuery wrapper: Loads a mustache template via ajax: onsuccess, mustache template is rendered (on all matched contexts). if callback is defined, it will be called.
var renderTemplate = function(context, source, data, callback) {
$.get(source, function(template){
$(context).html($.mustache(template, data));
if (typeof callback === "function")
callback.call(this, context);
});
};
@krambuhl
krambuhl / gist:5520479
Created May 5, 2013 10:53
percentBetween
var percentBetween = function(n1, n2, pos) {
return Math.floor(pos * n2) + n1;
};
@krambuhl
krambuhl / grid.scss
Last active December 21, 2015 09:28
Sass responsive grid implimentation
$grid-max: 12;
$grid-column: 80px;
$grid-gutter: 0px;
@function gridw ($span: $grid-max, $offset: 0px) {
@return ($grid-column * $span) + ($grid-gutter * ($span - 1)) + $offset;
}
@mixin grid ($span: $grid-max, $offset: 0px) {
width: gridw($span, $offset);
@krambuhl
krambuhl / mixins.animations.scss
Created January 23, 2014 04:58
Simple sass animation mixins
@mixin animation($animate...) {
$max: length($animate);
$animations: '';
@for $i from 1 through $max {
$animations: #{$animations + nth($animate, $i)};
@if $i < $max {
$animations: #{$animations + ", "};
}
@krambuhl
krambuhl / slice.scss
Last active August 29, 2015 13:56
A general layout module for creating columns.
.slice {
display: table;
table-layout: fixed; // makes items equal sizes automatically
width: 100%;
}
.slice-auto {
table-layout: auto; // items will resize based on content size
}
@krambuhl
krambuhl / backbone.jsonp-collection.js
Created March 2, 2014 05:46
Backbone Jsonp Collection. only supports simple get commands.
Backbone.JsonpCollection = Backbone.Collection.extend({
sync: function(method, model, options) {
var params = _.extend({
type: 'GET',
url: this.url,
dataType: "jsonp",
processData: false
}, options);
return $.ajax(params);
@krambuhl
krambuhl / icon.scss
Created March 14, 2014 19:20
icon utility class. uses sass to build out sizing modifiers.
.icon {
display: inline-block;
background-size: contain;
font-size: 0;
color: transparent;
}
.icon-block {
display: block;
@krambuhl
krambuhl / underscore.timers.js
Last active August 29, 2015 13:57
A set of underscore mixins for timer functions.
_.mixin({
bindDelay: function(func, context, wait) {
return _.delay(_.bind(func, context || this), wait, _.last(arguments, 3));
},
bindDefer: function(func, context) {
return _.defer(_.bind(func, context || this), _.last(arguments, 2));
},
repeat: function(func, interval) {
@krambuhl
krambuhl / respond.scss
Last active June 22, 2018 14:44
Sass mixin for creating media queries with min/max arguments
@mixin respond($min: -1, $max: -1, $media: "all") {
$query: "only " + $media;
@if $min != -1 and $max != -1 {
$query: "only " + $media + " and (min-width: " + $min + ") and (max-width: " + ($max - 1) + ")";
} @else if $min == -1 and $max != -1 {
$query: "only " + $media + " and (max-width: " + ($max - 1) + ")";
} @else if $min != -1 and $max == -1 {
$query: "only " + $media + " and (min-width: " + $min + ")";
}
@krambuhl
krambuhl / grid.scss
Last active August 29, 2015 14:05
updated grid version using respond.scss general media query maker
$grid-max: 12;
$grid-column: 80px;
$grid-gutter: 0;
@function gridw ($span: $grid-max, $offset: 0) {
@if $span != -1 {
@return ($grid-column * $span) + ($grid-gutter * ($span - 1)) + $offset;
}
@return -1;