Skip to content

Instantly share code, notes, and snippets.

View a2mz's full-sized avatar

Oleksandr Morozov a2mz

View GitHub Profile
@a2mz
a2mz / bitcoin-seeds.bash
Created July 8, 2022 10:09 — forked from atoponce/bitcoin-seeds.bash
Generate 1,000 valid BIP39 mnemonic phrases in Bash
#!/bin/bash
bip39=(abandon ability able about above absent absorb abstract absurd abuse access accident account accuse achieve acid acoustic acquire across act action actor actress actual adapt add addict address adjust admit adult advance advice aerobic affair afford afraid again age agent agree ahead aim air airport aisle alarm album alcohol alert alien all alley allow almost alone alpha already also alter always amateur amazing among amount amused analyst anchor ancient anger angle angry animal ankle announce annual another answer antenna antique anxiety any apart apology appear apple approve april arch arctic area arena argue arm armed armor army around arrange arrest arrive arrow art artefact artist artwork ask aspect assault asset assist assume asthma athlete atom attack attend attitude attract auction audit august aunt author auto autumn average avocado avoid awake aware away awesome awful awkward axis baby bachelor bacon badge bag balance balcony ball bamboo banana banner bar barely bargain barrel ba
@a2mz
a2mz / auxpattern.scala
Created September 1, 2020 12:55 — forked from gigiigig/auxpattern.scala
Aux Pattern
import shapeless._
import scalaz._
import Scalaz._
object console extends App {
trait Foo[A] {
type B
def value: B
@a2mz
a2mz / DependencyInjection.scala
Created March 23, 2020 06:05 — forked from fanf/DependencyInjection.scala
Simple, Static Scala dependency injection with Shapeless
package test_shapeless
object DI {
import shapeless._
trait Injecter[L <: HList, A] {
def apply(l: L) : A
}
trait InjecterAux[L <: HList, A] {
@a2mz
a2mz / LoggingMailbox.scala
Created November 10, 2018 05:08 — forked from patriknw/LoggingMailbox.scala
Logs the mailbox size when exceeding the configured limit. Implemented in Scala and Java. Copy one of them to your project and define the configuration. This code is licensed under the Apache 2 license.
/**
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.contrib.mailbox
import scala.concurrent.duration._
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.atomic.AtomicLong
import com.typesafe.config.Config
import akka.actor.{ ActorContext, ActorRef, ActorSystem, ExtendedActorSystem }
case class Person1(name: String, age: Int, other: Option[String])
case class Person2(name: String, age: Int, other: String)
import play.api.libs.functional.syntax._
import play.api.libs.json._
implicit val person1Format = (
(JsPath \ "name").format[String] and
(JsPath \ "age").format[Int] and
(JsPath \ "other").formatNullable[String].inmap[Option[String]](x => Some(x.getOrElse("default")), y => y)
@a2mz
a2mz / TestMultipartFileUpload.scala
Created November 13, 2017 13:41 — forked from jrudolph/TestMultipartFileUpload.scala
akka-http Multipart file-upload client + server example
package akka.http.scaladsl
import java.io.File
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.util.ByteString
import scala.concurrent.duration._
import akka.actor.ActorSystem
@a2mz
a2mz / AkkaHttpMicroService.scala
Created October 27, 2017 04:43 — forked from jeroenr/AkkaHttpMicroService.scala
Akka HTTP API with CORS headers and custom Media types
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.stream.ActorMaterializer
object Boot extends App with Service with CorsSupport {
override implicit val system = ActorSystem()
override implicit val executor = system.dispatcher
override implicit val materializer = ActorMaterializer()
Http().bindAndHandle(corsHandler(routes), "0.0.0.0", 1337)
import cats.{Id, Monad, Traverse, ~>}
import scala.concurrent.{Await, Future}
import scala.concurrent.duration.Duration
object TagLess extends App {
case class PurchaseOrderId(value: String)
case class ProductId(value: String)
case class LocationId(value: String)
@a2mz
a2mz / freemonads.scala
Created August 12, 2017 05:29 — forked from kciesielski/freemonads.scala
Free Monads example
package com.softwaremill.freemonads
import cats.free.Free
import cats.~>
import cats._, cats.std.all._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
sealed trait External[A]
case class Tickets(count: Int) extends AnyVal
@a2mz
a2mz / RobotCommands.scala
Last active June 28, 2017 13:18 — forked from pfcoperez/RobotCommands.scala
[Parsers] Parsers combinators example #scala #parsers
import scala.util.parsing.combinator._
object RobotCommands extends App {
object Entities {
trait MovementDirection
case object Up extends MovementDirection
case object Down extends MovementDirection
case object Left extends MovementDirection