Skip to content

Instantly share code, notes, and snippets.

View patrickberkeley's full-sized avatar

Patrick Berkeley patrickberkeley

View GitHub Profile
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['color'],
color: null
});
import Ember from 'ember';
export default Ember.Controller.extend({
queryParams: ['color'],
color: 'red'
});
@patrickberkeley
patrickberkeley / adapters.application.js
Last active January 27, 2016 05:10
load-nested-resources-on-demand
import DS from 'ember-data';
export default DS.FixtureAdapter.extend();
@patrickberkeley
patrickberkeley / application.js
Created March 13, 2014 19:21
Set the current path as a class on ember's application view.
App.ApplicationView = Ember.View.extend({
classNames: ['app'], // Static classes here.
classNameBindings: ['classForPath'], // Your dynamic path here.
classForPath: (function() {
var currentPath = this.get('controller.currentPath') || '';
currentPath = Ember.String.decamelize(currentPath);
currentPath = currentPath.split('.').join('-');
return currentPath;
}).property('controller.currentPath')
});
this.get('controller.target.location.location.pathname');
@patrickberkeley
patrickberkeley / mock_request.coffee
Last active August 29, 2015 13:57
Wrapper for mocking AJAX requests with Mockjax - https://github.com/appendto/jquery-mockjax
# Wrapper for mocking AJAX requests with Mockjax - https://github.com/appendto/jquery-mockjax
#
# Arguments:
#
# url - String, endpoint for request you want to capture
# response - Object, response you expect to be returned from the endpoint
# opts - Object (optional)
# opts.type - String, the HTTP request type. Default 'GET'
# opts.status - Integer, the HTTP response status code. Default 200
# opts.data - Object, data object passed with request. Default null
@patrickberkeley
patrickberkeley / test_helper.coffee
Created March 7, 2014 21:45
Ember test helper for bootstrapping qunit tests
document.write('<div id="ember-testing-container"><div id="ember-testing"></div></div>')
App.rootElement = '#ember-testing'
App.ApplicationAdapter = DS.FixtureAdapter.extend()
App.setupForTesting()
App.injectTestHelpers()
window.exists = (selector) ->

This grouped bar chart is constructed from a CSV file storing the populations of different states by age group. The chart employs conventional margins and a number of D3 features:

@patrickberkeley
patrickberkeley / README.md
Last active December 19, 2015 18:48 — forked from mbostock/.block

A variation of the example bar chart using a slightly more D.R.Y. style. The visual encoding is represented by two functions and their composition:

  • The value accessor returns the value (or property) to encode for a given data object.
  • The scale maps this value to a visual display encoding, such as a pixel position.
  • The map function represents the composition valuescale, mapping from data to display.

Inspired by Andrew Winterman’s post, Tooling for the Lazy Programmer: DRYing up D3.