Skip to content

Instantly share code, notes, and snippets.

@jamesarosen
jamesarosen / application_serializer.js
Created March 4, 2015 06:38
It's hard to test this Ember-Data Serializer
import DS from "ember-data";
function ensureRoot(rootName, payload) {
var result;
if (payload[rootName] == null) {
result = {};
result[rootName] = payload;
} else {
result = payload;
@jamesarosen
jamesarosen / ideas.md
Created March 4, 2015 00:22
Ideas for testing Ember apps & add-ons against multiple versions of libraries

package.json

Use a custom key in package.json:

alternateDependencies: [
  { "ember": "1.8.1" },
  {
    "ember": "1.12.0-beta",
 "handlebars": false,
@jamesarosen
jamesarosen / ux-skills.md
Last active June 6, 2018 10:02
UX Engineer Skill List

Off the top of my head, a UX team needs to collectively have the following talents. No one person will know all of these, nor would I expect someone who is learning something in the Advanced category to have fully mastered everything above. Paths vary.

Prerequisites

  • Writing and rhetoric, including constructing a thesis, providing supporting evidence, and tailoring your delivery to your audience

Intro

Enough to poke at things and learn more

  • Visual page construction
  • HTML
@jamesarosen
jamesarosen / 01-intro.md
Last active May 24, 2018 08:44
Ember-CLI + Ember-Data + Custom API

I had some trouble getting Ember-CLI and Ember-Data working with my existing HTTP API. These are the things I had to do to get it working:

Use ActiveModelSerializer by default

My API returns underscored_keys, not camelizedKeys. It's not exactly the standard ActiveModel, but it's quite similar. I started by defining a default (application) serializer that's a simple subclass of DS.ActiveModelSerializer:

// app/serializers/application.js
import DS from "ember-data";
@jamesarosen
jamesarosen / git-merge-button.md
Created October 10, 2014 23:20
GitHub's Merge Button™ from the command line

I love GitHub's Merge Button™... except that it creates a commit with my personal email address even on my work projects. (Or, conversely, that is uses my work email on my personal projects.)

My solution is to create a git-merge-button and add it to my path:

#!/bin/bash

if [ $# -ne 2 ]; then
  echo "Usage: git merge-and-clean-up [branch-name] [pull number]"
 exit 1
@jamesarosen
jamesarosen / comcast.md
Last active August 29, 2015 14:03
Why I Hate Comcast: A Story of Customer Disservice

I just signed another year lease on my apartment, so I figured if I have another year here, I might as well try to improve my Internet service and/or price. I really dislike how my current provider, Comcast, is opposing Net Neutrality, so I looked around for altneratives. Nope, still just Comcast and AT&T. Monopolies :(

So I went to comcast.com. Ooh, neat! They have a promotion on Internet that would cut my rate way down. I signed in. "This is a business address. For business service, call us or enter another address." I clicked "enter another address," hoping they just had my address wrong. That link takes me back to ""This is a business address. For business service, call us or enter another address." So much for a usable website.

OK, fine, I'll call. After a couple minutes of playing verbal and key-based phone tree, I get a very nice customer service agent. I ask him what plans are available in my region. He looks for a minute and says, "We have a promotion to add voice, give you the same Internet servic

@jamesarosen
jamesarosen / volary.md
Created April 9, 2014 01:52
Installing Multiple Sets of Bower Dependencies

Overview

Ember-I18n declares the following dependencies:

"cldr":       "^1.0",
"jquery":     ">=1.7 <3",
"handlebars": "^1.0",
"ember":      ">0.9.7 <2"
@jamesarosen
jamesarosen / overriding.md
Created January 24, 2014 17:41
Overriding observed functions in Ember 1

What is the expected behavior of the following code?

var Superclass = Ember.Object.extend({
  logOnInit: function() {
    console.log('Superclass#logOnInit');
  }.on('init')
});

var Subclass = Superclass.extend({
@jamesarosen
jamesarosen / volatile_dependent.md
Created January 22, 2014 22:39
Ember 1 and volatile properties with dependent keys

In Ember 0.9, we had properties that looked like

age: function() {
  return this.get('createdAt') - new Date();
}.property('createdAt').volatile()

The .property('createdAt') means, "recompute this every time createdAt changes".

@jamesarosen
jamesarosen / shovel_out.rb
Created August 5, 2013 02:30
Shovel Out, Elixir-Inspired Irresponsible Programming in Ruby
Object.class_eval do
def >>(callable = nil, &block)
raise ArgumentError.new('>> takes a callable or block') unless callable.nil? ^ block.nil?
(callable || block).call self
end
end
Enumerable.class_eval do
def >>(callable = nil, &block)
raise ArgumentError.new('>> takes a callable or block') unless callable.nil? ^ block.nil?