Skip to content

Instantly share code, notes, and snippets.

View alxhub's full-sized avatar

Alex Rickabaugh alxhub

  • Google, Inc.
  • San Francisco, CA
View GitHub Profile
@alxhub
alxhub / my.component.ts
Created February 9, 2022 21:41
How the Angular Compiler Works - Component With Selector Constant
const MY_SELECTOR = 'my-cmp';
@Component({
selector: MY_SELECTOR,
template: '...',
})
export class MyCmp {}
@alxhub
alxhub / app.component.js
Created February 9, 2022 21:37
How the Angular Compiler Works - AppComponent After Compilation
import { Component } from '@angular/core';
import * as i0 from "@angular/core";
export class AppCmp {
constructor() {
this.name = 'Alex';
}
}
AppCmp.ɵfac = function AppCmp_Factory(t) { return new (t || AppCmp)(); };
AppCmp.ɵcmp = i0.ɵɵdefineComponent({
@alxhub
alxhub / app.component.ts
Created February 9, 2022 21:36
How the Angular Compiler Works - AppComponent Before Compilation
import {Component} from '@angular/core';
@Component({
selector: 'app-cmp',
template: '<span>Your name is {{name}}</span>',
})
export class AppCmp {
name = 'Alex';
}
@alxhub
alxhub / abstractcontrol.ts
Last active September 24, 2020 00:40
Medium Embed testing
export abstract class AbstractControl {
readonly value: any;
readonly valueChanges: Observable<any>;
readonly statusChanges: Observable<any>;
}
copyFlagToPicture(
Matrix4 transform, Size deviceSize, img.Image flag, img.Image pic) async {
print("device: " + deviceSize.toString());
var d_flag_scale = deviceSize.width / flag.width;
var d_flag_height = flag.height * d_flag_scale;
print("d_flag_height: " + d_flag_height.toString());
var d_flag_top = deviceSize.height / 2.0 - (d_flag_height / 2.0);
var d_flag_bottom = deviceSize.height / 2.0 + (d_flag_height / 2.0);
Vector4 vd_flag_lt = transform * (new Vector4(0.0, d_flag_top, 0.0, 1.0));
packages/elements/test/slots_spec.ts:34:59 - error TS2345: Argument of type 'NgElementConstructor<{ accessKey: string; readonly accessKeyLabel: string; autocapitalize: string; dir: string; draggable: boolean; hidden: boolean; innerText: string; lang: string; readonly offsetHeight: number; readonly offsetLeft: number; readonly offsetParent: Element | null; readonly offsetTop: number; readonly offsetWidth: number; spellcheck: boolean; title: string; translate: boolean; click: () => void; addEventListener: { <K extends "input" | "progress" | "select" | "fullscreenchange" | "fullscreenerror" | "abort" | "animationcancel" | "animationend" | "animationiteration" | "animationstart" | "auxclick" | "blur" | "cancel" | "canplay" | "canplaythrough" | "change" | "click" | "close" | "contextmenu" | "cuechange" | "dblclick" | "drag" | "dragend" | "dragenter" | "dragexit" | "dragleave" | "dragover" | "dragstart" | "drop" | "durationchange" | "emptied" | "ended" | "error" | "focus" | "focusin" | "focusout" | "gotpointercaptu
import * as ts from 'typescript';
import {DecoratorHandler, DetectResult} from './api';
export enum TraitState {
PENDING = 0x01,
ANALYZED = 0x02,
RESOLVED = 0x04,
ERRORED = 0x08,
SKIPPED = 0x10,
function (rf) {
if (rf & 1) {
// creation mode
}
if (rf & 2) {
// update mode
}
}
// Setup: RxJS shaped types
declare class Observable<T> { _t: T; }
declare interface ObservedValueOf<T> { _t: T; _brand: 'ObservedValueOf'; }
declare interface Scheduler { _brand: 'Scheduler'; }
declare type ObservableInput<T> = Observable<T> | Promise<T> | T[];
// A trick to force T to be inferred as a tuple type. TypeScript would prefer to infer
// an array, but arrays don't match {0: any}.
type Tuple<T> = (T & { 0: any }) | [];
{ paths:
{ 'rxjs/ajax':
[ 'external/rxjs/ajax/index',
'bazel-out/darwin-fastbuild/genfiles/external/rxjs/ajax/index',
'bazel-out/darwin-fastbuild/bin/external/rxjs/ajax/index' ],
'rxjs/operators':
[ 'external/rxjs/operators/index',
'bazel-out/darwin-fastbuild/genfiles/external/rxjs/operators/index',
'bazel-out/darwin-fastbuild/bin/external/rxjs/operators/index' ],
'rxjs/testing':