Skip to content

Instantly share code, notes, and snippets.

View jamesarosen's full-sized avatar

James A Rosen jamesarosen

View GitHub Profile
@jamesarosen
jamesarosen / components.fui-truncate.js
Last active February 16, 2018 20:05
inner-truncate
import Ember from 'ember'
import hbs from 'htmlbars-inline-precompile'
export default Ember.Component.extend({
suffixLength: 4,
text: null,
prefix: Ember.computed('suffixLength', 'text', function() {
const suffixLength = this.get('suffixLength')
const text = this.get('text') || ''
@jamesarosen
jamesarosen / components.click-me.js
Created February 8, 2018 18:19
action-bubbling
import Ember from 'ember'
import hbs from 'htmlbars-inline-precompile'
export default Ember.Component.extend({
// The key is the argument to `sendAction`, below.
// The value is the name of the action that bubbles up. In this case,
// it matches something in controller:application.
clickMe: 'clickMeWasClicked',
layout: hbs`
@jamesarosen
jamesarosen / has-zero-or-one.md
Last active December 21, 2019 19:33
Ember-Data: hasZeroOrOne

Background

In our app, we have a number of different has-zero-or-one relationships where the foreign object may or may not exist. For example, a Customer may or may not have a CreditCard on file, but it won't have more than one.

We started with something like

// app/models/customer.js
export default DS.Model.extend({
@jamesarosen
jamesarosen / grill-rub.md
Last active June 7, 2017 03:53
James' Grill Rub

Sprinkle on salmon, chicken wings, roast root vegetables, popcorn, or whatever.

It's salt-free. I prefer to salt each dish individually.

The quantities below make just under 1/2 C. I use this most times I cook. If you're worried about not using it all within about 6 months, halve the recipe.

@jamesarosen
jamesarosen / healthcare.md
Last active May 13, 2017 15:56
Rambling thoughts on healthcare in America

Background

My friend and I were debating healthcare on Facebook. He recommended I watch this video by Stefan Molyneaux, which I did. My response was too long for Facebook and I don't have a better spot to put it, so I'm posting it here.

Summary

  • Government is a useful tool against abuses by those in power (including corporations, other parts of the government, and terrorists).
  • I absolutely agree with Molyneaux that we need to unbundle healthcare from employment. This is an unfair legacy system that gives employers too much power, employees too little flexibility, and spreads the benfit too thinly.
  • I like Molyneaux's "predictability vs cost" quandrant setup. This is a useful tool in evaluating policy options.
@jamesarosen
jamesarosen / keybase.md
Created February 1, 2017 00:30
Keybase Verification

Keybase proof

I hereby claim:

  • I am jamesarosen on github.
  • I am jamesarosen (https://keybase.io/jamesarosen) on keybase.
  • I have a public key ASCZBlGPvvF0orADOvinQs3X0aKHdjT3Jl-j9CdJdpikCwo

To claim this, I am signing this object:

@jamesarosen
jamesarosen / controllers.application.js
Last active December 19, 2016 20:05
SerializeQueryParams
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
queryParams: [ 'q' ],
q: 'defaultValue'
});
@jamesarosen
jamesarosen / controllers.application.js
Created December 14, 2016 00:12
tether-dialog-constraints
import Ember from 'ember';
export default Ember.Controller.extend();
@jamesarosen
jamesarosen / git-changes-histogram.rb
Created December 13, 2016 21:47
Generate a histogram of line changes (insertions + deletions) from a GitHub repo, bucketed by week
require 'time'
class Commit
DATE = /^Date: +(\w{3} \w{3} \d{1,2}.+)$/
MERGE = /^Merge: +([a-z0-9]+) ([a-z0-9]+)$/
CHANGES = /^ *\d+ files? changed(?:, (\d+) insertions?...)?(?:, (\d+) deletions?...)? *$/
attr_reader :sha
def self.sha_for(pointer)
@jamesarosen
jamesarosen / list-prs-by-time-open.js
Created December 13, 2016 21:45
List Top N closed/merged pull requests for a GitHub repository, ordered by number of days open
const RSVP = require('rsvp');
const moment = require('moment');
const GITHUB_API_TOKEN = process.env.GITHUB_API_TOKEN;
const GITHUB_USER = process.env.GITHUB_USER;
const GITHUB_REPO = process.env.GITHUB_REPO;
const TOP_N = 30;
fetchAllPRs();
function fetchAllPRs() {