Skip to content

Instantly share code, notes, and snippets.

@tomdale
tomdale / 1-say-hello.ts
Last active April 11, 2017 18:58
TypeScript, JavaScript
class Person {
/** The person's given name. */
name: string;
constructor(name: string) {
this.name = name;
}
async sayHello() {
console.log(`Hello, ${this.name}!`);
v6.9.2
4.0.5
glimmer-perf-app@0.0.0 /Users/tomdale/Code/glimmer-perf-app
├─┬ @glimmer/application-pipeline@0.5.2
│ ├─┬ @glimmer/compiler@0.23.0-alpha.11
│ │ ├── @glimmer/interfaces@0.23.0-alpha.11
│ │ ├── @glimmer/syntax@0.23.0-alpha.11
│ │ ├── @glimmer/wire-format@0.23.0-alpha.11
│ │ └── simple-html-tokenizer@0.3.0
│ ├── @glimmer/di@0.2.0
┌───────────────────────────────┬────────┐
│ Function │ Time │
├───────────────────────────────┼────────┤
│ dist/app.js │ 42.731 │
├───────────────────────────────┼────────┤
│ WeakMap │ 0.213 │
├───────────────────────────────┼────────┤
│ populateBuiltins │ 0.19 │
├───────────────────────────────┼────────┤
│ populateBuiltins$1 │ 0.171 │
@tomdale
tomdale / rfc.md
Created September 21, 2016 18:18
WIP Targets RFC

Targets RFC

  • Start Date: (fill me in with today's date, YYYY-MM-DD)
  • RFC PR: (leave this empty)
  • Ember Issue: (leave this empty)

Summary

Gives Ember developers and addon authors the ability to build an Ember app for targets in addition to the browser.

FastBoot Naming Questions

Your input is needed!

Error Handling

Right now, if an app errors out while fufilling a request, the FastBoot server returns a 500 HTTP status code and an error message. This is probably the correct behavior for using FastBoot for pre-rendering content.

However, if you're serving FastBoot pages to the end user, this is problematic. If you happen to have a route that crashes on certain circumstances, but only on Node—for example, maybe it inadvertently accesses localStorage—you'd rather serve the app to the user because

@tomdale
tomdale / deploy.js
Created December 22, 2015 03:32
Script for deploying zip of FastBoot build to S3
#!/usr/bin/env node
var AWS = require('aws-sdk');
var RSVP = require('rsvp');
var exec = RSVP.denodeify(require('child_process').exec);
var fs = require('fs-promise');
var chalk = require('chalk');
var crypto = require('crypto');
@tomdale
tomdale / gist:239676ad88289c56b74e
Created December 9, 2015 22:40
FastBoot dependencies

WIP, I had to run in the middle of writing this and will flesh it out in more detail later

Managing Node.js Dependencies in FastBoot Apps

By default, we sandbox Ember apps running in FastBoot such that they cannot access any built in Node.js features: no file IO, no network, etc.

However, FastBoot apps need to be able to fetch model data over the network, the same way they do in the browser. Historically, we've hardcoded the najax global to be available in the FastBoot context,

@tomdale
tomdale / proposal.md
Last active October 16, 2019 09:01
Ember Data / Ember Ajax / Ember Fetch proposal

Networking in Ember

Motivation

Most client-side applications need to fetch data over the network. In the Ember.js ecosystem, many developers use a high-level abstraction, like Ember Data, that standardizes network access via an adapter pattern.

For those who want more low-level control over data fetching, it is

@tomdale
tomdale / gist:ad71ff9bf1227b687510
Created June 5, 2015 02:29
Shell function to start IR Hydra
irhydra () {
cd ~/irhydra
command rm -f *.cfg *.asm
command "/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary" --no-sandbox \
--js-flags="--trace-hydrogen \
--trace-phase=Z \
--trace-deopt \
--code-comments \
--hydrogen-track-positions \
--redirect-code-traces"
@tomdale
tomdale / gist:7d17530c12dbc104b15d
Created November 15, 2014 20:05
destructuring assignment example
// before
var displayAnnotation = config.displayAnnotation,
width = config.width,
axisHeight = config.axisHeight,
barsLeftMargin = config.barsLeftMargin,
barsRightMargin = config.barsRightMargin;
// after
var { displayAnnotation,