Skip to content

Instantly share code, notes, and snippets.

Avatar
🥑
coding lotsa code

Matt Gardner allthesignals

🥑
coding lotsa code
View GitHub Profile
View extended-presence-on.js
import {
validatePresence,
} from 'ember-changeset-validations/validators';
export default function validatePresenceIf(options) {
const { withValue, on } = options;
return (...args) => {
const [,,, changes, content] = args;
const hasMatchingWith = (changes[on] || content[on]) === withValue;
View conditional-validator.js
import buildMessage from 'ember-changeset-validations/utils/validation-errors';
import { validate } from 'ember-validators';
export default function validatePresence(options) {
let targets;
if (typeof options === 'boolean') {
options = { presence: options };
} else if (options && options.on !== undefined) {
if (typeof options.on === 'string') {
targets = [options.on];
@allthesignals
allthesignals / controllers.application.js
Last active May 10, 2020 — forked from poteto/controllers.application.js
ember-changeset-validations demo
View controllers.application.js
import Ember from 'ember';
import AdultValidations from '../validations/adult';
import ChildValidations from '../validations/child';
import { reservedEmails } from '../validators/uniqueness';
import { schema } from '../models/user';
const { get } = Ember;
const { keys } = Object;
export default Ember.Controller.extend({
View mocking-mapbox-gl-tiles.md

Goal

I'd like to mock the requests for tiles made by MapboxGL using Pretender.

Problem

Pretender doesn't intercept those requests

What I've discovered

@allthesignals
allthesignals / controllers.application.js
Last active Dec 23, 2019
Mapping with Ember MapboxGL
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View feature.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View carto-data-provider.js
export default class CartoDataProvider extends Component {
@service
router;
@service
store;
modelName = 'carto-geojson-feature';
modelId = null;
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View components.my-component.js
import Ember from 'ember';
export default Ember.Component.extend({
});
You can’t perform that action at this time.