Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Teebo
Teebo / Octaves
Last active September 19, 2019 09:52
SVG Piano octaves
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="100%" viewBox="0 0 1120 400" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Piano Keyboard</title>
<defs></defs>
<g id="piano-keyboard">
<g id="octave-1">
<rect id="octave-1-C-key" class="piano-key white-key" data-piano-key="C" stroke="#555555" fill="#FFFFF7" x="0" y="0" width="80" height="400"></rect>
<rect id="octave-1-D-key" class="piano-key white-key" data-piano-key="D" stroke="#555555" fill="#FFFFF7" x="80" y="0" width="80" height="400"></rect>
<rect id="octave-1-E-key" class="piano-key white-key" data-piano-key="E" stroke="#555555" fill="#FFFFF7" x="160" y="0" width="80" height="400"></rect>
<rect id="octave-1-F-key" class="piano-key white-key" data-piano-key="F" stroke="#555555" fill="#FFFFF7" x="240" y="0" width="80" height="400"></rect>
@Teebo
Teebo / hero.component.html
Created January 31, 2021 12:01
HeroComponent - Parent form
<form [formGroup]="heroForm">
<nb-card>
<nb-card-header>Hero</nb-card-header>
<nb-card-body class="col">
<input
formControlName="heroName"
type="text"
nbInput
placeholder="Hero name"
/>
@Teebo
Teebo / hero.component.spec.ts
Created January 31, 2021 12:27
Unit test for @ViewChild approach
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HobbiesStubComponent } from './component-stubs/hobbies-stub.component';
import { HeroComponent } from './hero.component';
describe('HeroComponent', () => {
let component: HeroComponent;
let fixture: ComponentFixture<HeroComponent>;
const formBuilder: FormBuilder = new FormBuilder();
@Teebo
Teebo / hobbies.component.ts
Created January 31, 2021 12:45
HobbiesComponent - Uses ControlContainer
import { Component, Input, OnInit } from '@angular/core';
import { ControlContainer, FormGroup } from '@angular/forms';
@Component({
selector: 'app-hobbies',
templateUrl: './hobbies.component.html',
styleUrls: ['./hobbies.component.scss']
})
export class HobbiesComponent implements OnInit {
public hobbiesForm: FormGroup;
@Teebo
Teebo / hobbies-stub.component.ts
Created January 31, 2021 12:51
Component stub
import { Component, Input, OnInit } from '@angular/core';
@Component({
selector: 'app-hobbies',
template: ''
})
export class HobbiesStubComponent {
}
@Teebo
Teebo / hobbies.component.spec.ts
Created January 31, 2021 12:53
HobbiesComponent tests
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ControlContainer, FormBuilder, Validators } from '@angular/forms';
import { HobbiesComponent } from './hobbies.component';
describe('HobbiesComponent', () => {
let component: HobbiesComponent;
let fixture: ComponentFixture<HobbiesComponent>;
const formBuidler: FormBuilder = new FormBuilder();
@Teebo
Teebo / singleton.ts
Last active November 5, 2022 16:16
Singleton pattern
export interface ISession {
username: string;
token: string;
}
/**
* Session class
*/
export class Session implements ISession {