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
| # This is a ActiveRecord STI class | |
| class Hyundai < Car | |
| has_one :hyundai_details | |
| delegate *HyundaiDetails::ACCESSIBLE_ACCESSOR_METHODS, to: :hyundai_details | |
| default_scope { includes(:hyundai_details) } | |
| def initialize(args = {}) | |
| hyundai_details_attrs = {} | |
| args.each do |key, _val| |
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
| #! /usr/bin/env ruby | |
| # Switch to git branch by matching part of a name | |
| results = `git branch -l | grep -i #{ARGV[0]} | cut -f 1` | |
| branchNames = results.split("\n").map { |bn| bn.sub(/^\*/, '').strip } | |
| if branchNames.length == 1 | |
| `git checkout #{branchNames.first}` | |
| else | |
| puts 'More than one branch name matched' |
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 _ from 'lodash'; | |
| export default { | |
| UPDATE_RATES({ commit }, results) { | |
| if (results.data && results.data.length === 0) { | |
| commit('UPDATE_RATES', []); | |
| } else { | |
| let mapAtributes = function(_val, key) { | |
| return _.camelCase(key); | |
| }; |
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' | |
| }); |
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 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 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'; | |
| 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 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 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 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
| 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 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
| 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 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
| find . -iregex "\(.*\)\.js\.coffee$" -print | xargs ruby -e 'ARGV.each { |fn| `git mv #{fn} #{fn.sub(".js.", ".")}` }' |