Skip to content

Instantly share code, notes, and snippets.

@tphalp
tphalp / undo.js
Last active August 29, 2015 14:13 — forked from ericflo/undo.js
var UndoMixin = {
getInitialState: function() {
return {
undo: []
};
},
handleUndo: function() {
if (this.state.undo.length === 0) {
return;
/**
* Compares two software version numbers (e.g. "1.7.1" or "1.2b").
*
* This function was born in http://stackoverflow.com/a/6832721.
*
* @param {string} v1 The first version to be compared.
* @param {string} v2 The second version to be compared.
* @param {object} [options] Optional flags that affect comparison behavior:
* <ul>
* <li>
// Throttle: only execute callback if more than 'ms' has passed since last successful call
var throttle = function (ms, func) {
var last;
return function () {
var now = new Date();
if (now - last < ms) {
return;
}
func.apply(this, arguments);
last = now;
@tphalp
tphalp / jquery.textfill.js
Created March 5, 2013 19:16 — forked from juliankrispel/jquery.textfill.js
Same as https://gist.github.com/tphalp/5093228, except that this one recalculates the font size when the window is re-sized.
(function($) {
$.fn.textfill = function(maxFontSize) {
maxFontSize = parseInt(maxFontSize, 10);
return this.each(function(){
var ourText = $("span", this);
function resizefont(){
var parent = ourText.parent(),
maxHeight = parent.height(),
maxWidth = parent.width(),
fontSize = parseInt(ourText.css("fontSize"), 10),
@tphalp
tphalp / jquery.textfill.js
Last active December 14, 2015 13:28 — forked from jesstelford/jquery.textfill.js
Re-sizes text font to fill container element.
(function($) {
$.fn.textfill = function(maxFontSizePx, minFontSizePx, element) {
maxFontSizePx = parseInt(maxFontSizePx, 10);
minFontSizePx = parseInt(minFontSizePx, 10);
if (maxFontSizePx > 0 && minFontSizePx > maxFontSizePx) {
minFontSizePx = maxFontSizePx;
}
element = typeof(element) == "string" ? element : "span";
return this.each(function(){
var ourText = $(element, this),
@tphalp
tphalp / Custom.css
Created October 15, 2012 20:48 — forked from bentruyman/Custom.css
IR_Black Theme for Chrome Developer Tools
/**********************************************/
/*
/* IR_Black Skin by Ben Truyman - 2011
/*
/* Based on Todd Werth's IR_Black:
/* http://blog.toddwerth.com/entries/2
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*