Skip to content

Instantly share code, notes, and snippets.

Yehuda Katz wycats

View GitHub Profile
wycats / 1-js.js
Created Jul 30, 2020
alternative observer design
View 1-js.js
// observed popover is interested in changes to `width` and `height` relative to the
// page's origin, and normalized by rounding them to the nearest integer.
let observedPopover = new RectObserver(
width: Math.round,
height: Math.round
relativeTo: 'origin' // not viewport
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
value: 'Hello world',
inputted(e) {
Ember.set(this, 'value',;
View js.ts
// default tagName is 'div'
// The problem
function createElement(tagName: string): Element {
// very broken
return document.createElement(tagName || 'div');
// you might want to use defaults
import Ember from 'ember';
export default Ember.Component.extend({
View monad-stuff.ts
import { unknown } from 'ts-std';
import { ErrorMessage } from "monad-test";
export type ErrorPath = ReadonlyArray<string>;
export interface ErrorMessage {
key: string;
args: unknown;
import FirebaseAdapter from 'emberfire/adapters/firebase';
export default FirebaseAdapter.extend({

The Ember Creed

  1. Optimize for programmer happiness
  2. Convention over configuration
  3. The menu is omakase
  4. No one paradigm
  5. Exalt beautiful code
  6. Provide sharp knives
  7. Value integrated systems
  8. Stability without Stagnation
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
wycats /
Last active Apr 8, 2018
A Response to "The Birthering of the Democrats"

Response to The Birthering of the Democrats

Let us accept from the outset that partisan Democrats and I will never agree on the substance of the particular claims they have made about the election. Let’s simply try to find common ground on what they’re alleging. Conventional post-election debate among Democrats has involved…

Freddie claims that "conventional post-election debate among Democrats" is made up of a number of characteristics. I don't think the debate has been nearly as homogenous as he implies, and the bullets are full of misleading hyperbole that further amps up the emotion of the piece.

wycats /
Last active Oct 21, 2018
How I think about error handling in Rust
  • Option: "None is a totally valid result, usually found in data structures"
    • unwrap(): YOLO use in prototyping
    • expect(...): to indicate the reason you believe None is impossible (or a contract violation for the method)
  • Result: 😱 "Errors are unexpected but not bugs; the decision for how to handle them is up to the caller"
    • unwrap(): YOLO "I'm an app and don't know how to handle this error -- I'm fine if the whole process aborts"
    • try! / ?: "Leave the decision about how to handle this error to the caller; they have more information"
    • match / catch: "I'm going to handle the error right here right now"
  • panic!: "The error is a bug and can't be recovered from. Game over man. Rust is allowed to abort the process if it wants"
You can’t perform that action at this time.