Skip to content

Instantly share code, notes, and snippets.

View ourmaninamsterdam's full-sized avatar

Justin Perry ourmaninamsterdam

View GitHub Profile
@ourmaninamsterdam
ourmaninamsterdam / gist:b2bda53a5b1ecbb2133c
Created May 7, 2014 13:57
Libary-less addClass and removeClass functions
function addClass(elem, newClass) {
var curClass = elem.className;
if(!new RegExp(newClass,'i').test(curClass)){
if(curClass.length > 0 && curClass.charAt(curClass.length) === '') {
newClass = ' ' + newClass;
}
elem.className += newClass;
}
};
@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 / Canvas-Chart.markdown
Created September 17, 2013 21:06
A Pen by Justin Perry.

Canvas Chart

JavaScript class for creating simple charts in Canvas. Uses requestAnimationFrame for smooth animations and includes options for variable speed and multiple linear gradient stops. Includes HiDPI resize.

A Pen by Justin Perry on CodePen.

License.

@ourmaninamsterdam
ourmaninamsterdam / gist:6430454
Created September 3, 2013 22:27
Underscoreesque template replace. Needs some work.
mystr.replace(/<%=.+?%>/g, function(a,b){ return a;})
@ourmaninamsterdam
ourmaninamsterdam / gist:6397870
Created August 31, 2013 12:23
Get text from inside tags
<.+?>
<a href="http://www.google.com">Google</a>
<a class="myclass" href="http://www.bbc.co.uk">BBC</a>
<a id="myid" href="http://www.yahoo.com" class="myclass">Yahoo</a>
<div><a href="http://www.google.com">Google</a></div>
@ourmaninamsterdam
ourmaninamsterdam / gist:6397798
Created August 31, 2013 11:55
Get ULR fragment. greedy
#[^\/\?]+
@ourmaninamsterdam
ourmaninamsterdam / index.html
Created August 8, 2013 10:31
A CodePen by Justin Perry.
<div class="flex">
<!--div*6>table>tr*8>tr*8>td*7>{Eius facere reprehenderit esse praesentium eligendi.}-->
<div>
<table>
<col style="width: auto" />
<col style="width: 20%" />
<col style="width: 30%" />
<col style="width: 20%" />
<col style="width: 10%" />
<col style="width: 10%" />