Skip to content

Instantly share code, notes, and snippets.

James James1x0

Block or report user

Report or block James1x0

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View components.x-test.js
import Ember from 'ember';
export default Ember.Component.extend({
updates: Ember.A(),
didReceiveAttrs () {
this._super(...arguments);
this.get('updates').pushObject('didReceiveAttrs ' + new Date());
},
View test.log
✓ should POST new records
mocha:runner run suite Acceptance :: Resource :: Payment Method GET /payment-methods/:id +1ms
GET /payment-methods/:id
koa:application use responseTime +0ms
koa:application use compress +0ms
koa:application use bodyParser +0ms
koa:application use - +0ms
koa:application use dispatch +0ms
koa:application use - +0ms
debug: routes: bt
View gist:0c6e82dd91c542f9b5cd82554a9067e7

Each config gets called with:

  var mod = require(conf.directory);

  if ( conf.crud ) {
    methodMixins(mod, conf);
  }

  app.use(mount('/api/v1', Resource(conf.name, mod).middleware()));
@James1x0
James1x0 / run-along.js
Last active Jan 11, 2016
Neat little random array generator I came up with for a thought experiment.
View run-along.js
function runAlongFolks ( init, iter, deviation ) {
var n = init || 150,
arr = [];
for ( var i = 0; i < iter; i++ ) {
var a = Math.floor(Math.random() * (deviation - (-deviation) + 1)) - deviation;
arr.push(n);
n += a;
}
@James1x0
James1x0 / indexof.hbs
Created Jan 5, 2015
Index from itemController
View indexof.hbs
{{#each foo in content}}
foo{{foo.fooIndexComputed}}
{{#each bar in foo.bar}}
bar{{bar.barIndexComputed}} of foo{{foo.fooIndexComputed}}
{{/each}}
{{/each}}
<!--
foo0
bar0 of foo0
bar1 of foo0
View Minimalistic-CSS-Loader.markdown

Minimalistic CSS Loader

Fairly minimalistic loader in pure css. Everything is pretty much customizable; check the less var source.

A Pen by James on CodePen.

License.

@James1x0
James1x0 / nested-routes.js
Created Nov 5, 2014
Nested route behavior w/o view nesting
View nested-routes.js
// router.js
Router.map(function () {
this.resource('employee', { path: 'employees/:id' }, function () {
this.route('index', { path: '/' });
this.route('edit');
});
this.resource('employee.dependent', { path: 'employees/:employeeid/dependents/:dependentid' }, function () {
this.route('index', { path: '/' });
this.route('edit');
View computed-draw-call.js
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement: function () {
this._draw();
},
dataset: function () {
// Calulate dataset
return dataset;
@James1x0
James1x0 / w.js
Created Aug 28, 2014
Window prop
View w.js
export default Ember.View.extend({
didInsertElement: function () {
this.$().on('scroll', { emEl: this }, this._updatePosition);
},
_updatePosition: function ( ev ) {
Ember.run.throttle(ev.data.emEl, function () {
this.set('scrollY', ev.currentTarget.scrollY);
}, 250);
}
@James1x0
James1x0 / json-to-html.js
Created Aug 20, 2014
JSON To HTML table
View json-to-html.js
/*
Quick and dirty JSON to HTML table parser
---
Designed for use debugging in node.js
*/
function jsonToHtml ( json, limit ) {
var data = json,
dataKeys = [];
You can’t perform that action at this time.