This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Refer: http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delaying_only_some_traffic | |
#Refer: http://www.bomisofmab.com/blog/?p=100 | |
#Refer: http://drija.com/linux/41983/simulating-a-low-bandwidth-high-latency-network-connection-on-linux/ | |
#Setup the rate control and delay | |
sudo tc qdisc add dev lo root handle 1: htb default 12 | |
sudo tc class add dev lo parent 1:1 classid 1:12 htb rate 56kbps ceil 128kbps | |
sudo tc qdisc add dev lo parent 1:12 netem delay 200ms | |
#Remove the rate control/delay | |
sudo tc qdisc del dev lo root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
speechSynthesis.getVoices().forEach(function(voice) { | |
var name = voice.name, | |
speech = new SpeechSynthesisUtterance("Hello, my name is " + name); | |
speech.voice = voice; | |
speechSynthesis.speak(speech); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ideally you would set up a flash message service as a dependency injection | |
// (which can be a little involved), but here's a quick hack | |
// P.S. this was transpiled down from CoffeeScript, so it might look a bit funky | |
App.Post = DS.Model.extend({ | |
errorMessages: Em.A([]), | |
didBecomeDirty: Em.observer('isDirty', function() { | |
return Em.run.debounce(this, '_handleSave', 500, true); | |
}), | |
_handleSave: function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var computed; | |
App.computed = {}; | |
computed = Ember.computed; | |
App.computed.sample = function(dependentKey) { | |
return (computed("" + dependentKey + ".@each", function() { | |
var items, length; | |
items = this.getWithDefault(dependentKey, Em.A([])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['range-slider'], | |
value: 0, | |
attributeBindings: ['data-slider'], | |
'data-slider': 0, | |
valueDidChange: Em.observer('value', function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Mixin.create({ | |
scrollTimeout: 100, | |
boundingClientRect: 0, | |
windowHeight: 0, | |
windowWidth: 0, | |
enteredViewport: Ember.computed('boundingClientRect', 'windowHeight', 'windowWidth', function() { | |
var rect, windowHeight, windowWidth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scrollTimeout: 100, | |
boundingClientRect: 0, | |
windowHeight: 0, | |
windowWidth: 0, | |
_updateBoundingClientRect: function() { | |
var el; | |
el = this.$()[0]; | |
this.set('boundingClientRect', el.getBoundingClientRect()); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_scrollHandler: function() { | |
return Ember.run.debounce(this, '_updateBoundingClientRect', this.get('scrollTimeout')); | |
}, | |
_bindScroll: (function() { | |
var scrollHandler; | |
scrollHandler = this._scrollHandler.bind(this); | |
Ember.$(document).on('touchmove.scrollable', scrollHandler); | |
Ember.$(window).on('scroll.scrollable', scrollHandler); | |
}).on('didInsertElement'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enteredViewport: Ember.computed('boundingClientRect', 'windowHeight', 'windowWidth', function() { | |
var rect, windowHeight, windowWidth; | |
rect = this.get('boundingClientRect'); | |
windowHeight = this.get('windowHeight'); | |
windowWidth = this.get('windowWidth'); | |
return ( | |
rect.top >= 0 && | |
rect.left >= 0 && | |
rect.bottom <= windowHeight && | |
rect.right <= windowWidth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
var { | |
computed, | |
get, | |
set, | |
getWithDefault, | |
run | |
} = Ember; |
OlderNewer