This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System.IO | |
| open System | |
| let input = File.ReadLines("day-2.txt") | |
| // part 1 | |
| let countTwosAndThrees line = | |
| line | |
| |> Seq.countBy id | |
| |> Seq.map snd // only take counts (second param), letter not important |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // part 1 | |
| System.IO.File.ReadAllLines("day-1.txt") | |
| |> Seq.map int | |
| |> Seq.reduce (+) | |
| |> printfn "%A" | |
| // part 2 | |
| let rec findFirstRepeating (input: seq<int>, vals: seq<int>, i: int, total: int) = | |
| let newTotal = total + Seq.item (i % Seq.length input) input |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System.IO | |
| open System | |
| let inputFilePath = "input.txt" | |
| let readLines (filePath: string) = seq { | |
| use sr = new StreamReader (filePath) | |
| while not sr.EndOfStream do yield sr.ReadLine () | |
| } | |
| let toWordArray (x: string) = x.Split(' ') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pool: | |
| vmImage: 'Ubuntu 16.04' | |
| steps: | |
| - script: dotnet build | |
| displayName: 'build' | |
| - script: dotnet test $(System.DefaultWorkingDirectory)/**/TestCodeCoverageProject.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura | |
| displayName: 'test with coverage' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private captureEvents(canvasEl: HTMLCanvasElement) { | |
| Observable | |
| .fromEvent(canvasEl, 'mousedown') | |
| .switchMap((e) => { | |
| return Observable | |
| .fromEvent(canvasEl, 'mousemove') | |
| .takeUntil(Observable.fromEvent(canvasEl, 'mouseup')) | |
| .pairwise() | |
| }) | |
| .subscribe((res: [MouseEvent, MouseEvent]) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private drawOnCanvas( | |
| prevPos: { x: number, y: number }, | |
| currentPos: { x: number, y: number } | |
| ) { | |
| // incase the context is not set | |
| if (!this.cx) { return; } | |
| // start our drawing path | |
| this.cx.beginPath(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private captureEvents(canvasEl: HTMLCanvasElement) { | |
| // this will capture all mousedown events from the canvas element | |
| fromEvent(canvasEl, 'mousedown') | |
| .pipe( | |
| switchMap((e) => { | |
| // after a mouse down, we'll record all mouse moves | |
| return fromEvent(canvasEl, 'mousemove') | |
| .pipe( | |
| // we'll stop (and unsubscribe) once the user releases the mouse | |
| // this will trigger a 'mouseup' event |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { | |
| Component, Input, ElementRef, AfterViewInit, ViewChild | |
| } from '@angular/core'; | |
| @Component({ | |
| selector: 'app-canvas', | |
| template: '<canvas #canvas></canvas>', | |
| styles: ['canvas { border: 1px solid #000; }'] | |
| }) | |
| export class CanvasComponent implements AfterViewInit { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {Component} from '@angular/core'; | |
| import {DialogsService} from './dialogs.service'; | |
| @Component({ | |
| selector: 'material-app', | |
| template: ` | |
| <div> | |
| <button md-raised-button (click)="openDialog()">Open Dialog</button> | |
| <p>Result from dialog: {{ result }}</p> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { DialogsService } from './dialogs.service'; | |
| import { MdDialogModule, MdButtonModule } from '@angular/material'; | |
| import { NgModule } from '@angular/core'; | |
| import { ConfirmDialog } from './confirm-dialog.component'; | |
| @NgModule({ | |
| imports: [ | |
| MdDialogModule, | |
| MdButtonModule, |