Skip to content

Instantly share code, notes, and snippets.

View alexdiliberto's full-sized avatar

Alex DiLiberto alexdiliberto

View GitHub Profile
@alexdiliberto
alexdiliberto / ember-concurrency-tips.md
Last active January 15, 2018 16:39
ember-concurrency Tips and Tricks

Using ember-concurrency to easily load data inside a component

import { task } from 'ember-concurrency';
import { readOnly } from '@ember/object/computed';

export default Component.extend({
  tags: readOnly('loadTags.lastSuccessful.value'),

 loadTags: task(function * () {
@alexdiliberto
alexdiliberto / presentational-ui-components.md
Created January 15, 2018 16:33
Presentational UI Component Architecture in Ember
{{!--
  Create a `/components/ui` directory to keep all of the ui presentational components

  In this example `ui-card` and `ui-selectable-list` are both simply presentational contextual components
--}}
{{#ui-card as |card|}}
  {{#card.header onClose=onClose}}
    Tags
 {{/card.header}}
@alexdiliberto
alexdiliberto / ember-cli-mirage-tips.md
Last active June 7, 2018 23:21
ember-cli-mirage Tips and Tricks

ember-cli-mirage Tips and Tricks

Lock randomly generated data from faker for each test run for a consistent experience

// <project>/mirage/config.js
import { faker } from 'ember-cli-mirage'

// Lock randomly generated seed data from faker
faker.seed(123);
@alexdiliberto
alexdiliberto / config_env_from_browser.md
Last active January 11, 2018 00:12
How to access ember config/environment.js variables from the browser?
  1. require('<module-prefix>/config/environment')
  2. Grab the container from wherever and .lookup('config:environment')
  3. From <meta> tag
@alexdiliberto
alexdiliberto / 0 README.md
Created November 23, 2017 04:50 — forked from caseywatts/0 README.md
d3 & c3 npm shim to es6 module for Ember

app.import() works with node_modules now! As of Ember 2.15. Previously it only worked with bower_components and vendor.

Docs for app.import are here: https://ember-cli.com/managing-dependencies#standard-non-amd-asset

This method (vendor-shim) wraps the global export into an es6 module (but the global one is still present). It doesn't use an es6 interface even if the library offers one, but that's okay for my use case.

Things could still be easier, see this thread for the current state of that.

@alexdiliberto
alexdiliberto / components.ui-hooks.js
Last active June 5, 2018 20:19
Component: UI Hooks (route template `didInsertElement`)
import Ember from 'ember';
const { get } = Ember;
export default Ember.Component.extend({
'did-insert'() {},
'will-destroy'() {},
didInsertElement() {
this._super(...arguments);
@alexdiliberto
alexdiliberto / OSX-Convert-MOV-GIF.md
Created October 2, 2017 23:13 — forked from tskaggs/OSX-Convert-MOV-GIF.md
Creating GIFs from .MOV files in OSX using FFmpeg and ImageMagick

Convert MOV to GIF using FFmpeg and ImageMagick

I tried a few different techniques to make a GIF via command-line and the following gives me the best control of quality and size. Once you're all setup, you'll be pumping out GIFs in no time!

Preparation

Install FFmpeg

  • $ brew install ffmpeg [all your options]
    • Example: $ brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Install ImageMagick

@alexdiliberto
alexdiliberto / components.edit-user.js
Last active October 2, 2017 04:25
skipValidate ember-changeset-validations demo
import Ember from 'ember';
import Changeset from 'ember-changeset';
import lookupValidator from 'ember-changeset-validations';
export default Ember.Component.extend({
init() {
this._super(...arguments);
let user = Ember.get(this, 'user');
let validations = Ember.get(this, 'validations');

Introduction

Many people are confused by the {{mut}} helper because it seems very magical. This gist aims to help you construct a mental model for understanding what is going on when you use it.

History

Prior to the introduction of {{mut}}, form elements were two-way bound by default. That is, given this component:

import Ember from 'ember';
export default Ember.Component.extend({
@alexdiliberto
alexdiliberto / readme.md
Created September 16, 2017 23:58 — forked from maxrimue/readme.md
Use yarn with Greenkeeper

Use yarn with Greenkeeper

When using yarn, it will create a yarn.lock lockfile which holds data on your used dependencies. This file also includes hard-typed versions, so should you update your dependencies, the yarn.lock file is basically outdated and needs to be regenerated. While yarn does this automatically, Greenkeeper pull requests that update dependencies as of right now do not do this regeneration, which means you would have to do it manually.

This gist shows you a way how to automatise this step using a Travis CI script.

Prerequisites

  • You use Travis CI and have it build Pull Requests (default behaviour)
  • You have a yarn.lock file in your repository for Travis CI to automatically install yarn (yarn will be added to their default images soon)

Getting started