Skip to content

Instantly share code, notes, and snippets.

View pshirshov's full-sized avatar
😹

Paul S. pshirshov

😹
View GitHub Profile
@pshirshov
pshirshov / hlist.scala
Last active October 18, 2017 16:27
HLIst and implicit based specializations
// hlist definition
sealed trait HList
case class HPair[A, B <: HList](head: A, tail: B) extends HList {
override def toString = Seq(head, tail).mkString(" ::: ")
}
case object HNil extends HList
// instantiation
import com.typesafe.config.{Config, ConfigFactory}
import scala.language.{existentials, higherKinds, implicitConversions}
trait Monoid[T] {
def mapply(a: T, b: T): T
def mzero: T
}
@pshirshov
pshirshov / DNF.scala
Last active October 13, 2017 10:10
Optimizing DNF converter
import scala.reflect.ClassTag
trait Expr
case class Not(expr: Expr) extends Expr {
override def toString = s"!$expr"
}
case class Value[T](t: T) extends Expr {
override def toString = s"$t"
@pshirshov
pshirshov / ConfigUtils.scala
Last active November 18, 2015 18:32
OSGi complex config
// flat <-> hierarchical conversions
import java.util
import java.util.regex.Pattern
import scala.collection.JavaConversions._
import com.typesafe.config.{Config, ConfigFactory, ConfigList, ConfigObject, ConfigUtil}
import com.typesafe.scalalogging.StrictLogging
@pshirshov
pshirshov / ht.py
Created May 26, 2015 12:13 — forked from guenter/http.py
import sys
port = 8080
if sys.version_info.major == 3:
import http.server
import socketserver
handler = http.server.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("",port), handler)
elif sys.version_info.major == 2: