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
<?php | |
class ValueObject { | |
protected $value; | |
public function equals(ValueObject $other) { | |
return $this->value === $other->value; | |
} | |
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
def initiateRegistration(userName: UserName, emailAddress: EmailAddress): Reader[RegistrationRepository, Future[Registration]] = Reader { repo => | |
val exists: OptionT[Future, (Registration, Registration)] = for { | |
e <- repo.findByUserName(userName) | |
u <- repo.findByEmailAddress(emailAddress) | |
} yield (e, u) | |
exists.run.flatMap { | |
case None => | |
val hash = Random.alphanumeric take 32 mkString "" | |
val reg = Registration(UUID.randomUUID(), userName, emailAddress, hash, DateTime.now()) |
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
def listTuple1(List a): Option[(a,a)] = a match { | |
case x :: y :: _ => Some((x,y)) | |
case _ => None | |
} |
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
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
module Main where | |
import Projectable | |
data CounterEvent = Created | Increased | Decreased deriving (Show) | |
data Counter = Counter Int deriving (Show) |
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 Data.List (foldl') | |
data Projection s e = Projection { runProjection :: s -> e -> s | |
, state :: s | |
} | |
mkProjection :: (s -> e -> s) -> s -> Projection s e | |
mkProjection = Projection | |
loadProjection :: (s -> e -> s) -> s -> [e] -> Projection s e |
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
/** | |
* @var DateTimeImmutable <-- kay | |
*/ | |
private $date; | |
protected function __construct() | |
{ | |
$this->date = date("Y-m-d H:i:s"); // <-- waaaat? | |
} |
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
{-# LANGUAGE DefaultSignatures #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
module Test2 where | |
import Data.Aeson | |
import Data.Maybe (catMaybes) |
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
<?php | |
$data = [ | |
'req_url' => $_SERVER['REQUEST_URI'], | |
'remote_addr' => $_SERVER['REMOTE_ADDR'], | |
'time' => (new DateTime())->format('Y-m-d H:i:s'), | |
'get' => $_GET, | |
'post' => $_POST | |
]; |
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
-- pokeNameLine is "Mimikyu @ Ghostium Z \n" (where \n represents newline) | |
pokeNameLineParser :: Parser (String,String) | |
pokeNameLineParser = do | |
name <- manyTill anyChar (spaces <* char '@' *> spaces) | |
thingAfterAt <- manyTill anyChar newline | |
return (name, thingAfterAt) |