This file contains hidden or 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
| package main | |
| import ( | |
| "fmt" | |
| "sync" | |
| "time" | |
| ) | |
| func process(item string, index int, wg *sync.WaitGroup) { | |
| fmt.Printf("Hitting endpoint #%d: %+v\n", index, item) |
This file contains hidden or 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.Controller.extend({ | |
| actionRunId: null, // This property stores the task id for our action | |
| timerRunId: null, // this property stores the task id for the auto-updating of the timer | |
| currentWaitTime: 0, // The timer (how many seconds are left until the action is executed) | |
| waitTime: 5, // The delay (in seconds) during which you can cancel an action | |
| cancelable: false, // Is there an action to cancel ? | |
| cancelMessage: null, // The message to display to the user |
This file contains hidden or 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
| { | |
| "posts":[ | |
| { | |
| "id":1, | |
| "title":"first-post" | |
| }, | |
| { | |
| "id":2, | |
| "title":"second-post" | |
| } |
This file contains hidden or 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.Route.extend({ | |
| // Here, we're telling ember to "watch" the query parameter "page". | |
| // In this case, if the parameter changes, the model will be fetched again. | |
| // We could map the parameter to a different property name if we wanted. | |
| queryParams: { | |
| page: { | |
| refreshModel: true | |
| } |
This file contains hidden or 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.Route.extend({ | |
| model: function() { | |
| return this.get('store').find('post')); | |
| }, | |
| setupController: function(controller, model) { | |
| this._super.apply(this, arguments); // Do not forget this call | |
| controller.set('totalPages', model.get('meta.totalPages')); |
This file contains hidden or 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
| Ember.get({foo: {bar: 'hello'}}, 'foo.bar') | |
| // <- "hello" | |
| Ember.get({foo: {bar: 'hello'}}, 'nonexistent') | |
| // <- undefined |
This file contains hidden or 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 a = null; | |
| var b; // undefined | |
| a.get('myprop') | |
| // Uncaught TypeError: Cannot read property 'get' of null | |
| Ember.get(a, 'myprop'); | |
| // <- undefined | |
| Ember.get(b, 'myprop'); |
This file contains hidden or 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
| // Do not do this | |
| var SomeController = Ember.ArrayController.extend({ | |
| init: function() { | |
| this._super.apply(this, arguments) // easy to forget, can introduce typos, etc | |
| // your code here | |
| } | |
| }); | |
| // Do this |
This file contains hidden or 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
| window.navigator.language // -> "fr" | |
| window.navigator.languages // -> ["fr-FR", "fr", "en-US", "en", "es", "de"] | |
| window.navigator.userLanguage // -> undefined | |
| window.navigator.browserLanguage // -> undefined | |
| window.navigator.systemLanguage // -> undefined |
This file contains hidden or 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 langage = (navigator.language || navigator.browserLanguage).split('-')[0]; |