Skip to content

Instantly share code, notes, and snippets.


Jim Armstrong theAlgorithmist

View GitHub Profile
View FractionType.ts
import { BasicMathType } from "./basic-math-type";
// Fraction Type
export interface FractionType extends BasicMathType
// is this a mixed number?
get mixed(): boolean
// designate this as a mixed number
set mixed(pIsMixed: boolean);
View BasicMathType.ts
export type ExtendedMathType =
BasicMathType |
number |
import { MathTypeEnum } from "./math-type-enum";
export interface BasicMathType
// what is the current math type?
View evalute.ts
public evaluate(variables: Array<expressionOperand>): expressionValue
if (this._expressionStack.length === 0) return false;
if (variables.length != this._variables.length) return false;
const len: number = variables.length;
let j: number;
for (j = 0; j < len; ++j) {
if (!this.__isValidOperand(variables[j])) return false;
View state-machine-models.ts
* The current state of a machine with a given name
export interface FSMState
name: string;
isAcceptance: boolean;
transition: string;
View setPreviewImage
public setPreviewImage(imgURL: string): void
if (this._canvas !== undefined)
const img: HTMLImageElement = new Image();
this._url = imgURL;
img.crossOrigin = 'anonymous';
// TODO This only works for a single image load. As an exercise, modify to handle deletion (including handlers)
View fabric-service.ts
import { Injectable } from '@angular/core';
import { fabric } from 'fabric';
import { POINT } from '../libs/point';
@Injectable({providedIn: 'root'})
export class FabricService
// draw properties are public to keep the demo more compact; but, you break it ... you buy it
View basic-legend.ts
import {
} from './map-legends';
export const legendClasses: MapLegendClasses =
legendTitleClass: "title-text",
View map-legend.ts
export type IconProps = LegendCircleData | LegendRectData | LegendPolygonData;
export interface MapLegendClasses
legendTitleClass: string;
legendContainerClass: Array<string>;
legendHeadingClass: string;
View calculator.reducer.ts
import {
} from '@ngrx/store';
import * as CalculatorActions from './calculator.actions';
import { QCalc } from '../../shared/definitions/QCalc';
View QCalulations.ts
import { TSMT$Quaternion } from './Quaternion';
import { Q } from '../definitions/Q';
export class QCalculations
protected static readonly Q1: TSMT$Quaternion = new TSMT$Quaternion();
protected static readonly Q2: TSMT$Quaternion = new TSMT$Quaternion();