Skip to content

Instantly share code, notes, and snippets.

import Ember from 'ember';
export default Ember.Component.extend({
currentUsername: '',
currentSecret: '',
dataService: Ember.inject.service(),
init() {
this._super(...arguments);
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
init() {
this._super(...arguments);
let rejectPromise;
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
add() {
this.get('foo').pushObject(5);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
stableItem: {},
something: {},
actions: {
setSomething: function() {
this.set('something', {});
}
export default Component.extend({
actions: {
beginApplePay() {
let item = this.get('item');
let price = item.get('price');
let paymentRequest = {
requiredShippingContactFields: ['email', 'postalAddress'],
countryCode: 'US',
currencyCode: 'USD',
total: {
@mitchlloyd
mitchlloyd / apple-pay-button.js
Created January 13, 2017 20:56
Wrap Third Party APIs - Ideal Interface
beginApplePay() {
// ... snip!
this.get('applePay').charge(paymentRequest).then({ result, notify } => {
this.get('onChargeSuccess')({
shippingContact: result.shippingContact,
token: result.token.id,
price,
item,
description: `201 Created Sticker: ${item.get('name')}`
@mitchlloyd
mitchlloyd / apple-pay-button-test.js
Last active January 13, 2017 22:27
Wrap Third Party APIs - Test
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import wait from 'ember-test-helpers/wait';
import FakeApplePay from 'bodega/tests/fakes/apple-pay';
moduleForComponent('apple-pay-button', 'Integration | Component | apple pay button', {
integration: true,
beforeEach() {
this.register('service:apple-pay', FakeApplePay);
@mitchlloyd
mitchlloyd / apple-pay.js
Last active January 13, 2017 21:34
Wrap Third Party APIs - Fake
import Ember from 'ember';
const { Service, RSVP } = Ember;
export default Service.extend({
init() {
this._super(...arguments);
// We record both the charges sent and notifications sent to verify in
// our tests.
this.chargesSent = [];
@mitchlloyd
mitchlloyd / apple-pay.js
Last active January 13, 2017 22:55
Wrap Third Party APIs - Adapter
/* globals Stripe, ApplePaySession*/
import Ember from 'ember';
const { Service, RSVP, run } = Ember;
export default Service.extend({
charge(paymentRequest) {
return new RSVP.Promise(function(resolve, reject) {
let runLoopResolve = (...args) => run.join(() => resolve(...args));
let runLoopReject = (...args) => run.join(() => reject(...args));
Stripe.applePay.buildSession(paymentRequest, buildSuccessHandler(runLoopResolve), runLoopReject).begin();
@mitchlloyd
mitchlloyd / resources.md
Last active January 24, 2017 22:58
Some software productivity resources

Getting Things Done by David Allen - This is a personal productivity system that encourages capturing all "projects" and being intentional about what the single "next action" is for any given project.

User Story Mapping by Jeff Patton - Honestly I did not read all of this and I probably should. However, I know this was very influential for people that I've worked with.

Kanban Development Oversimplified by Jeff Patton - This blog post does a good job of summarizing Kanban ideas in the context of Scrum and Agile.

Growing Object Oriented Software Guided by Tests by Nat Pryce and Steve Freeman - This includes a nice overview of an "outside-in" approach to software development using tests. The concept of a "walking skeleton" has been very useful for me.

Dreaming in Code by Scott Rosenburge - It's been a while since I read this but I know it covers things like "Mythical Man Month" in a story driven way.