Skip to content

Instantly share code, notes, and snippets.

View tdreyno's full-sized avatar

Thomas Reynolds tdreyno

  • Portland, OR
  • 22:40 (UTC -07:00)
View GitHub Profile
@tdreyno
tdreyno / gist:4947918
Created February 13, 2013 20:25
Cross-platform mouse/touch events
var evts = [],
touchEvt,
mouseEvt,
msEvent;
if (evt === 'up') {
touchEvt = 'touchend';
mouseEvt = 'mouseup';
msEvent = 'MSPointerUp';
} else if (evt === 'move') {
# Store somewhere
class SitemapGenerator
def initialize(app)
@app = app
end
def manipulate_resource_list(resources)
sitemap_builder = ::Middleman::Sitemap::Resource.new(
@app.sitemap,
@tdreyno
tdreyno / gist:4531832
Last active December 11, 2015 02:39
Polyfill for new Chrome submillisecond requestAnimationFrame timer
function rightNow() {
if (window['performance'] && window['performance']['now']) {
return window['performance']['now']();
} else {
return +(new Date());
}
}
@tdreyno
tdreyno / airports.json
Created December 13, 2012 18:50
JSON data for airports and their locations
This file has been truncated, but you can view the full file.
[
{
"code": "AAA",
"lat": "-17.3595",
"lon": "-145.494",
"name": "Anaa Airport",
"city": "Anaa",
"state": "Tuamotu-Gambier",
"country": "French Polynesia",
@tdreyno
tdreyno / one-off-animation.js
Created October 1, 2012 19:38
One-off animation with rAF
function oneOffAnimation(from, to, duration, easing, onUpdate, onComplete) {
var t = new TWEEN.Tween(from)
.to(to, duration)
.easing(easing)
.onUpdate(onUpdate)
.onComplete(function _onComplete() {
t.done = true;
});
var self = this;
@tdreyno
tdreyno / multiplexing_collection.js
Created September 23, 2012 22:27
An Ember.js Collection view which has childViews depending on a property of the data row.
FS.MultiplexingCollectionView = Em.CollectionView.extend({
itemViewClass: Em.View,
typeProperty: "type",
viewMap: {},
createChildView: function(view, attrs) {
var map = this.get("viewMap");
var prop = this.get("typeProperty");
@tdreyno
tdreyno / multiplexing_model.js
Created September 23, 2012 22:16
"Single Table Inheritance" for Ember.js
/**
* A root "Model" class for Objects which have inherited types based on
* a configurable per-object value.
*/
FS.MultiplexingModel = Em.Object.extend({
});
/**
* The great hash of klasses and types
@tdreyno
tdreyno / pool.js
Created September 23, 2012 22:13
Ember.js View and Model pooling
/**
* A View Pool
*/
FS.ViewPool = Em.ArrayController.extend({
content: [],
viewClass: null,
createViewOnEmpty: true,
takeView: function(content) {
@tdreyno
tdreyno / SwiffyLoader.js
Created September 2, 2012 22:36
JSON/Swiffy PxLoader extension
// @depends PxLoader.js
/**
* PxLoader plugin to load swiffy
*/
function PxLoaderSwiffy(name, tags, priority) {
var self = this,
loader = null,
complete = false;
<p><%= image_tag "whatever.jpg" %></p>