Skip to content

Instantly share code, notes, and snippets.

Dave Porter dcporter

Block or report user

Report or block dcporter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am dcporter on github.
  • I am dcporter (https://keybase.io/dcporter) on keybase.
  • I have a public key whose fingerprint is BD85 FE84 FD28 4326 485C 3B8C AFB1 B485 1093 B29C

To claim this, I am signing this object:

View performance.now()-polyfill.js
// relies on Date.now() which has been supported everywhere modern for years.
// as Safari 6 doesn't have support for NavigationTiming, we use a Date.now() timestamp for relative values
// if you want values similar to what you'd get with real perf.now, place this towards the head of the page
// but in reality, you're just getting the delta between now() calls, so it's not terribly important where it's placed
(function(){
// prepare base perf object
@dcporter
dcporter / proxied_array_controller.js
Last active Aug 29, 2015
An ArrayController which exposes each content item wrapped in a proxy class.
View proxied_array_controller.js
// ==========================================================================
// Project: SC.ProxiedArrayController
// Copyright: ©2014 My Company, Inc.
// ==========================================================================
/*globals SC */
/** @class
This controller implements an experimental ArrayController pattern which wraps each item in a
controller object when retrieved.
@dcporter
dcporter / local_storage_data_source.js
Last active Aug 29, 2015
A data source for SproutCore which persists data to local storage instead of to a server.
View local_storage_data_source.js
// ==========================================================================
// Project: LocalStorageDataSource For SproutCore
// Copyright: 2014 Dave Porter & contributors
// License: Licensed under MIT license
// ==========================================================================
window.DCP = window.DCP || {};
/** @class
A data source which persists records to local storage.
@dcporter
dcporter / FadingImageView.js
Created Sep 27, 2013
Fun With Transitions: ImageView that fades in on load.
View FadingImageView.js
/*
View Transitions, new in SC1.0, have made all kinds of effects drop-dead easy. Here's
an ImageView which will fade nicely in when the image loads.
*/
FadingImageView = SC.ImageView.extend({
isVisible: NO,
isVisibleBinding: SC.Binding.oneWay('.status').transform(function(status) { return status === SC.IMAGE_STATE_LOADED; }),
transitionShow: SC.View.FADE_IN,
transitionShowOptions: { duration: 0.25 },
@dcporter
dcporter / gist:6536417
Created Sep 12, 2013
Monkeypatches ManyArray with live status.
View gist:6536417
SC.ManyArray.reopen({
// Set up observers.
contentDidChange: function() {
var observedRecords = this._observedRecords;
if (!observedRecords) observedRecords = this._observedRecords = [];
var record, i, len;
// If any items in observedRecords are not in content, stop observing them.
len = observedRecords.length;
for (i = len - 1; i >= 0; i--) {
@dcporter
dcporter / SC.AutonomousStore
Last active Dec 21, 2015
A gist for patching in autonomous nested stores (see https://github.com/sproutcore/sproutcore/pull/1000) while we work out how and when to integrate the ideas.
View SC.AutonomousStore
// SC.Store (for autonomous nested stores)
SC.Store.reopen({
chainAutonomousStore: function(attrs, newStoreClass) {
var newAttrs = attrs ? SC.clone( attrs ) : {};
var source = this._getDataSource();
newAttrs.dataSource = source;
return this.chain( newAttrs, newStoreClass );
}
});
@dcporter
dcporter / timespan.js
Last active Dec 20, 2015
A proposed Timespan class for SproutCore to allow for easier comparison of time spans.
View timespan.js
// ==========================================================================
// Project: SC.Timespan
// Copyright: @2013 My Company, Inc.
// ==========================================================================
/*globals SC */
/**
Standard error thrown when trying to create a timespan with dates in
different timezones.
@dcporter
dcporter / BestFitGridView
Created Jul 21, 2013
A quick-and-dirty BestFitGridView.
View BestFitGridView
// A (quick and dirty) view which renders its content as a best-fit grid – that is, it shows all items,
// laid out as close to evenly as possible.
// Known issues:
// - doesn't update when content changes (wasn't part of my needs); easy observer fix
// - isn't a subclass of SC.CollectionView
// - someone with the maths could optimize the calculations
// - child views are never destroyed, only created and cached
BestFitGridView = SC.View.extend({
You can’t perform that action at this time.