Skip to content

Instantly share code, notes, and snippets.

View jesstelford's full-sized avatar

Jess Telford jesstelford

View GitHub Profile
@jesstelford
jesstelford / jquery.textfill.js
Created February 1, 2012 00:57
jQuery Plugin to resize text to fit container
(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),
console.log('Before custom event handler');
$('button').on('customEvent', function(){
console.log('customEvent Caught');
});
console.log('Before custom event handler');
$(document).on('customEvent', function(){
console.log('customEvent Caught');
});
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z_][A-Za-z0-9_]+\.)*([A-Za-z_][A-Za-z0-9_]+)( extends ([A-Za-z][A-Za-z0-9_.]*)+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?(([A-Za-z][A-Za-z0-9_.]*)+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,field/
--regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?/\3/f,field/
@jesstelford
jesstelford / index.html
Created September 24, 2013 16:00
Getting `Cannot read property '_thoraxBind' of undefined` errors in Thorax 2.0.1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js"></script>
@jesstelford
jesstelford / pr-compare.sh
Last active December 5, 2022 10:46
List the Pull Requests which have been merged into one branch but not another. Execute this from within a git directory that has it's `origin` remote set to github.
#!/bin/sh
if (( $# < 2 )) || (( $# > 3 ))
then
echo "$0 <are-in-this-branch> <are-not-in-this-branch> [<url-of-repo>]"
exit 1
fi
URLPREFIX=
if (( $# == 3 ))
then
URLPREFIX=$(echo "$3/pull/" | sed -e 's/[\/&]/\\&/g')
@jesstelford
jesstelford / gist:7829992
Last active December 30, 2015 12:39
A mirror of my post about efficient EPA collision detection

Original Post

G'Day all,

I'm at that stage in my physics engine where I need to get the Penetration Depth of two colliding polyhedra. So, I've written a GJK implementation based on Casey's geometric simplification (along with suggestions from Rory, etc, in this thread)

Now, I am using Jay's method of finding the penetration depth along the relative motion vector (as described here and here), but this fails when there is no relative velocity between the bodies. So, I am falling back on EPA.

@jesstelford
jesstelford / index.coffee
Last active August 29, 2015 13:57
Minimal node.js express example showcasing hoisting, type coercion, module patterns, closures, strict mode, and how to avoid nasty `undefined` issues.
# The same as `index.js`, but in Coffeescript. Try it out here: http://michaelficarra.github.io/CoffeeScriptRedux/#try:
express = require 'express'
class Foo
'use strict'
defaultQuery = {}
query: undefined
toString: ->
if @query?

Keybase proof

I hereby claim:

  • I am jesstelford on github.
  • I am jesstelford (https://keybase.io/jesstelford) on keybase.
  • I have a public key whose fingerprint is FC98 1149 9D7A EB37 B053 1530 216F EC51 DFDC 3091

To claim this, I am signing this object:

@jesstelford
jesstelford / asyncSeries.js
Created April 27, 2015 04:35
asyncSeries to ensure promises complete in correct order
/**
* Will execute success/fail in the order of the promises in the Iterable, even
* though they are executed in parallel.
*
* If `fail` is executed, no more promises in the series will be handled.
*
* @param promises An Iterable of Promises
* @param success a function which accepts the results of the promise
* @param fail a function which accepts the failure of the promise
*/