Skip to content

Instantly share code, notes, and snippets.

View dwickern's full-sized avatar

Derek Wickern dwickern

View GitHub Profile
import Ember from 'ember';
export default Ember.Component.extend({
count: 0,
actions: {
increment() {
this.sendAction('changed', this.get('count') + 1);
}
}
import Ember from 'ember';
const DEBOUNCE_MILLIS = 300;
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
value: 1,
displayText: function() {
@dwickern
dwickern / cancellable-promise.js
Created December 20, 2016 22:08
Ember cancellable promise
import Ember from 'ember';
export class CancellablePromise extends Ember.RSVP.Promise {
constructor(resolver, cancel, label) {
super(function (resolve, reject) {
try {
resolver(function resolved(value) {
cleanup();
resolve(value);
}, function rejected(reason) {
import Ember from 'ember';
export default Ember.Controller.extend({
/*openModal: function(modal, opts) {
this.controllerFor(modal).set('model', opts);
return this.render(modal, {
into: 'application',
outlet: 'modal'
});
},
@dwickern
dwickern / components.blog-post.js
Created October 5, 2016 17:13
using "send" as an action name breaks things
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
send() { this.sendAction('send'); },
delete() { this.sendAction('delete'); }
}
});
@dwickern
dwickern / templates.application.hbs
Created October 4, 2016 22:10
positional params error // ember 2.9.0-beta.4
{{input foo bar}}
import Ember from 'ember';
export default Ember.Component.extend({
imageLoaded: 'image loading',
imageWidth: 'width loading',
// purely to make sure image loads each time and
// is not cached for testing
volatileSrc: Ember.computed('src', function(){
return this.get('src') + '?cache=' + new Date().toISOString();
@dwickern
dwickern / components.async-image-wrapper.js
Created August 11, 2016 18:28 — forked from chrism/components.async-image-wrapper.js
Non working example using Ember.run
import Ember from 'ember';
export default Ember.Component.extend({
imageLoaded: 'image not yet loaded',
// purely to make sure image loads each time and
// is not cached for testing
volatileSrc: Ember.computed('src', function(){
return this.get('src') + '?cache=' + new Date().toISOString();
}),
@dwickern
dwickern / npm-debug.log
Created November 18, 2015 19:29
npm install error -- Could not get current working directory: No such file or directory
This file has been truncated, but you can view the full file.
72036 silly gunzTarPerm extractEntry node_modules/node-gyp/node_modules/path-array/node_modules/array-index/README.md
72037 silly gunzTarPerm modified mode [ 'node_modules/node-gyp/node_modules/path-array/node_modules/array-index/README.md',
72037 silly gunzTarPerm 420,
72037 silly gunzTarPerm 438 ]
72038 silly gunzTarPerm extractEntry node_modules/node-gyp/node_modules/path-array/node_modules/array-index/index.js
72039 silly gunzTarPerm modified mode [ 'node_modules/node-gyp/node_modules/path-array/node_modules/array-index/index.js',
72039 silly gunzTarPerm 420,
72039 silly gunzTarPerm 438 ]
72040 silly gunzTarPerm extractEntry node_modules/node-gyp/node_modules/path-array/node_modules/array-index/test.js
72041 silly gunzTarPerm modified mode [ 'node_modules/node-gyp/node_modules/path-array/node_modules/array-index/test.js',
@dwickern
dwickern / Macros.scala
Last active September 23, 2016 20:16
Scala "nameOf" macro: get the name of an identifier as a string at compile-time!
import scala.annotation.tailrec
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
// UPDATE: now published for your convenience!
// https://github.com/dwickern/scala-nameof
object Macros {
def nameOfImpl(c: blackbox.Context)(x: c.Tree): c.Tree = {
import c.universe._