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 function initialize(appInstance) { | |
appInstance.lookup('service:session').reopen({ | |
isAdmin: Ember.computed('jwt', function() { | |
const isAdmin = this.get('jwt.is_admin'); | |
return (typeof isAdmin === 'boolean') ? isAdmin : false; | |
}), | |
jwt: Ember.computed('data.authenticated.access_token', 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'; | |
import SessionService from 'ember-simple-auth/services/session'; | |
export default SessionService.reopen({ | |
jwt: {}, | |
// my problem is with this computed property. It is defined as a computed property, | |
// but when accessed, it is always undefined | |
isAdmin: Ember.computed('jwt', function() { | |
debugger; // this line is never hit |
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 foo = function(e) { | |
console.log('message in worker: ' + e.data); | |
}; | |
var blob = new Blob(['var onmessage = ' + foo.toString()], { type: 'text/javascript' }); | |
document.worker = new Worker(window.URL.createObjectURL(blob)); | |
document.worker.postMessage('Howdy'); |
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
Friend = DS.Model.extend Cacheable, | |
avatar_url: DS.attr() | |
cachableAvatarImage: Em.computed 'avatar_url', -> | |
id = @get('id') | |
lfKey = "user-avatar-#{id}" | |
avatarUrl = @get('avatar_url') | |
showAsBlob = false | |
ObjectPromiseProxy = Ember.ObjectProxy.extend(Ember.PromiseProxyMixin) |
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
Rollbar.configure({ | |
transform: function(payload) { | |
let trace = payload.data.body.trace; | |
if (trace && trace.frames) { | |
for (let frame of trace.frames) { | |
let filename = frame.filename; | |
if (filename) { | |
let matches = filename.match(/^(.*\/)((dfw|vendor)(-[a-z0-9]{16,})?\.js)$/i); | |
if (matches && matches[2]) { | |
frame.filename = `https://PLATFORM/${matches[2]}`; |
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
find . -iregex "\(.*\)\.js\.coffee$" -print | xargs ruby -e 'ARGV.each { |fn| `git mv #{fn} #{fn.sub(".js.", ".")}` }' |
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
Calculating ------------------------------------- | |
select + include 30.000 i/100ms | |
sort + select + bsearch | |
138.000 i/100ms | |
presorted: select + bsearch | |
207.000 i/100ms | |
------------------------------------------------- | |
select + include 306.578 (± 4.9%) i/s - 1.530k | |
sort + select + bsearch | |
1.387k (± 5.1%) i/s - 7.038k |
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
App.Cache = Em.Object.extend | |
init: -> | |
@store = App.__container__.lookup('store:main') | |
# tries to load the results from localforage cache or from normal adapter | |
findAll: -> | |
localforage.getItem(@modelStr).then (cacheItems)=> | |
if Em.isEmpty(cacheItems) | |
@findAndCache() | |
else |
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
App.FriendCache = Em.Object.extend | |
init: -> | |
@store = App.__container__.lookup('store:main') | |
findAll: -> | |
localforage.getItem('friends').then (cfriends)=> | |
if Em.isEmpty(cfriends) | |
@findAndCache() | |
else | |
allFriends = @store.all('friend') |
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
App.ApplicationAdapter = DS.ActiveModelAdapter.extend | |
namespace: 'api/v1' | |
host: App.BaseUrl | |
setHeaders: (-> | |
console.log "setting headers", @get('currentSession.token') | |
@set('headers', | |
token: @get('currentSession.token') | |
Accept: 'application/json' | |
) | |
).observes('currentSession.token').on('init') |