Skip to content

Instantly share code, notes, and snippets.

View GavinJoyce's full-sized avatar

Gavin Joyce GavinJoyce

View GitHub Profile
@GavinJoyce
GavinJoyce / gist:6f60a0a6b0b3a6aba3f6
Created July 23, 2015 07:48
DublinJS / EmberJS Dublin Computed Property Macros
//Controller
import Em from 'ember';
function concatProperties(key1, key2) {
return Em.computed(key1, key2, function() {
return this.get(key1) + ' ' + this.get(key2);
});
}
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@GavinJoyce
GavinJoyce / gist:c3b5707747121ff067e7
Last active October 23, 2015 12:55
Ember component metrics
import Em from 'ember';
import Metrics from 'myapp/models/metrics';
var FrontendStatsService = Em.Service.extend({
stats: {},
timings: {},
start: function(key) {
if(window.performance) {
if(this.timings[key] === undefined) { //skip the first so we're not capturing data when loading the app
@GavinJoyce
GavinJoyce / application.controller.js
Last active January 21, 2016 20:10
concatenatedProperties
import Ember from 'ember';
//the foods array will concatinate, the colours are replaced
let Animal = Ember.Object.extend({
concatenatedProperties: ['foods'],
colours: ['white'],
foods: ['milk']
});
@GavinJoyce
GavinJoyce / gist:4f81d0bf879dad6b203e
Last active November 20, 2020 04:01
speeding up `npm install` by disabling the progress bar
with `react-native`:
npm set progress=false && rm -rf ~/.npm && rm -rf node_modules && npm cache clean && time npm install
npm install 83.72s user 26.03s system 100% cpu 1:49.32 total
npm set progress=true && rm -rf ~/.npm && rm -rf node_modules && npm cache clean && time npm install
npm install 199.30s user 27.32s system 91% cpu 4:08.29 total
--
@GavinJoyce
GavinJoyce / application.controller.js
Created February 1, 2016 21:33 — forked from JakeDetels/application.controller.js
Template registration issue
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
myComponentName: null,
actions: {
registerComponent() {
let template = Ember.Handlebars.compile('<b>First x-foo</b>');
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
myComponentName: null,
actions: {
registerComponent() {
let template = Ember.Handlebars.compile('<b>First x-foo</b>');
@GavinJoyce
GavinJoyce / application.controller.js
Created February 1, 2016 22:08 — forked from brendan-rius/application.controller.js
intermediateTransitionTo()
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
import Ember from 'ember';
export default Ember.Controller.extend({
enabled: false,
trueValue: 'T',
falseValue: 'F'
});
import Ember from 'ember';
export default Ember.Controller.extend({
enabled: false,
items: ['a'],
isNotEmpty: Ember.computed.notEmpty('items'),
actions: {
addItem: function() {
this.get('items').pushObject('another');