Skip to content

Instantly share code, notes, and snippets.

View kryptt's full-sized avatar
:octocat:
Looking for inspiration

Rodolfo Hansen kryptt

:octocat:
Looking for inspiration
View GitHub Profile
@kryptt
kryptt / query-fragment.scala
Last active August 29, 2015 14:17
Playing with the QueryFragment Idea
package msw.util
import doobie.imports.{Composite, Query0}
import doobie.hi.connection.{ prepareStatement, prepareQueryAnalysis, prepareQueryAnalysis0, process => cprocess }
import doobie.hi.preparedstatement.{ set, executeQuery }
import doobie.hi.resultset.{ getUnique, getOption }
import scalaz.syntax.monad._
import shapeless._
import shapeless.ops.hlist.Prepend
@kryptt
kryptt / Using the state monad with HPS in doobie
Last active August 29, 2015 14:20
Idea of adding a State Monad around PreparedStatementIO
import doobie.imports.{Composite, HPS, PreparedStatementIO => IO}
import generic.isEmpty
import scalaz.{Monoid, State}
import scalaz.syntax.monad._
import shapeless._
import shapeless.record._
import shapeless.ops.hlist._
@kryptt
kryptt / argonaut-efficient-traversal.scala
Last active August 29, 2015 14:26
cleanup dissallowed fields
import argonaut._, Argonaut._
Object example {
def cleanup(details: Json): Json = details
.withArray(_.map(cleanup))
.withObject(jo => JsonObject.from(jo.toList.map(cleanup)))
def cleanup(field: (JsonField, Json)): (JsonField, Json) = (field._1.toLowerCase, field._1, field._2) match {
case (pwd, k, _) if List("password", "passwd", "pass", "pwd").contains(pwd) => (k, jString("******"))
case (_, k, v) => (k, cleanup(v))
@kryptt
kryptt / buld.sbt
Created September 16, 2015 13:24
How to get to the siteMappings in root ?
import com.typesafe.sbt.SbtSite.SiteKeys._
import com.typesafe.sbt.SbtGhPages.GhPagesKeys._
val commonSettings = Seq(
organization := "com.rodolfohansen",
version := "0.1-SNAPSHOT",
scalaVersion := "2.11.7",
autoAPIMappings := true
)
@kryptt
kryptt / blocks.scala
Last active November 28, 2018 03:09
Model/View/Update using FS2
package br
package blocks
import scala.concurrent.{ExecutionContext, Future}
import fs2.{Strategy, Stream, Task}
import fs2.async.mutable.Topic
abstract class Piece[Model, View]
(events: Stream[Task, Any])(implicit ec: ExecutionContext) {
@kryptt
kryptt / keybase.md
Created May 8, 2017 17:39
Keybase Id

Keybase proof

I hereby claim:

  • I am kryptt on github.
  • I am rhansen (https://keybase.io/rhansen) on keybase.
  • I have a public key ASDXfmDX3w-O85UsTCxmAR6OgEJFlKo-H1arnci0zizDZgo

To claim this, I am signing this object:

@kryptt
kryptt / tree.sc
Created January 30, 2018 08:59
Four different strategies for calculating tree depth. a tail recursive version, a continuation passing version and a recursion schema version
#!/usr/bin/amm
import $ivy.`org.scalaz::scalaz-core:7.2.18`
import $ivy.`com.slamdata::matryoshka-core:0.18.3`
import scala.annotation.tailrec
sealed trait Tree[+A]
object Tree {
@kryptt
kryptt / innerFlow.sc
Last active October 18, 2019 10:10
Inner Flow for Vitaly
#!/usr/bin/env amm
import $plugin.$ivy.`org.typelevel:::kind-projector:0.11.0`
import $ivy.{
`co.fs2::fs2-core:2.0.1`,
`com.github.julien-truffaut::monocle-generic:2.0.0`
}
import cats.Applicative
import fs2._
import monocle._
@kryptt
kryptt / SVNXmlParserSpec.scala
Created September 25, 2019 07:28
SVN XML Parser Property Based Test Specification
package industrious
import io.dylemma.spac.xml._
import org.specs2.{ScalaCheck, Specification}
import org.scalacheck.{Gen, Prop}
class SvnXmlParserSpec extends Specification with ScalaCheck {
def is = s2"""
SVN XML Parser can
parse entries $parseEntries
@kryptt
kryptt / traversal.scala
Last active August 17, 2020 10:02
Useful Lenses
class BalanceSheet {
val froms: List[Transaction]
val toss: List[Transaction]
/* ... */
}
class Transaction {
val issue: DateTime
val acknowledge: DateTime
/* ... */