Skip to content

Instantly share code, notes, and snippets.

View James1x0's full-sized avatar
Building

James James1x0

Building
View GitHub Profile
@James1x0
James1x0 / unokata.js
Created April 22, 2022 18:24
I play next on a reverse in uno, change my mind
let currentTurn = 3;
const players = [
'you',
'someone',
'me'
];
function logCurrentPlayer () {
return players[(currentTurn % players.length) - 1];
}
@James1x0
James1x0 / components.x-test.js
Created December 15, 2016 22:20
updateattrs?
import Ember from 'ember';
export default Ember.Component.extend({
updates: Ember.A(),
didReceiveAttrs () {
this._super(...arguments);
this.get('updates').pushObject('didReceiveAttrs ' + new Date());
},
✓ 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

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 January 11, 2016 18:31
Neat little random array generator I came up with for a thought experiment.
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 January 5, 2015 21:29
Index from itemController
{{#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
@James1x0
James1x0 / Minimalistic-CSS-Loader.markdown
Created November 20, 2014 20:30
Minimalistic CSS Loader

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 November 5, 2014 20:19
Nested route behavior w/o view nesting
// 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');
@James1x0
James1x0 / computed-draw-call.js
Created October 9, 2014 16:17
Computed draw call
import Ember from 'ember';
export default Ember.Component.extend({
didInsertElement: function () {
this._draw();
},
dataset: function () {
// Calulate dataset
return dataset;
@James1x0
James1x0 / w.js
Created August 28, 2014 16:04
Window prop
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);
}