Skip to content

Instantly share code, notes, and snippets.

View gclaramunt's full-sized avatar

Gabriel Claramunt gclaramunt

View GitHub Profile
@gclaramunt
gclaramunt / Playground.hs
Last active March 9, 2021 23:41
Plutus Playground Smart Contract
-- This is a starter contract, based on the Game contract,
-- containing the bare minimum required scaffolding.
--
-- What you should change to something more suitable for
-- your use case:
-- * The MyDatum type
-- * The MyMyRedeemerValue type
--
-- And add function implementations (and rename them to
-- something suitable) for the endpoints:
@gclaramunt
gclaramunt / Playground.hs
Last active March 3, 2021 12:55
Plutus Playground Smart Contract
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
import Language.PlutusTx.Prelude hiding (pure, (<$>))
import Ledger (Address, Validator, ValidatorCtx, Value, scriptAddress)
import qualified Ledger.Constraints as Constraints
import qualified Ledger.Typed.Scripts as Scripts
import Playground.Contract
@gclaramunt
gclaramunt / Playground.hs
Created March 2, 2021 19:20
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
@gclaramunt
gclaramunt / Playground.hs
Last active March 2, 2021 14:21
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import qualified Data.Text as T
import Language.Plutus.Contract
@gclaramunt
gclaramunt / Playground.hs
Created March 1, 2021 14:10
Plutus Playground Smart Contract
-- A game with two players. Player 1 thinks of a secret word
-- and uses its hash, and the game validator script, to lock
-- some funds (the prize) in a pay-to-script transaction output.
-- Player 2 guesses the word by attempting to spend the transaction
-- output. If the guess is correct, the validator script releases the funds.
-- If it isn't, the funds stay locked.
import Control.Monad (void)
import qualified Data.ByteString.Char8 as C
import Language.Plutus.Contract
import qualified Language.PlutusTx as PlutusTx
package demo
import akka.serialization.SerializerWithStringManifest
import scalapb.{GeneratedMessage, GeneratedMessageCompanion}
import scala.reflect.runtime.{universe => ru}
/**
* Custom Serializer/Deserializer for scalapb protobuf generated classes
*/
@gclaramunt
gclaramunt / gist:74698bf8881899f42ad77916c2716946
Last active January 11, 2019 20:06
foldMap and secuence
object FutureUtils {
/**
* Serialises the futures so they execute one after another
* Future.sequence still runs all futures at the same time
*/
def sequence[A, B](l: Iterable[A])(fn: A ⇒ Future[B])(implicit ec: ExecutionContext): Future[Iterable[B]] =
foldM(l, ListBuffer.empty[B]) { (xs, x) => fn(x).map(xs :+ _) }
/**
def sequence[A, B](l: Iterable[A])(fn: A ⇒ Future[B])(implicit ec: ExecutionContext): Future[List[B]] =
l.foldLeft(Future(List.empty[B])) {
(previousFuture, next) ⇒
for {
previousResults ← previousFuture
next ← fn(next)
} yield previousResults :+ next
abstract class Blarhg[A] {
def add(x: A, y: A): A
}
abstract class Blejjj[A] extends Blarhg[A] {
def unit: A
}
object ImplicitTest extends App {
implicit object StringBlejjj extends Blejjj[String] {
def add(x: String, y: String): String = x concat y
def unit: String = ""
@gclaramunt
gclaramunt / git-dmz-flow.md
Last active August 29, 2015 14:27 — forked from djspiewak/git-dmz-flow.md
Git DMZ Flow

Git DMZ Flow

I've been asked a few times over the last few months to put together a full write-up of the Git workflow we use at RichRelevance (and at Precog before), since I have referenced it in passing quite a few times in tweets and in person. The workflow is appreciably different from GitFlow and its derivatives, and thus it brings with it a different set of tradeoffs and optimizations. To that end, it would probably be helpful to go over exactly what workflow benefits I find to be beneficial or even necessary.

  • Two developers working on independent features must never be blocked by each other
    • No code freeze! Ever! For any reason!
  • A developer must be able to base derivative work on another developer's work, without waiting for any third party
  • Two developers working on inter-dependent features (or even the same feature) must be able to do so without interference from (or interfering with) any other parties
  • Developers must be able to work on multiple features simultaneously, or at lea