Skip to content

Instantly share code, notes, and snippets.

View taras's full-sized avatar

Taras Mankovski taras

View GitHub Profile
@machty
machty / router-facelift-guide.md
Last active November 11, 2023 06:44
Guide to the Router Facelift

Ember Router Async Facelift

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.

@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
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
@slindberg
slindberg / ember-data.dependent-relations.js
Last active November 5, 2021 21:41
Dependent Relationships in Ember Data
/**
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'),
@mikeschinkel
mikeschinkel / class-custom-hooks.php
Last active June 17, 2021 04:42
Classes providing "hooks" (actions and filters) that work with WordPress or free-standing PHP-based apps.
<?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 );
@possibilities
possibilities / meteor-async.md
Created August 23, 2012 22:53
Meteor Async Guide

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.

Basic async

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:

@tim-evans
tim-evans / autosave.js
Created June 14, 2013 16:03
Autosave pattern for Ember with Ember Data
(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),
@lukemelia
lukemelia / buffered_proxy.js
Last active May 5, 2016 20:47
Buffered Proxy, extracted from Yapp codebase
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;
@wycats
wycats / app.js
Last active February 11, 2016 16:08
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.

@mattpodwysocki
mattpodwysocki / pausable.js
Last active December 31, 2015 04:49
Pause/resume semantics on an Observable.
/**
* 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;