Skip to content

Instantly share code, notes, and snippets.

View EdgeCaseBerg's full-sized avatar
Wondering why Github added statuses instead of something useful

Ethan Eldridge EdgeCaseBerg

Wondering why Github added statuses instead of something useful
View GitHub Profile
EdgeCaseBerg / WSClientBackend.scala
Last active October 16, 2018 20:01
WSClient powered backend for sttp.
package module
/* Don't import ._ because there's naming conflicts between sttp and ws for request bodies and whatnot */
import ws.{ WSClient, WSClientConfig, WSRequest, WSResponse }
import play.api.libs.iteratee.Enumerator
import com.softwaremill.sttp._
import com.softwaremill.sttp.internal.SttpFile
import com.softwaremill.sttp.monadSyntax._
EdgeCaseBerg / makeZip.scala
Last active July 2, 2018 16:29
How to make a zip file in scala (Java 8)
import java.nio.file.{Files, Paths, Path, FileVisitResult}
import java.nio.file.attribute.BasicFileAttributes
import java.nio.file.SimpleFileVisitor
def autoClosing[C <: Closeable, T](closeable: C)(c: C => T) = {
try {
} finally {
EdgeCaseBerg / caseInsensitive.sense
Last active May 11, 2018 20:40
Case Insensitive ElasticSearch Regular expressions
# Delete any old test index
DELETE example_copy
# Create index with appropriate mappings/settings
# Note that the pattern is meant to not match anything so that the entire field is taken as the "token"
PUT example_copy
"settings": {
"analysis": {
EdgeCaseBerg / VimeoClient.scala
Last active April 9, 2018 18:28
How to use Vimeo API from Scala
import com.vimeo.networking._
import com.vimeo.networking.model._
import com.vimeo.networking.model.error.VimeoError;
import com.vimeo.networking.callbacks._
import scala.concurrent.{Future, Promise}
import scala.reflect.ClassTag
import scala.reflect._
import okhttp3.CacheControl
EdgeCaseBerg / how to
Created December 19, 2017 16:59
How to fix reactive mongo playframework dependency issue when (trying) using 12.6

Getting this?

java.lang.NoSuchMethodError: play.api.libs.iteratee.Execution$Implicits$.trampoline()Lscala/concurrent/ExecutionContext;

Is your build.sbt including a dependency like this?

"org.reactivemongo" %% "play2-reactivemongo" % "0.12.6-play24"
EdgeCaseBerg / CustomShellPrompt.scala
Created August 2, 2017 16:08
Make a git prompt in sbt!
import sbt._
import Keys._
// This lifted from
object CustomShellPrompt {
val Branch = """refs/heads/(.*)\s""".r
def gitBranchOrSha =
(Process("git symbolic-ref HEAD") #|| Process("git rev-parse --short HEAD")).!! match {
EdgeCaseBerg / how-to-do-without-tuple-horror.scala
Last active June 27, 2017 14:19
Over 22 fields in play-json case class. How to deal.
import play.api.libs.json._
import play.api.libs.functional.syntax._
case class AToM(
a: Int,
b: Int,
c: Int,
d: Int,
e: Int,
f: Int,
import com.typesafe.config.ConfigFactory
val c = ConfigFactory.load().getConfig("gs")
import com.mcl.recipesearch.service._
val gsConf = GroceryServerConf(true, new"endpoint")), c.getString("clientId"), c.getString("clientApiKey"))
EdgeCaseBerg / removeAllEmptyChildren.scala
Created February 22, 2017 18:53
How to remove empty text from HTML with Jsoup + Scala
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import scala.collection.JavaConverters._
def removeAllEmptyChildren(doc: Document): = {
val allElements = doc.body().getAllElements()
allElements.asScala.foreach { element =>
if(!element.hasText) {