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
| function rmrf (fs, directory, callback) { | |
| fs.readdir(directory, function (err, list) { | |
| if (err) return callback(err); | |
| async.everySeries(list, function (item, callback) { | |
| var filename = path.join(directory, item); | |
| var stats = fs.stat(filename, function (err, stat) { | |
| if (err) return callback(err); | |
| if (filename === '.' || filename === '..') return callback(); | |
| if (stat.isDirectory()) return rmrf(fs, filename, callback); | |
| fs.unlink(filename, callback); |
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
| const createEmitter = () => { | |
| const handlersByEvent = new Map() | |
| const on = (event, handler) => { | |
| let handlers = handlersByEvent.get(event) | |
| if (!handlers) { | |
| handlers = [] | |
| handlersByEvent.set(event, handlers) | |
| } | |
| handlers.push(handler) |
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
| export const once = (func: Function): Function => { | |
| let called = false | |
| let cachedValue = undefined | |
| return (...args) => { | |
| if (!called) { | |
| cachedValue = func(...args) | |
| called = true | |
| } | |
| return cachedValue | |
| } |
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' | |
| const { Component } = Ember | |
| export default Component.extend({ | |
| // properties | |
| options: undefined, | |
| selectedOption: undefined, | |
| onChange: 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
| import Ember from 'ember' | |
| const { Component } = Ember | |
| export default Component.extend({ | |
| // props | |
| availableItems: undefined, | |
| selectedItem: undefined, | |
| onSelectItem: 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
| export const fetchAsBlob = url => fetch(url) | |
| .then(response => response.blob()); | |
| export const convertBlobToBase64 = blob => new Promise((resolve, reject) => { | |
| const reader = new FileReader; | |
| reader.onerror = reject; | |
| reader.onload = () => { | |
| resolve(reader.result); | |
| }; | |
| reader.readAsDataURL(blob); |
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
| <?php | |
| namespace App\Providers; | |
| use Illuminate\Support\Facades\Event; | |
| use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; | |
| class EventServiceProvider extends ServiceProvider | |
| { |
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({ | |
| appName: 'Ember Twiddle', | |
| actions: { | |
| foo() { | |
| alert('red box') | |
| }, | |
| bar(ev) { |
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({ | |
| appName: 'Ember Twiddle', | |
| model: { | |
| sumText: 'sum text', | |
| }, | |
| actions: { | |
| changed() { | |
| alert('onChange triggered') |
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 { HTTPFetchNetworkInterface, printAST } from 'apollo-client'; | |
| /** | |
| * Serialize a object to a query string | |
| * @source https://stackoverflow.com/questions/1714786/query-string-encoding-of-a-javascript-object#comment47677757_18116302 | |
| */ | |
| function serialize( obj ) { | |
| return `?` + Object.keys(obj).map(k => k + `=` + encodeURIComponent(obj[k])).join(`&`); | |
| } |