In this guide we will cover two main cases:
- Ember specific library
- vendor library
The Ember library will assume that Ember has already ben loaded (higher in the loading order) and thus will assume it has access to the Ember API.
| import Controller from '@ember/controller'; | |
| import { inject as service } from '@ember/service'; | |
| export default class extends Controller { | |
| @service('query-params') params; | |
| // queryParams = this.params.buildControllerParams('application', { | |
| // composeWith: [this.params.getDatatableParams('controls')] | |
| // }); | |
| } |
| // Credits to the following posts that helps me to reduce build times drastically | |
| // https://discuss.emberjs.com/t/tips-for-improving-build-time-of-large-apps/15008/12 | |
| // https://www.gokatz.me/blog/how-we-cut-down-our-ember-build-time/ | |
| //ember-cli-build.js | |
| let EmberApp = require('ember-cli/lib/broccoli/ember-app'); | |
| let env = EmberApp.env(), |
| function makePropertyMapper<T>(prototype: any, key: string, mapper: (value: any) => T) { | |
| const values = new Map<any, T>(); | |
| Object.defineProperty(prototype, key, { | |
| set(firstValue: any) { | |
| Object.defineProperty(this, key, { | |
| get() { | |
| return values.get(this); | |
| }, | |
| set(value: any) { | |
| values.set(this, mapper(value)); |
| import Ember from 'ember'; | |
| import ApplicationAdapter from 'adapters/application'; | |
| const {RSVP, run} = Ember; | |
| export default ApplicationAdapter.extend({ | |
| //unloads existing record if create record returns a duplcate. | |
| createRecord(store, type, snapshot) { | |
| let saving = this._super(store, type, snapshot); |
| // from https://rosettacode.org/wiki/Haversine_formula#Elixir | |
| defmodule Haversine do | |
| @v :math.pi / 180 | |
| @r 6372.8 # km for the earth radius | |
| def distance({lat1, long1}, {lat2, long2}) do | |
| dlat = :math.sin((lat2 - lat1) * @v / 2) | |
| dlong = :math.sin((long2 - long1) * @v / 2) | |
| a = dlat * dlat + dlong * dlong * :math.cos(lat1 * @v) * :math.cos(lat2 * @v) | |
| @r * 2 * :math.asin(:math.sqrt(a)) |
| machine: | |
| node: | |
| version: 0.10.28 | |
| dependencies: | |
| pre: | |
| - npm install -g bower | |
| override: | |
| - npm i | |
| - bower i | |
| deployment: |
| // Include gulp | |
| var gulp = require('gulp'); | |
| // Include Our Plugins | |
| var sass = require('gulp-sass'); | |
| var lr = require('tiny-lr'), | |
| refresh = require('gulp-livereload'), | |
| server = lr(); |
Example for Cooperative Brushing and Tooltips in D3.
The completed chart, with both tooltips and brushing working cooperatively. You can start a brush-zoom on either the background or a data point.
| #app/inputs/collection_check_boxes_input.rb | |
| class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput | |
| def item_wrapper_class | |
| "checkbox-inline" | |
| end | |
| end |