Skip to content

Instantly share code, notes, and snippets.

View jamesarosen's full-sized avatar

James A Rosen jamesarosen

View GitHub Profile
@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 / react-state-machines.jsx
Created December 12, 2019 16:52
Using state machines in hook-based React components
const STATUSES = {
initial: {},
fetching: { showLoadingIndicator: true },
fetched: { showResults: true },
error: { showError: true },
}
function Foo() {
const [status, setStatus] = useState(STATUSES.initial)
const [results, setResults] = useState(null)
@jamesarosen
jamesarosen / 1.1.1.1.md
Created October 11, 2019 16:42
Does 1.1.1.1 resolve .org domains properly?

A friend asked me whether Cloudflare's 1.1.1.1 service was having trouble resolving .org domains. Here are some findings.

From SF:

dig zendesk.com
;; ANSWER SECTION:
zendesk.com.		3432	IN	A	54.172.126.223
zendesk.com.		3432	IN	A	34.206.241.1
zendesk.com.		3432	IN	A	34.225.199.37
require 'chronic'
require 'timecop'
module TemporalHelpers
# Travels to +time+ and lets the clock keep running.
#
# If a block is given, executes the block at that
# time then returns to the present.
def travel_to(time, &block)
@jamesarosen
jamesarosen / towards_a_better_rails_navigation_plugin.md
Created February 12, 2010 17:55
README for a proposed Rails navigation helper

Tired of building custom navigation code for each site?

Have you seen Ryan Heath's Navigation Helper? It's very usable, but it only does one nav-bar. I often have sites where there are many, e.g.

+-----------------------------------------------------------+
| MyApp                           | Home | Sign Out | FAQ | | # "site" nav bar
|===========================================================|
| | *Projects* | Friends |                                  | # "area" nav bar
|===========================================================|

| | Project Overview | Budget | History | | # "tabs" nav bar

@jamesarosen
jamesarosen / on-css.md
Last active November 13, 2018 15:47
On CSS

I don't have a Grand Vision for (S)CSS, but I do have some ideas.

Cohesion & Coupling

In JavaScript (and any other "programming language"), we value cohesion and eschew coupling. To value cohesion is to say that all of the foo-related things are in the Foo component or the app/pods/foo pod or the lib/foo addon. Like things are together. To eschew coupling is to say that two unrelated things should not need to know about one another. Unlike things don't rely on one another. Further reading on Cohesion & Coupling:

@jamesarosen
jamesarosen / 0-README.md
Created August 25, 2018 23:42
addon-mirage-supprot

The following code will let an ember addon provide an addon-test-support/ folder whose contents get merged into app/mirage/. It excludes addon-test-support/ from the build if mirage is disabled.

See Better Addon Support on the Ember CLI Mirage feature-request board.

@jamesarosen
jamesarosen / notes.md
Last active August 27, 2018 01:18
Quality Engineering
# an example Monit configuration file for delayed_job
#
# To use:
# 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc
# 2. replace {app_name} and {environment} as appropriate
# 3. add this to your /etc/monit/monitrc
#
# include /var/www/apps/{app_name}/shared/delayed_job.monitrc
check process delayed_job with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.pid
@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