Skip to content

Instantly share code, notes, and snippets.

View knownasilya's full-sized avatar
🌒
And, behold, I come quickly; and my reward is with me.. Rev 22:12

Ilya Radchenko knownasilya

🌒
And, behold, I come quickly; and my reward is with me.. Rev 22:12
View GitHub Profile
@knownasilya
knownasilya / observer-throttled.js
Last active August 29, 2015 14:06
Ember observerThrottled
'use strict';
var Ember = require('ember');
module.exports = function () {
var args = argsToArray(arguments);
var argsLength = args.length;
var funcIndex, keys, throttled;
if (typeof args[argsLength - 2] === 'function') {
@knownasilya
knownasilya / index.js
Last active August 29, 2015 14:06
genertor memory leak
// Within writing in app generator
gulpTasks.forEach(function (task) {
this.invoke('emberate:gulp-task', {
args: [task]
});
}, this);
@knownasilya
knownasilya / dynamic-view.js
Last active August 29, 2015 14:06
Dynamic view binding helper for Ember.js
var DynamicView = Ember.ContainerView.extend(Ember._Metamorph, {
childViews: [],
viewChanged: function () {
var viewName = this.get('viewName');
var view = this.get(viewName) || this.container.lookup('view:' + viewName);
if (view) {
this.clear();
this.pushObject(view);
@knownasilya
knownasilya / user.js
Last active August 29, 2015 14:07
Ember User model - token authentication
'use strict';
var DS = require('ember-data');
var ajax = require('../helpers/ajax');
var attr = DS.attr;
var UserModel = DS.Model.extend({
email: attr('string'),
firstName: attr('string'),
lastName: attr('string'),
queryParams: [
{
borough: {
refreshModel: true
}
}, {
neighborhoods: {
refreshModel: true
}
}
var DynamicView = Ember.ContainerView.extend(Ember._Metamorph, {
childViews: [],
viewChanged: function () {
var viewName = this.get('viewName');
var view = this.container.lookup('view:' + viewName);
if (view) {
this.clear();
this.pushObject(view);
@knownasilya
knownasilya / data.json
Last active August 29, 2015 14:08
polymorphic
{
"user": {
"id": 44,
"profileType": "providerProfile",
"profile": 1
},
"profile": {
"id": 1,
"type": "providerProfile"
@knownasilya
knownasilya / info-window.js
Last active August 29, 2015 14:10
Google Maps InfoWindow with Emberjs
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['info-window-container'],
attachTo: function ($el) {
this.$().detach().appendTo($el);
}
});
@knownasilya
knownasilya / init-plugins.js
Last active August 29, 2015 14:11
ember plugins
var pluginIds = Ember.keys(this.container.registry.dict).filter(function (item) {
return item && item.indexOf('plugin:') === 0;
});
var containerView = Ember.ContainerView.create({
});
pluginIds.forEach(function (id) {
var factory = self.container.lookupFactory(id);
var view = factory.view.create();
@knownasilya
knownasilya / view.js
Created January 28, 2015 23:38
gmaps hack
// hack for GMAPS, since it doesn't provide an event object
// on didInsertElement
Ember.$(window).on('keydown', function (event) {
Ember.run(function () {
if (event.shiftKey) {
self.set('shiftDown', true);
}
Ember.$(window).one('keyup', function () {
Ember.run(function () {