Skip to content

Instantly share code, notes, and snippets.

View knownasilya's full-sized avatar
🦾
Working on Archegos

Ilya Radchenko knownasilya

🦾
Working on Archegos
View GitHub Profile
# This won't be live if bars is a hasMany relationship
foo.get 'bars'
# Instead do this and use the patch below to get a live array:
hasManyHack foo, 'bars'
# workaround for https://github.com/emberjs/data/issues/1308 -
# once the SSOT branch is merged this should be able to be replaced
@hodzanassredin
hodzanassredin / dokku_clean.sh
Created May 12, 2014 08:54
clean unused docker images wen recieving Error: create: no space left on device
docker images | grep '<none>' | awk '{print $3}' | xargs docker rmi
@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
@dandean
dandean / link.sh
Last active August 29, 2015 14:04
Link a module to itself to get around relative require hell.

urlTemplate Proposal

Summary

urlTemplate improves the extesibility of API endpoint urls in RESTAdapter.

Motivation

I think that Ember Data has a reputation for being hard to configure. I've often heard it recommended to design the server API around what Ember Data expects.

scrollTimeout: 100,
boundingClientRect: 0,
windowHeight: 0,
windowWidth: 0,
_updateBoundingClientRect: function() {
var el;
el = this.$()[0];
this.set('boundingClientRect', el.getBoundingClientRect());
},
@code0100fun
code0100fun / component_with_optional_block.handlebars
Created March 30, 2015 14:21
Ember component with optional block
<!-- app/templates/*.hbs -->
{{#if template}}
{{yield}}
{{else}}
{{defaultContent}}
{{/if}}
@knownasilya
knownasilya / boot2docker.md
Last active August 29, 2015 14:22
boot2docker

If behind a VPN (AnyConnect) do the following:

boot2docker down
vboxmanage modifyvm "boot2docker-vm" --natpf1 "docker,tcp,127.0.0.1,2376,,2376"
boot2docker up
export DOCKER_HOST=tcp://127.0.0.1:2376

To expose a port from boot2docker to host (osx):

@Floby
Floby / editor.js
Created April 19, 2011 09:18
open the default editor from node
var fs = require('fs');
var child_process = require('child_process');
var spawn = child_process.spawn;
function openEditor(file) {
var cp = spawn(process.env.EDITOR, [file], {
customFds: [
process.stdin,
process.stdout,
process.stderr