Skip to content

Instantly share code, notes, and snippets.

@jamesarosen
jamesarosen / sproutcore-notes.md
Created July 1, 2016 06:07
Some notes I just found on SproutCore

After my recent move, I've been sorting through old papers. I just found this page of notes I had prepared before meeting @wycats and @tomdale for lunch to discuss SproutCore vs Backbone. It's undated, but from around March 2011.

I remember very vividly the passion they showed over that meal. They knew they had a long road ahead of them to convince the web-developer community of the value of this framework and that many substantial changes would be needed. But they had a vision and a group of people that were willing to give them a chance.

  • why #getEach instead of #pluck?
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@jamesarosen
jamesarosen / forms.md
Last active June 1, 2016 22:48
Inline Validations, Form Resetting, and Initial Values in Ember

Conditionally Show Validation Errors

I have a component for an <input> that (a) knows about validations and (b) knows how to only show validation errors if the user has touched the field or submitted the form:

// my-input/component.js
export default Ember.Component.extend({
  attributeBindings: [ 'isValid:data-is-valid', 'showValidationErrors:data-show-validation-errors' ],
  classNames: [ 'my-input' ],
@jamesarosen
jamesarosen / algorithms.md
Last active April 7, 2016 16:40
Practicing some algorithms

Sorting

Mergesort

export default function mergesort(array) {
  if (array.length <= 1) { return array; }
  const halfIndex = Math.floor(array.length / 2);
  const left = array.splice(0, halfIndex);
  return merge(mergesort(left), mergesort(array));
@jamesarosen
jamesarosen / house-hunting.md
Last active April 14, 2016 16:48
House Hunting in the Bay Area

Priorities

My priorities (please suggest things I didn't think of):

  1. Under $1.3M
  2. Safe neighborhood
  3. Livable condition, but it doesn't have to be super up-to-date; no major structural problems
  4. Quiet street; not next to train tracks, highway, or a lot of bars; prefer not on El Camino or similarly major streets
  5. Less than 2mi from some shops / a town center
  6. Freestanding home; not part of a condo/townhome association
@jamesarosen
jamesarosen / hash-table.js
Last active March 25, 2016 06:21
Implementing a HashTable based on JS arrays... just for fun
export default class HashTable {
constructor(size) {
this._data = new Array(size);
}
// Inserts `value` under `key`, forgetting any previous value stored under `key`.
// Returns the HashTable.
insert(key, value) {
bucketFor(this._data, key, true).insert(key, value);
return this;
@jamesarosen
jamesarosen / trouble.md
Last active February 19, 2016 20:42
Trouble with Ember 1.13 Query Params

Some notes on problems I'm experiencing with Ember's Query-Params.

Background

I'm trying to create a "global" query-param that exists on controller:application and sticks around for the whole session. An example might be http://myapp.com/some/route?locale=es. The only oddity is that only some users are allowed to set this parameter; for other users, it's ignored. I started with the following

// app/pods/application/controller.js
@jamesarosen
jamesarosen / application.controller.js
Last active February 18, 2016 18:43
Query Params Investigation
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
queryParams: [ 'refreshCount' ],
refreshCount: Ember.computed({
get() { return 0; },
set(prop, newVal) { return +newVal; }
}),
@jamesarosen
jamesarosen / application.controller.js
Created February 5, 2016 18:06
Application Query Params
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
queryParams: [ 'myParam' ]
});
@jamesarosen
jamesarosen / git-excise-attempt.md
Last active January 13, 2016 00:14
Trying to excise some commits

I have a project with a long git history. I want to open-source it, but there's a long section at the beginning that I want to remove first.

*    ddfe660 - (HEAD, origin/master)
|
|    (many hundreds of commits, including merges)
|
*    420b801 - (the intended beginning of the new history)
*    00a3516 - (the most recent commit I want squashed out)