Skip to content

Instantly share code, notes, and snippets.

Matthew de Detrich mdedetrich

Block or report user

Report or block mdedetrich

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mdedetrich
mdedetrich / PostgresEncodings.scala
Created Jul 2, 2019
Common encodings for Postgres Scala
View PostgresEncodings.scala
import java.time.OffsetDateTime
import enumeratum._
import io.circe.Json
import io.getquill.context.jdbc.PostgresJdbcContextBase
import org.postgresql.util.PGobject
trait PostgresEncodings {
val ctx: PostgresJdbcContextBase[_]
@mdedetrich
mdedetrich / FindToolsJar.java
Last active May 15, 2018
Find tools.jar if it exists on your system, translated from https://stackoverflow.com/a/25163628
View FindToolsJar.java
import java.util.*;
import java.io.File;
class FindToolsJar {
static ArrayList<String> paths = new ArrayList<String>();
static ArrayList<File> files = new ArrayList<File>();
static final String suffix = "/lib/tools.jar";
private static final void addStringToArray(String value) {
try {
View ifmacros.scala
```scala
implicit def decoder
#IF-SCALA < 2.13
[C[A] <: Traversable[A]](implicit cbf: MyCollection.CBF1[C],cbf2: MyCollection.CBF2[C]): Decoder[MyCollection[C]]
#ELSE
[C[A] <: Traversable[A]](implicit builder: Builder[C]): Decoder[MyCollection[C]]
#DONE
= new Decoder[MyCollection[C]] {
override def apply(c: HCursor): Decoder.Result[MyCollection[C]] = {
(
View pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- Put this pom.xml in your project directory -->
<!-- And run "mvn initialize" to download all dependencies -->
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
@mdedetrich
mdedetrich / ArrayExtensions.scala
Created Nov 17, 2016
Array Extensions for Quill 1.0.0
View ArrayExtensions.scala
trait ArrayExtensions extends io.getquill.context.jdbc.JdbcEncoders with io.getquill.context.jdbc.JdbcDecoders {
this: JdbcContext[PostgresDialect, _] =>
implicit def arrayStringDecoder[T]: Decoder[Array[String]] =
new Decoder[Array[String]] {
def apply(index: Int, row: ResultRow) = {
row.getArray(index + 1).getArray.asInstanceOf[Array[String]]
}
}
@mdedetrich
mdedetrich / benchmarks.scala
Last active Jan 21, 2016
.emptyAttr @inline vs no @inline benchmarks
View benchmarks.scala
With @inline
scalatagsJS/testOnly scalatags.text.ScalatagsPerf
[info] 1/3 scalatags.text.ScalatagsPerf.correctness.performance Success
[info] ScalatagsPerf 45273 in 10000
[info] 2/3 scalatags.text.ScalatagsPerf.correctness Success
[info] 3/3 scalatags.text.ScalatagsPerf Success
[info] -----------------------------------Results-----------------------------------
[info] scalatags.text.ScalatagsPerf Success
@mdedetrich
mdedetrich / build.sbt
Created Sep 17, 2015
Issue with rubygems + sbt
View build.sbt
name := "rubygems-test"
resolvers += "rubygems-releases" at "http://rubygems-proxy.torquebox.org/releases"
libraryDependencies ++= Seq("org.mdedetrich" % "java-premailer-wrapper" % "1.1_1.8.4")
scalaVersion := "2.11.7"
View Auction.scala
val declinedBidIds = declinedBidsThisRound.map(_.user.id)
val currentBidsAlreadyMadeIds = currentBidsAlreadyMade.map(_.user.id)
val clientUsers = {for(
u <- Users if (u.id notIn declinedBidIds
&& u.completedSignup === true)
) yield u}.list
View build.sbt
seq(jsSettings : _*)
(sourceDirectory in (Compile, JsKeys.js)) <<= (sourceDirectory in Compile)(_ / "coffee")
(sourceDirectory in (Test, JsKeys.js)) <<= (sourceDirectory in Test)(_ / "unit" / "coffee")
(resourceManaged in (Compile, JsKeys.js)) <<= (resourceManaged in (Compile, JsKeys.js))(_ / "js")
(resourceManaged in (Test, JsKeys.js)) <<= (resourceManaged in (Test, JsKeys.js))(_ / "unit" / "js")
View MonetiseClient.scala
get("/") {
contentType="text/html"
jade("index")
}
// get("/:page") {
// findTemplate(params("page")) map { path =>
// contentType = "text/html"
// jade(path)
// } orElse serveStaticResource() getOrElse resourceNotFound()
You can’t perform that action at this time.