Skip to content

Instantly share code, notes, and snippets.

Sean McCleary mrinterweb

  • InQuicker
  • Portland, Oregon
View GitHub Profile
View docker-sync.yml
version: "2"
options:
verbose: true
syncs:
rails-app-sync:
compose-dev-file-path: 'docker-compose-dev.yml'
notify_terminal: false
src: './'
sync_strategy: 'native_osx'
sync_host_ip: '127.0.0.1'
View Hyundai.rb
# 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|
View gist:25eac01663309741240c45d18a0a3026
#! /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'
@mrinterweb
mrinterweb / actions.js
Created Oct 2, 2017
A basic jsonapi serializer
View actions.js
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);
};
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View extend-session.js
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() {
View session.js
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
View inline-web-worker.js
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');
View friend.coffee
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)
View rollbar-transform.js
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]}`;
You can’t perform that action at this time.