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 Component from '@glimmer/component';
export default class extends Component {
get shouldLimit() {
return this.args.items.length > this.args.showMax;
}
get items() {
if (this.shouldLimit) {
const [...items] = this.args.items;
import Component from '@ember/component';
export default class extends Component {
}
@nightire
nightire / controllers.application\.js
Created March 4, 2020 03:06
example to use each-in
import Controller from '@ember/controller';
class ApplicationController extends Controller {
abvalues = [
{a:{title:"First A"},b:{title:"First B"}},
{a:{title:"Second A"},b:{title:"Second B"}},
]
}
export default ApplicationController;
@nightire
nightire / controllers.application.js
Last active January 4, 2019 08:05
Change state by route link
import Controller from '@ember/controller';
import { inject } from '@ember/service';
import { set } from '@ember/object';
export default Controller.extend({
state: inject(),
router: inject(),
@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';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
appVersion: Ember.VERSION,
});
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 / debug_ember_app_in_vscode.md
Created May 17, 2018 11:21
How to debug an ember application with VS Code

Step 1: Launch Google Chrome with Remote Debugging support

  • windows: <path to chrome>/chrome.exe --remote-debugging-port=9222
  • macOS: /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
  • linux: google-chrome --remote-debugging-port=9222

Step 2: Install "Debugger for Chrome" extension

Step 3: Setup your application

@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');