Skip to content

Instantly share code, notes, and snippets.

JSONAPI - Kabab case only. No camel case
data
type (plural)
id (string of a number)
attributes (payload)
relationships (minial JSONAPI form inside. Type (can be singular or plural) and id. can also be an Array)
links (optional but ember-data does support links)
included (optional. Type, id and attributes. Always an Array)
====================================================================
@visualjeff
visualjeff / gist:8c04d19680293fdb2af7c69023022563
Last active July 30, 2016 22:24
Ember Component Learnings
Ember Component Learnings:
==========================
Don't ever assign a dynamic value to a id or name attribute of a field
Don't share state between components. Always reset or init properties via the init method. Same for mixins.
Warning:
========
Because components are sealed from outside events. It challenging to
get them to refresh on command. To pull this off you essentially need
them to observe a property on a controller in order to get them to refresh.
//Check to see if promise is already running
if (this.isRunning) { return; }
//Promise is success, but we need to check on the parent before we make
changes to the parent.
if (this.isDestroyed) { return; }
@visualjeff
visualjeff / gist:c7ad3f51845c79476fc7b6da5d4dc722
Created July 30, 2016 22:25
Node.js best practices (to build over time)
Node best practices:
#!/usr/bin/env node
'use strict';
// Provide a title to the process in `ps`
process.title = 'description of what is actually running';
Use "nopt" package for option parsing from command line input.
Regex tips for JOI:
^ asserts that the regular expression must match at the beginning of the subject
[] is a character class - any character that matches inside this expression is allowed
A-Z allows a range of uppercase characters
a-z allows a range of lowercase characters
. matches a period rather than a range of characters
\s matches whitespace (spaces and tabs)
_ matches an underscore
- matches a dash (hyphen); we have it as the last character in the character class so it doesn't get interpreted as being part of a character range. We could also escape it (\-) instead and put it anywhere in the character class, but that's less clear
@visualjeff
visualjeff / gist:3382931063d0f7659be5e6663569b866
Created August 3, 2016 18:21
VS Code TypeScript Code completion how to and how to debug node.js in VS Code
To add code completion for node.js
==================================
sudo npm install typings --global
typings search --name node
typings install env~node --global --save
Then I added the following to the top of my index.js file.
/// <reference path="typings/index.d.ts"/>
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
yenConverter: Ember.inject.service(),
actions: {
switchCurrency(){
this.get('yenConverter').switchCurrency();
}
}
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'EAM V.2.0.0'
});
import Ember from 'ember';
const {$}= Ember; //JQuery reference for events
import layout from '../templates/components/checkbox-component';
const {
Component,
get
} = Ember;
const MyComponent = Ember.Component.extend({
import Ember from 'ember';
const {$}= Ember; //JQuery reference for events
import layout from '../templates/components/checkbox-component';
const {
Component,
get
} = Ember;
const MyComponent = Ember.Component.extend({