Skip to content

Instantly share code, notes, and snippets.

View HenryVonfire's full-sized avatar

HenryVonfire

View GitHub Profile
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
actions: {
test() {
this.model.forEach(person => person.rollbackAttributes());
this.store.push({
data: {
// primary data for single record of type `Person`
if(!("valueAsDate" in HTMLInputElement.prototype)){
Object.defineProperty(HTMLInputElement.prototype, "valueAsDate", {
get: function(){
var d = this.value.split(/\D/);
return new Date(d[0], --d[1], d[2]);
},
set: function(d){
var day = ("0" + d.getDate()).slice(-2),
month = ("0" + (d.getMonth() + 1)).slice(-2),
datestr = d.getFullYear()+"-"+month+"-"+day;
@HenryVonfire
HenryVonfire / controllers.application.js
Last active October 8, 2018 23:15 — forked from samselikoff/mirage.config.js
Example of Model.reopen that fails in ember > 3.2
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
showText() {
// this throws an error of exampleFun is not a function
// in ember > 3.2 when ec-mirage is enabled
this.model.exampleFun();
}
}
@HenryVonfire
HenryVonfire / adapters.application.js
Created September 10, 2018 07:23 — forked from runspired/adapters.application.js
Ember Data - Save Transaction
import Adapter from 'ember-data/adapters/json-api';
import Ember from 'ember';
import RSVP from 'rsvp';
const { Promise } = RSVP;
const { get } = Ember;
class Transaction {
constructor(store, ModelClass, primary, transactionMembers) {
this.store = store;
@HenryVonfire
HenryVonfire / components.list-data.js
Created September 5, 2018 07:45 — forked from mike-north/components.list-data.js
display + presentation
import Ember from 'ember';
import hbs from 'htmlbars-inline-precompile';
export default Ember.Component.extend({
layout: hbs`{{yield sortedItems}}`,
sortedItems: Ember.computed('data.@each.id', 'sort', function() {
const sort = this.get('sort');
const sorted = [...this.get('data')].sort((a, b) => {
if (sort === 'up') return a.id - b.id;
return b.id - a.id;
@HenryVonfire
HenryVonfire / components.my-component.js
Last active September 5, 2018 07:34 — forked from mike-north/components.my-component.js
component-data-provider
import Ember from 'ember';
// it makes the issue of async really simple, in that you just care about the array {{my-component}} yields out
// it may at some times be empty, it may have some stuff later -- you're just binding to it. No promises for you to worry about
// you could do the same thing with the API call currently in your controller, and then break out code that consumes that data into other components.
// to make this even fancier, you could add Ember.run.debounce to avoid race conditions
export default Ember.Component.extend({
term: '',
init() {
this._super(...arguments);
this.set('results', []);
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@HenryVonfire
HenryVonfire / debug_ember_app_in_vscode.md
Created May 18, 2018 07:18 — forked from nightire/debug_ember_app_in_vscode.md
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

@HenryVonfire
HenryVonfire / GitHub-Forking.md
Created January 19, 2018 12:03 — forked from Chaser324/GitHub-Forking.md
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

@HenryVonfire
HenryVonfire / controllers.application.js
Created November 23, 2017 13:00 — forked from sukima/controllers.application.js
Ember Concurrency Task Model / Nested Routes
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Concurrency Decendants'
});