The Ember router is getting number of enhancements that will greatly enhance its power, reliability, predictability, and ability to handle asynchronous loading logic (so many abilities), particularly when used in conjunction with promises, though the API is friendly enough that a deep understanding of promises is not required for the simpler use cases.
gifify() { | |
if [[ -n "$1" ]]; then | |
if [[ $2 == '--good' ]]; then | |
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png | |
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif | |
rm out-static*.png | |
else | |
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif | |
fi | |
else |
/** | |
Ember Data: Dependent Relationships | |
This package extends Ember Data to support creating relationships | |
where a model's dirty state depends not only on its own attributes | |
but on the dirty state of models in dependent relationships as well. | |
```javascript | |
App.Thing = DS.Model.extend({ | |
name : DS.attr('string'), |
<?php | |
class Custom_Hooks { | |
/** | |
* Adds a filter hook for an object | |
* | |
* Custom_Hooks::add_filter( 'filter_data', array( $this, 'filter_data' ) ); | |
* Custom_Hooks::add_filter( 'filter_data', array( $this, 'filter_data' ), 11 ); | |
* Custom_Hooks::add_filter( 'filter_data', 'special_func' ); | |
* Custom_Hooks::add_filter( 'filter_data', 'special_func', 11 ); |
From Meteor's documentation:
In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.
This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.
Sometimes we need to run async code in Meteor.methods
. For this we create a Future
to block until the async code has finished. This pattern can be seen all over Meteor's own codebase:
(function () { | |
// Implement debounce until backburner implements a proper debounce | |
var debouncees = [], | |
pop = Array.prototype.pop; | |
var debounce = function (target, method /*, args, wait */) { | |
var self = Ember.run.backburner, | |
args = arguments, | |
wait = pop.call(args), |
var empty, get, set, | |
__hasProp = {}.hasOwnProperty; | |
get = Ember.get; | |
set = Ember.set; | |
empty = function(obj) { | |
var key; | |
for (key in obj) { | |
if (!__hasProp.call(obj, key)) continue; |
App.Router.map(function() { | |
this.resource('post', { path: '/posts/:post_id' }); | |
}); | |
App.PostRoute = Ember.Route.extend({ | |
model: function(params) { | |
return this.store.find('post', params.post_id); | |
} | |
}); |
There are several types of relationships.
- OneToMany
- OneToOne
- OneToNone
- ManyToNone
A OneToMany relationship has a Set of members and a link to the belongsTo. Each member and the belongsTo has a link back to the relationship. The member links can change.
A ManyToNone relationship has a Set of members and a link to the belongsTo. The belongsTo has a link back to the relationship. The link doesn't change.
/** | |
* Pauses the underlying observable sequence based upon the observable sequence which yields true/false. | |
* @example | |
* var pauser = new Rx.Subject(); | |
* var source = Rx.Observable.interval(100).pausable(pauser); | |
* @param {Observable} pauser The observable sequence used to pause the underlying sequence. | |
* @returns {Observable} The observable sequence which is paused based upon the pauser. | |
*/ | |
observableProto.pausable = function (pauser) { | |
var self = this; |