Skip to content

Instantly share code, notes, and snippets.

@j-
j- / is-boundary-character.js
Created February 20, 2017 00:48
Check if a character is a boundary character
const isBoundary = (ch) => `a${ch}b`.split(/\b/).length > 1;
isBoundary('a'); // => false
isBoundary('A'); // => false
isBoundary('1'); // => false
isBoundary(' '); // => true
isBoundary('.'); // => true
isBoundary(','); // => true
isBoundary('|'); // => true
isBoundary('/'); // => true
console.clear();
import Em from 'ember';
export const BaseController = Em.Controller.extend({
appName: 'Ember Twiddle',
foobar: function () {
console.count('_super() called');
return 'foobar';
console.clear();
import Em from 'ember';
export default Em.Controller.extend({
appName: 'Ember Twiddle',
init: function () {
this._super();
this.testDebounceInline();
@j-
j- / controllers.application.js
Last active May 27, 2016 05:18
New Twiddle
console.clear();
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
foo: false,
bar: false,
@j-
j- / controllers.application.js
Last active April 28, 2016 00:47
New Twiddle
console.clear();
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
const EXPECTED = Ember.computed(function (key) {
throw new Error(`Expected property "${key}" to be set`);
@j-
j- / controllers.application.js
Created April 12, 2016 06:13
ArrayObservers
console.clear();
import Em from 'ember';
export default Em.Controller.extend({
appName: 'Ember Twiddle',
arr: Em.computed(function () {
return Em.A();
}),
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['activity-indicator'],
ref: null,
refObserver: Ember.observer('ref', function () {
const $el = Ember.$(this.$());
$el.removeClass('activity');
@j-
j- / controllers.application.js
Last active March 30, 2016 22:36
ObjectProxy
import Em from 'ember';
const ModelController = Em.ObjectProxy.extend({
bar: Em.computed('content.bar', function () {
return this.get('content.bar').toLowerCase();
}),
foobar: Em.computed('foo', 'bar', function () {
return this.get('foo') + this.get('bar');
}),
import Em from 'ember';
console.clear();
export default Ember.Controller.extend({
foo: false,
bar: false,
fooAndBar: Em.computed.alias('foo') && Em.computed.alias('bar'),
@j-
j- / application.controller.js
Created March 17, 2016 05:18
notifyPropertyChange
console.clear();
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
prop: 'foobar',
obs: Em.observer('prop', function () {