- Test in a clean environment
https://developer.chrome.com/devtools/docs/clean-testing-environment
- Test against prod build
ember s --environment=production
- Don't minify JS
# Set up a listener | |
nc -l 1234 | |
# spawn ember-cli that proxies to the listener | |
ember s --proxy http://localhost:1234 | |
# curl "as ajax" | |
curl -H 'X-Requested-With: XMLHttpRequest' -H 'Accept: application/json' localhost:4200/api/foo | |
#result in the listener tab: |
// The following two function convert string Maps to and from objects: | |
// http://www.2ality.com/2015/08/es6-map-json.html | |
function strMapToObj(strMap) { | |
let obj = Object.create(null); | |
for (let [k,v] of strMap) { | |
// We don’t escape the key '__proto__' | |
// which can cause problems on older engines | |
obj[k] = v; | |
} |
https://developer.chrome.com/devtools/docs/clean-testing-environment
ember s --environment=production
export default Ember.Component.extend({ | |
_setup: Ember.on('init', function() { | |
//do stuff in this method | |
}), | |
_teardown: Ember.on('willDestroyElement', function() { | |
//if you need a spot to tear down ... | |
}) | |
}); |
/** | |
README.md | |
1. Copy & paste the input file into third-party.css as raw CSS | |
2. $ node css-negator.js | |
3. When finished, the final copy will be in the file named: negated-output.css | |
*/ | |
var css = require('css'); | |
var fs = require('fs'); | |
var colors = require('colors'); |
// app/services/locale.js | |
export default Ember.Service.extend(Ember.Evented, { | |
init() { | |
this._super(...arguments); | |
// initialize locales from localStorage (or URL string) | |
}, | |
currentLocale() { | |
return ...; |
Wierd tricks you can stop using in Ember 2.0 | |
{{! Input component with Error handling }} | |
{{input value=(mut (get model field))}} | |
{{#each (get model (concat "errors." field)) as |error|}} | |
{{error}} | |
{{/each}} | |
// Remove jQuery's ability to evaluate code in a global context | |
// When you go from text -> script, do not execute eval() | |
// Taken from: https://www.youtube.com/watch?v=vD4G358rEUY&index=8&list=PL4eq2DPpyBbk5hPbX1kSoIpPspYKoeC5V | |
$.globalEval = function() {}; | |
$.ajaxSetup({ | |
converters: { | |
'text script': text => text | |
} | |
}); |
let getRandomBytes = ( | |
(typeof self !== 'undefined' && (self.crypto || self.msCrypto)) | |
? function() { // Browsers | |
var crypto = (self.crypto || self.msCrypto), QUOTA = 65536; | |
return function(n) { | |
var a = new Uint8Array(n); | |
for (var i = 0; i < n; i += QUOTA) { | |
crypto.getRandomValues(a.subarray(i, i + Math.min(n - i, QUOTA))); | |
} | |
return a; |
/* | |
Best practice in ember to ensure all actions will always fire correctly | |
*/ | |
[data-ember-action], a, button, input, .link { | |
cursor: pointer; | |
} |