Skip to content

Instantly share code, notes, and snippets.

View nightire's full-sized avatar
Looking for new opportunities

余凡 nightire

Looking for new opportunities
View GitHub Profile
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
appVersion: Ember.VERSION,
});
@nightire
nightire / application.controller.js
Last active August 8, 2018 17:37
e-c: waitForProperty
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
}
import Ember from 'ember';
import { task, waitForEvent } from 'ember-concurrency';
const { Evented, Controller } = Ember;
export default Controller.extend(Evented, {
myTask: task(function* () {
while (true) {
let payload = yield waitForEvent(this, 'message');
this.get('messages').pushObject(payload);
}
@nightire
nightire / application.controller.js
Last active July 8, 2018 06:49
Application Template
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
}
@nightire
nightire / define_method.md
Last active March 29, 2018 09:01
善用 define_method

善用 define_method

define_method 可以帮助我们动态的,快速的定义多个方法;比如有这样一个类:

class Post
  attr_accessor :title, :content, :state

  def initialize(title, content, state = :draft)
    @title, @content, @state = title, content, state
@nightire
nightire / Flexible Dockerized Phoenix Deployments.md
Created February 26, 2018 11:14 — forked from jswny/Flexible Dockerized Phoenix Deployments.md
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai

@nightire
nightire / components.data-binding.js
Last active February 25, 2018 11:18
possible bug about one way binding
import Ember from 'ember';
export default Ember.Component.extend({
bar: 0,
actions: {
change() {
// if comment out this line, mutation will be updated in template properly
this.toggleProperty('foo');
@nightire
nightire / application.route.js
Last active February 6, 2018 13:34
Data Binding
import Ember from 'ember';
export default Ember.Route.extend({
activate() {
document.body.classList.add('standard');
}
});
import Ember from 'ember';
const { Controller } = Ember;
export default class ApplicationController extends Controller {
constructor() {
super(...arguments);
this.application_name = '<code>as</code> pattern';
}
}
@nightire
nightire / application.controller.js
Last active January 28, 2018 11:08
double loop
import Ember from 'ember';
const { Controller } = Ember;
export default class ApplicationController extends Controller {
constructor() {
super();
this.application_name = 'Double Loop';
}
}