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
| pragma solidity 0.5.3; | |
| /** | |
| * Can receive money. | |
| * Can be stolen. | |
| * Non payable at address. | |
| */ | |
| contract Alfa { | |
| function stealMyEth() public { |
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
| pragma solidity 0.5.3; | |
| /** | |
| * Can receive money. | |
| * Can be stolen. | |
| * Payable at address. | |
| */ | |
| contract Beta { | |
| function stealMyEth() public { |
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
| pragma solidity 0.5.3; | |
| contract Addressable { | |
| address payable public target; | |
| function addressSet(address payable y) public { | |
| target = y; | |
| } | |
| } |
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
| pragma solidity ^0.5.2; | |
| /** | |
| * @title Ownable | |
| * @dev The Ownable contract has an owner address, and provides basic authorization control | |
| * functions, this simplifies the implementation of "user permissions". | |
| * @dev The God | |
| */ | |
| contract GodOwner { | |
| address payable _owner; |
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
| pragma solidity 0.5.2; | |
| contract Contract_C { | |
| address payable [5] public target = [address(0), address(0),address(0),address(0),address(0)]; | |
| uint8 public max = 5; | |
| uint public amountToPaid = 1; | |
| event Sent(address destination, uint amount); | |
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 java.util.concurrent.TimeoutException | |
| import java.util.{Timer, TimerTask} | |
| import play.api.Logger | |
| import scala.collection.generic.CanBuildFrom | |
| import scala.concurrent.duration.FiniteDuration | |
| import scala.concurrent.{ExecutionContext, Future, Promise} | |
| import scala.util.{Failure, Random, Success} | |
| object FutureUtils { |
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
| type A[E,T] = (E, Try[T]) | |
| def seqOfFuturesRecovered[T, E](elems: Seq[E])(func: E => Future[T])(implicit executionContext: ExecutionContext): Future[Seq[A[E,T]]] = { | |
| elems.foldLeft(Future(Seq.empty[A[E, T]])) { (acc, elem) => | |
| acc.flatMap { prevSeq: Seq[(E, Try[T])] => | |
| FutureOps(func(elem)).futureToTry.map( (elem, _)).map { prevSeq :+ _} | |
| } | |
| } | |
| } |
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
| from reactive programms edx course | |
| // Utilities to temporarily have unimplemented parts of the program | |
| private def unimplementedFlow[A, B, C]: Flow[A, B, C] = | |
| Flow.fromFunction[A, B](_ => ???).mapMaterializedValue(_ => ??? : C) | |
| private def unimplementedSink[A, B]: Sink[A, B] = Sink.ignore.mapMaterializedValue(_ => ??? : B) |
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
| #!/usr/bin/env amm | |
| import $ivy.`org.apache.hadoop:hadoop-common:3.2.0`, org.apache.commons.codec.binary.Base32 | |
| // HexBytesUtil from https://gist.githubusercontent.com/tmyymmt/3721117/raw/70af27f30df0ec0084e37e7fe3ff0a547bf8020b/HexBytesUtil.scala | |
| object HexBytesUtil { | |
| def hex2bytes(hex: String): Array[Byte] = { | |
| if(hex.contains(" ")){ | |
| hex.split(" ").map(Integer.parseInt(_, 16).toByte) | |
| } else if(hex.contains("-")){ |
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
| // in buid.sbt """routesImport ++= Seq("com.nachinius.controllers.Binders._" """ | |
| package com.nachinius.controllers | |
| object Binders { | |
| implicit def BigDecimalQueryStringBindable = new QueryStringBindable[BigDecimal] { | |
| override def bind(key: String, params: Map[String, Seq[String]]): Option[Either[String, BigDecimal]] = { | |
| params.get(key).flatMap(_.headOption).map { value => | |
| Try { BigDecimal(value) } match { | |
| case Success(value) => Right(value) | |
| case Failure(exception) => Left(exception.getMessage) |