Skip to content

Instantly share code, notes, and snippets.

package test
package grepgit.core
import scala.collection.mutable
import scala.reflect.ClassTag
/**
* A Generator of elements of type [[A]].
*
* [[Generator]] is basically the inverse of
import scala.reflect.runtime.universe._
import scala.util.{Failure, Success, Try}
object CompanionTypeSystem {
def apply[SealedClass: TypeTag, Companion: TypeTag](fBoundedType: String): Set[Companion] = {
val sealedClassType = typeOf[SealedClass]
val companionType = typeOf[Companion]
val upperBound = sealedClassType
val refineCompanionWithTypeParameter = getTypeWithTypeParameterOrElseCheckTypeMember(companionType, fBoundedType, upperBound, isSelfRecursive = false)
@leogrim
leogrim / IO.scala
Created February 14, 2014 01:31
IO Helpers - Automated Backup and Restoration of Lucene Indices with Amazon S3 - http://eng.kifi.com/automated-backup-and-restoration-of-lucene-indices-with-amazon-s3/
import java.io._
import java.util.zip.{GZIPInputStream, GZIPOutputStream}
import org.apache.commons.compress.archivers.tar.{TarArchiveInputStream, TarArchiveEntry, TarArchiveOutputStream}
import org.apache.commons.io.{IOUtils, FileUtils}
object IO {
def addToArchive(tarArchive: TarArchiveOutputStream, file: File, base: String = ""): Unit = {
val entryName = base + file.getName
val entry = new TarArchiveEntry(file, entryName)
@andrewconner
andrewconner / FutureGoodies.scala
Last active May 4, 2016 11:34
SafeFuture, TimeoutFuture, CancelableFuture implementations. See https://eng.42go.com/future-safefuture-timeout-cancelable for further explanation.Thanks to @bretthoerner for spotting an error!
/* We've run into a few common pitfalls when dealing with Futures in Scala, so I wrote these three helpful
* classes to give some baked-in functionality.
*
* I'd love to hear about other helpers you're using like these, or if you have improvement suggestions.
* github@andrewconner.org / @connerdelights
*/
import scala.concurrent.{ExecutionContext, CanAwait, Awaitable, Future, Promise}
import scala.concurrent.duration.Duration
import scala.util.Try