Skip to content

Instantly share code, notes, and snippets.

View notxcain's full-sized avatar
🏠
Working from home

Denis Mikhaylov notxcain

🏠
Working from home
View GitHub Profile
@notxcain
notxcain / example.scala
Created November 14, 2016 07:15
Free Interpreter Gen
@free sealed trait Op[A]
object Op {
final case class StringOp(s: String) extends Op[String]
final case class PolyOp[A](a: A) extends Op[A]
/* Should be expanded to
trait ForF[F[_]] {
def stringOp(s: String): F[String]
def polyOp[A](a: A): F[A]
}
@notxcain
notxcain / request.xsd
Created November 15, 2016 12:16
СБЕРБАНК УПШ 2.0
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://bssys.com/upg/request"
targetNamespace="http://bssys.com/upg/request" elementFormDefault="qualified"
attributeFormDefault="unqualified" version="1.0">
<xs:element name="Request" type="Request">
<xs:annotation>
<xs:documentation>Запрос УС к СББОЛ</xs:documentation>
</xs:annotation>
</xs:element>
<xs:complexType name="Fraud">
@notxcain
notxcain / upg5.wsdl
Last active November 15, 2016 15:00
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions name="UniversalPaymentGate" targetNamespace="http://upg.sbns.bssys.com/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://upg.sbns.bssys.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<xs:schema elementFormDefault="qualified" targetNamespace="http://upg.sbns.bssys.com/" version="1.0" xmlns:tns="http://upg.sbns.bssys.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="changePassword" type="tns:changePassword"/>
<xs:element name="changePasswordResponse" type="tns:changePasswordResponse"/>
<xs:element name="getRequestStatus" type="tns:getRequestStatus"/>
<xs:element name="getRequestStatusResponse" type="tns:getRequestStatusResponse"/>
<xs:element name="getRequestStatusSRP" type="tns:getRequestStatusSRP"/>
<xs:element name="getRequestStatusSRPResponse" type="tns:getRequestStatusSRPResponse"/>
@notxcain
notxcain / cofree.scala
Created December 13, 2016 08:32
Streams for (Co)free
import cats.data.Kleisli
import cats.implicits._
import cats.{Applicative, FlatMap, Functor, Monad, Monoid, ~>}
final case class Cofree[F[_], A](head: A, tail: F[Cofree[F, A]]) {
def map[B](f: A => B)(implicit F: Functor[F]): Cofree[F, B] =
Cofree(f(head), F.map(tail)(_.map(f)))
def zip[B](other: Cofree[F, B])(implicit F: Applicative[F]): Cofree[F, (A, B)] =
Cofree((head, other.head), (tail |@| other.tail).map(_ zip _))
import cats.{ Functor, ~> }
import cats.implicits._
import shapeless.{ :+:, ::, CNil, Coproduct, Generic, HList, HNil, Inl, Inr }
sealed abstract class HasHandlers[C[_], F[_], H, A] {
type Out
def apply(h: H, a: A): F[Out]
}
object HasHandlers {
@notxcain
notxcain / OffsetRepartitioner.scala
Last active April 13, 2017 08:34
Repartition Offset Calculator
package io.aecor.distributedprocessing
object OffsetRepartitioner {
type Partition = Int
def apply[A, Offset: Ordering](
oldPartitioner: A => Partition,
newNumberOfPartitions: Int,
getNearestLeftInNewPartition: (Partition, Offset) => Option[A],
offsetOf: A => Offset
@algebra
trait Ag[F[_]] {
def mate(name: String): F[Unit]
def feed(food: String): F[Unit]
def kill: F[Unit]
}
sealed trait AgEvent
case class AgBorn(name: String) extends AgEvent
case class AgAte(food: String) extends AgEvent
Drift into Failure - http://www.amazon.com/Drift-into-Failure-Components-Understanding-ebook/dp/B009KOKXKY
How Complex Systems Fail - http://web.mit.edu/2.75/resources/random/How%20Complex%20Systems%20Fail.pdf
Leverage Points: Places to Intervene in a System - http://www.donellameadows.org/archives/leverage-points-places-to-intervene-in-a-system/
Going Solid: A Model of System Dynamics and Consequences for Patient Safety - http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1743994/
Resilience in Complex Adaptive Systems: Operating at the Edge of Failure - https://www.youtube.com/watch?v=PGLYEDpNu60
Puppies! Now that I’ve got your attention, Complexity Theory - https://www.ted.com/talks/ nicolas_perony_puppies_now_that_i_ve_got_your_attention_complexity_theory
How Bacteria Becomes Resistant - http://www.abc.net.au/science/slab/antibiotics/resistance.htm
Towards Resilient Architectures: Biology Lessons - http://www.metropolismag.com/Point-of-View/March-2013/Toward-Resilient-Architectures-1-Biology-Lessons/ Dealing in
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="UniversalPaymentGate" targetNamespace="http://upg.sbns.bssys.com/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://upg.sbns.bssys.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://bssys.com/upg/request"
targetNamespace="http://bssys.com/upg/request" elementFormDefault="qualified"
attributeFormDefault="unqualified" version="1.0">
<wsdl:types>
<xs:schema elementFormDefault="qualified" targetNamespace="http://upg.sbns.bssys.com/" version="1.0" xmlns:tns="http://upg.sbns.bssys.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="changePassword" type="tns:changePassword"/>
<xs:element name="changePasswordResponse" type="tns:changePasswordResponse"/>
<xs:element name="getRequestStatus" type="tns:getRequestStatus"/>
import akka.http.scaladsl.server.Directives._
import akka.cluster.Member
import akka.actor.Address
import akka.http.scaladsl.model.StatusCodes
import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport._
import io.circe.generic.auto._
val cluster = Cluster(system)
final case class ClusterView(status: MemberStatus,