Skip to content

Instantly share code, notes, and snippets.

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
EdgeCaseBerg / WSClientBackend.scala
Last active Oct 16, 2018
WSClient powered backend for sttp.
View WSClientBackend.scala
package module
/* Don't import ._ because there's naming conflicts between sttp and ws for request bodies and whatnot */
import play.api.libs.ws
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
EdgeCaseBerg / makeZip.scala
Last active Jul 2, 2018
How to make a zip file in scala (Java 8)
View makeZip.scala
import java.io.FileOutputStream
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 {
c(closeable)
} finally {
closeable.close()
@EdgeCaseBerg
EdgeCaseBerg / caseInsensitive.sense
Last active May 11, 2018
Case Insensitive ElasticSearch Regular expressions
View caseInsensitive.sense
# 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
EdgeCaseBerg / VimeoClient.scala
Last active Apr 9, 2018
How to use Vimeo API from Scala
View VimeoClient.scala
import com.vimeo.networking._
import com.vimeo.networking.model._
import com.vimeo.networking.model.error.VimeoError;
import com.vimeo.networking.callbacks._
import java.io.File
import scala.concurrent.{Future, Promise}
import scala.reflect.ClassTag
import scala.reflect._
import okhttp3.CacheControl
@EdgeCaseBerg
EdgeCaseBerg / how to fix.md
Created Dec 19, 2017
How to fix reactive mongo playframework dependency issue when (trying) using 12.6
View how to fix.md

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"
View learning_scala.org
View CustomShellPrompt.scala
import sbt._
import Keys._
// This lifted from https://github.com/mingchuno/aws-wrap/blob/master/project/CustomShellPrompt.scala
object CustomShellPrompt {
val Branch = """refs/heads/(.*)\s""".r
def gitBranchOrSha =
(Process("git symbolic-ref HEAD") #|| Process("git rev-parse --short HEAD")).!! match {
@EdgeCaseBerg
EdgeCaseBerg / how-to-do-without-tuple-horror.scala
Last active Jun 27, 2017
Over 22 fields in play-json case class. How to deal.
View how-to-do-without-tuple-horror.scala
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,
View todogss.scala
import com.typesafe.config.ConfigFactory
val c = ConfigFactory.load().getConfig("gs")
import com.mcl.recipesearch.service._
val gsConf = GroceryServerConf(true, new java.net.URI(c.getString("endpoint")), c.getString("clientId"), c.getString("clientApiKey"))
@EdgeCaseBerg
EdgeCaseBerg / removeAllEmptyChildren.scala
Created Feb 22, 2017
How to remove empty text from HTML with Jsoup + Scala
View removeAllEmptyChildren.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) {
element.remove()