Skip to content

Instantly share code, notes, and snippets.

Avatar

matteddy

View GitHub Profile
View rules.txt
House manual
Everything you'll need is on our website. Check your Airbnb inbox for the link.
House rules
We love hosting, and we want you to have the best possible experience here. To that end, it's critical that every adult in your party reads and acknowledges these house rules.
More information
Don't even think of throwing a party here. If your plans include keg stands, beer pong, Jackass stunts or any other Animal House fantasies, please keep looking. You'll get evicted, annoy our neighbors, and forfeit your deposit We promise, it will suck for everyone.
Check-in time is 4:00. Check-out time is noon. By absolute necessity, we cannot accommodate requests for early check-ins or late check-outs.
View components.form-for-input.js
import Ember from 'ember';
export default Ember.Component.extend({
trump: Ember.computed('model.firstName', function() {
return this.get('model.firstName') == "Donald";
})
});
View controllers.application.js
import Ember from 'ember';
import { task, timeout } from 'ember-concurrency';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
save: task(function*() {
yield timeout(1000);
alert("cats");
})
});
@matteddy
matteddy / gist:a9ae28570e2265d1c713
Last active Oct 30, 2015
Correctly Handling Hover Events
View gist:a9ae28570e2265d1c713

So I'm having trouble appropriately handling mouseEnter and mouseLeave events in the star-rating component. The goal was to emulate a hover by tracking when things enter and leave the element.

The problem is that a mouseEnter event is getting triggered again before the mouseLeave. An example of this can be seen (here)[http://i.imgur.com/3PdPvD3.gif].

This manifests as multiple mouse enters for every mouse leave, which ends up leaving the component in a state inconsistent with the models.

http://stackoverflow.com/questions/9673191/jquery-mouseout-not-triggering-if-mouse-is-moved-out-too-fast ^This post seems similar to my question and then handle things by doing

$("body").on('mouseenter', 'some-element', function() {
View first env example
// config/environment.js
module.exports = function(environment) {
var ENV = {
torii: {
providers: {
'some-oauth2': {
apiKey: 'SOME_SORTA_KEY',
redirectUri: 'http://localhost:4200/api/session'
}
View some-oauth2.js
\\ app/torii-adapters/some-oauth2.js
export default Ember.Object.extend({
close() {
return new Ember.RSVP.Promise(function(resolve, reject) {
resolve(localStorage.setItem('token', null))
})
}
})
View some-oauth2.js
\\ app/torii-adapters/some-oauth2.js
export default Ember.Object.extend({
fetch() {
return new Ember.RSVP.Promise(function(resolve, reject) {
if(!!localStorage.getItem('token')) {
return resolve({token: localStorage.getItem('token')});
} else {
return reject();
}
View some-oauth2.js
\\ app/torii-adapters/some-oauth2.js
export default Ember.Object.extend({
fetch() {
var storage = this.get('storage');
return new Ember.RSVP.Promise(function(resolve, reject) {
if(storage.exists('token')) {
return resolve(storage.fetch('token', 'name'));
} else {
View some-oauth2.js
fetch() {
var storage = this.get('storage');
return new Ember.RSVP.Promise(function(resolve, reject) {
if(storage.exists('token')) {
return resolve(storage.fetch('token', 'name'));
} else {
return reject();
}
});
View some-oauth2.js
\\ app/torii-adapters/some-oauth2.js
export default Ember.Object.extend({
open(authorizationGrant) {
return new Ember.RSVP.Promise(function(resolve, reject) {
// part 1
Ember.$.ajax({
url: 'api/session',
data: { 'some-oauth2-code': authorizationGrant },
dataType: 'json'