Skip to content

Instantly share code, notes, and snippets.

View GavinJoyce's full-sized avatar

Gavin Joyce GavinJoyce

View GitHub Profile
This file has been truncated, but you can view the full file.
alert(1);
/*!
* @overview Ember - JavaScript Application Framework
* @copyright Copyright 2011-2014 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
* @version 1.7.0-beta.1+canary.6555b15a
@GavinJoyce
GavinJoyce / gist:54c03bd4048a8f64742e
Last active August 29, 2015 14:05
Simple spike of an incremental backoff for Ember.js
// **EDIT**: I've created an ember-cli addon for this here:
//
// https://github.com/GavinJoyce/ember-backoff
var delay = function(milliseconds) {
milliseconds = milliseconds || 2000;
return new Em.RSVP.Promise(function(resolve) {
Em.run.later(this, function() {
@GavinJoyce
GavinJoyce / gist:0caa08b3cea7af044cf8
Last active August 29, 2015 14:14
Ember listener debugging
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, 'startsWith', {
enumerable: false,
configurable: false,
writable: false,
value: function(searchString, position) {
position = position || 0;
return this.lastIndexOf(searchString, position) === position;
}
});
@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 / webdis
Created May 28, 2012 14:30 — forked from xiangjian/redis-server
redis & webdis init script for ubuntu
#! /bin/sh
### BEGIN INIT INFO
# Provides: webdis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: webdis-server - Persistent key-value db
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@GavinJoyce
GavinJoyce / Heroku git Commands
Created November 27, 2012 10:51
My most used heroku and git commands
heroku apps:create [appname]
heroku open
heroku config
heroku run rake [task]
heroku keys
heroku logs
g='git'
gst='git status'
gl='git pull'
@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 / singleton.js
Created August 27, 2013 14:31
Ember Singleton
App.Singleton = Em.Mixin.create({
instance: function() {
if(!this._instance) {
this._instance = this.createInstance();
}
return this._instance;
},
//override this in your class