This file contains 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
let contraction_table = |w: &str| match | |
(contraction(w),pronoun(w),with_verb(w)) { | |
(false ,_ ,_ ) => "No Apostrophe", | |
(true ,true ,true ) => "Use Apostrophe", | |
(true ,false ,_ ) => "Use Apostrophe", | |
(true ,true ,false ) => "No Apostrophe" | |
}; | |
let possessive_table = |w: &str| match | |
(possessive(w),is_it_it(w),is_or_has(w),name_ends_in_s(w),plural_name(w),ends_in_s(w)) { |
This file contains 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
[Fact] | |
public async Task GameIsTied() | |
{ | |
await _appService.Handle(new CreateGameCommand(_gameId, _player1)); | |
await _appService.Handle(new MakeMoveCommand(_gameId, _player1, Move.Rock)); | |
await _appService.Handle(new MakeMoveCommand(_gameId, _player2, Move.Rock)); | |
var events = await _repository.Load(_gameId); | |
Assert.True(events.Contains(new Events.GameTiedEvent(_gameId))); | |
} |
This file contains 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 async Task<Game> GetCurrentState(Guid gameId) => | |
(await _repository.Load(gameId)).Aggregate(new Game(), (g, e) => Game.Apply(g, e)); | |
private List<IEvent> SendToAggregate(ICommand command, Game game) => | |
command switch | |
{ | |
CreateGameCommand c => game.Handle(c), | |
MakeMoveCommand c => game.Handle(c), | |
_ => throw new NotImplementedException() | |
}; |
This file contains 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 async Task<Game> GetCurrentState(Guid gameId) => | |
(await _repository.Load(gameId)).Aggregate(new Game(), (g, e) => Game.Apply(g, e)); | |
private List<IEvent> SendToAggregate(ICommand command, Game game) => | |
command switch | |
{ | |
CreateGameCommand c => game.Handle(c), | |
MakeMoveCommand c => game.Handle(c), | |
_ => throw new NotImplementedException() | |
}; |
This file contains 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
public static Game Apply(Game game, IEvent evt) | |
{ | |
switch (evt) | |
{ | |
case GameCreatedEvent e: | |
return new Game | |
{ | |
State = EState.Created, | |
Player = e.PlayerEmail, | |
}; |
This file contains 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
public List<IEvent> Handle(MakeMoveCommand cmd) | |
{ | |
if (EState.Created == State) | |
{ | |
return new List<IEvent> | |
{ | |
new MoveDecidedEvent(cmd.GameId, cmd.PlayerEmail, cmd.Move) | |
}; | |
} | |
else if (EState.Waiting == State) |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<script src="https://cdn.tailwindcss.com"></script> | |
<title>Spotify Now Playing</title> | |
</head> | |
<body> |
This file contains 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 requests | |
from typing import Generator | |
from contextlib import contextmanager | |
from dataclasses import dataclass | |
@dataclass | |
class Context: | |
span: opentracing.Span | |
session: requests.Session |
This file contains 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 random | |
_desserts = { | |
"AngelDelight": "😇+💕", | |
"AngelCake": "😇+🍰", | |
"Amandine": "🍫🍰", | |
"Bakewell": "🍒+🧁", | |
"Brownie": "🍫🟤y", | |
"Battenberg": "🦇+🧊", | |
"Cake": "🍰", |