Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Thoburn runspired

View GitHub Profile
View controllers.application\.js
import Controller from '@ember/controller';
import { get, notifyPropertyChange } from '@ember/object';
import { tracked } from '@glimmer/tracking';
let id = 0;
class Person {
constructor(store) {
this._store = store;
this.id = 'person-' + id++;
@runspired
runspired / adapters.bar\.js
Last active Jul 21, 2020 — forked from amk221/adapters.bar\.js
Ember Data promise proxy
View adapters.bar\.js
import RESTAdapter from 'ember-data/adapters/rest';
export default class FooAdapter extends RESTAdapter {
ajax(path, method, options) {
const id = path.match(/\d+/)[0];
return {
bar: {
id: id,
name: `Bar${id}`
}
View components.product-selector\.js
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
const Products = [
{
name: 'learning',
versions: [
{ tag: '1.0.0', deprecated: true },
{ tag: '1.1.0', deprecated: false },
View controllers.application\.js
import Controller from '@ember/controller';
import EmberObject, { get, set } from '@ember/object';
import { getOwner } from '@ember/application';
const RecordMeta = new WeakMap();
function getRecordMeta(record) {
let meta = RecordMeta.get(record);
if (meta === undefined) {
meta = Object.create(null);
RecordMeta.set(record, meta);
View controllers.application\.js
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
View components.ember-data-test-rollback-new\.js
import Ember from 'ember';
const { Component, inject, get } = Ember;
export default Component.extend({
store: inject.service(),
init() {
this._super(...arguments);
this.log = Ember.A();
let record = this.get('store').createRecord('dummy');
View covid-calculator.js
function calculateIntervals(mortality = 0.001 /* a number from 0-1 for proportion that will die */) {
const doubling = 2.11578003167; // based on New York's doubling rate in deaths between 1st death and April 1st
const seedDailyDeaths = 505; // number of Deaths on April 1st
const incubation = 14; // average days from start to death
let getDay0 = (deaths) => {
let doublingTime = (Math.log(deaths / mortality) * doubling) / Math.log(2);
return doublingTime + incubation;
}
View controllers.application\.js
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
import Ember from 'ember';
const AMixin = Ember.Mixin.create({
appName: undefined
});
export default Controller.extend(AMixin {
store: service('store'),
View adapters.application\.js
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import HasManyQueryAdapterMixin from 'ember-data-has-many-query/mixins/rest-adapter';
export default JSONAPIAdapter.extend(HasManyQueryAdapterMixin, {
host: 'https://api.eventyay.com',
namespace : 'v1'
})
View adapters.application.js
import RSVP from 'rsvp';
const RecordArrays = new WeakSet();
const PREFLIGHT_PAYLOAD = {
data: [
{ type: 'user', id: '1', },
{ type: 'user', id: '2', },
{ type: 'user', id: '3', },
{ type: 'user', id: '4', },
{ type: 'user', id: '5', },
You can’t perform that action at this time.