Skip to content

Instantly share code, notes, and snippets.

View mixonic's full-sized avatar

Matthew Beale mixonic

View GitHub Profile
@mixonic
mixonic / buffered-store-proxy.md
Created July 2, 2014 16:06
Buffered Store Proxy

If you have worked much with Ember-Data, then you know the buffered object proxy pattern:

http://coryforsyth.com/2013/06/27/ember-buffered-proxy-and-method-missing/

This pattern allows us to put changes to a model into a buffer instead of on the model itself. There are several benefits of this:

  • If the model has changes come from a push source (an attribute is updated), the changes will not destroy what the user is currently entering.
  • Saves can be de-coupled from dirty tracking. If you are saving a model as a user types, the model in flight will not accept changes from the user. You will get the dreaded cannot change an object inFlight error. With a buffer, you can commit the buffer to the model and save the model, then allow the user to keep making edits against a new buffer. No conflict.
  • In general, a buffer allows you to treat Ember-Data records more like database rows. You lock them for modification (while persisting them) but only for the shortest time possible. An object is made dirty then sav
@mixonic
mixonic / dependency-injection-and-service-lookup.md
Last active August 29, 2015 14:03
Dependency Injection & Service Lookup

Dependency Inject & Service Lookup

Dependency injection and service lookup are two important framework concepts. The first, dependency injection, refers a dependent object being injected onto another object during instantiation. For example, all route objects have the property router set on them during instantiation. We say that the dependency of the router has been injected onto the route objects.

App.IndexRoute = Ember.Route.extend({
  actions: {
    showPath: function(){
      // Dependency injection provides the router object to our
      // route instance.

Pass at marketing copy

An authorization service library for your Ember.js application. <- Cory and I really like this as a tagline.

Torii is an authorization abstraction for Ember.js applications.

Adding social login to your Ember.js app just got a whole lot simpler.

Need an OAuth 2 authorization code? Let us do the heavy lifting.

@mixonic
mixonic / keybase.md
Last active August 29, 2015 14:02
keybase.md

Keybase proof

I hereby claim:

  • I am mixonic on github.
  • I am mixonic (https://keybase.io/mixonic) on keybase.
  • I have a public key whose fingerprint is C34B 0092 AF17 0AFC 9F22 3F5D 8FCD 4AB5 1F37 1A5E

To claim this, I am signing this object:

@mixonic
mixonic / vcr_proxy.js
Last active January 1, 2016 00:59
Ember.js VCRProxy
// Record changes to an ObjectProxy and allow them to be stepped through
// or jumped to.
//
// For an example, see http://emberjs.jsbin.com/EJEcoxO/12/edit?html,js,output
//
// There is a bower/npm installable version of this library on GitHub:
// https://github.com/mixonic/ember-vcr-proxy
//
(function (global) {
test("it slices the array", function() {
expect(7);
deepEqual(get(obj, 'sliced'), [1, 2]);
Ember.run(function() {
// [0, 1, 2, 3, 4, 5]
obj.get('array').insertAt(0, 0);
});
// Ember.computed.slice managing the array
Ember.computed.slice = function(dependentKey, begin, end) {
var size = end - begin,
slicedIndex;
var options = {
addedItem: function(array, item, changeMeta, instanceMeta) {
slicedIndex = changeMeta.index - begin;
if (slicedIndex >= 0 && slicedIndex < size) {
if (slicedIndex >= array.length) {
array.push(item);
@mixonic
mixonic / template.html
Last active December 21, 2015 03:59 — forked from bricker/template.html
<script type="text/x-handlebars" id="articles">
{{#each controller itemController="article"}}
<figure class="img-wrapper" {{bindAttr style="imgWrapperStyle"}}>
</figure>
{{/each}}
</script>
/*
Copyright (C) 2011 by Yehuda Katz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
diff --git a/packages/list-view/lib/list_view_mixin.js b/packages/list-view/lib/list_view_mixin.js
index 2148cf9..6b8bb74 100644
--- a/packages/list-view/lib/list_view_mixin.js
+++ b/packages/list-view/lib/list_view_mixin.js
@@ -214,6 +214,10 @@ Ember.ListViewMixin = Ember.Mixin.create({
endingIndex = min(maxContentIndex, visibleEndingIndex);
this.trigger('scrollYChanged', y);
+ console.log('start');
+ var el = this.$('.ember-list-scrolling-view')