Skip to content

Instantly share code, notes, and snippets.

@dragos
dragos / reflect.scala
Created November 16, 2015 15:56
Reflect on singleton types
package test
// prints:
//
// test.Main.C prefix value: test.Main$@54a097cc
// test.Main.o.D prefix value: Outer(o)
object Main {
val universe = scala.reflect.runtime.universe
val mirror = universe.runtimeMirror(getClass.getClassLoader)
import universe._
@dragos
dragos / overloadingmap.scala
Created November 16, 2015 11:14
Overloading Dataset.map
trait Encoder[T]
trait JFunction[T, U]
trait Dataset[T] {
def map[U](f: T => U)(implicit encoder: Encoder[U])
def map[U](f: JFunction[T, U], encoder: Encoder[U])
}
trait Testing {
implicit val e: Encoder[Int] = ???
@dragos
dragos / gist:fcfda4deeaf63514b81f
Created June 30, 2015 16:13
Building sbt 0.13.8
----- org.scala-lang:scala-compiler:jar:2.11.6 found !
>>>>> Zinc
>> Building Zinc using dbuild
>> Writing properties: /Volumes/Thunderbolt_SSD/dragos/workspace/plugin/uber-build/target/zinc/current-zinc-build.properties
>> publish-repo=https://proxy-ch.typesafe.com:8082/artifactory/ide-2.11
sbt-tag=v0.13.8
sbt-version=0.13.8-on-2.11.6-for-IDE-SNAPSHOT
>> Detected sbt version: 0.13.8-on-2.11.6-for-IDE-SNAPSHOT
[scala2] --== Extracting dependencies for scala2 ==--
[scala2] ----------
@dragos
dragos / gist:f2b48ef15e6ef7049693
Created June 26, 2015 16:45
Wikipedia filtering
package test
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.SQLContext
import SQLContext._
import org.apache.spark.sql.types._
case class WikidataElement(id: String, sites: Map[String, String])

Keybase proof

I hereby claim:

  • I am dragos on github.
  • I am dragos (https://keybase.io/dragos) on keybase.
  • I have a public key whose fingerprint is 12D2 FCAC 81B2 3BDF EE19 AEE3 2988 22A1 9159 F5E2

To claim this, I am signing this object:

@dragos
dragos / gist:c082696bd5f76dc63bb4
Created April 20, 2015 09:35
dbuild failure referring to a7
$ ./uber-build.sh config/sbt-publish-0.13.6-2.11.x.conf
>>>>> Check arguments
>>>>> Load config
>>>>> Setup logging
>>>>> Set flags
>>>>> Check prerequisites
>>>>> Check configuration
0
>>>>> Scala
----- org.scala-lang:scala-compiler:jar:2.11.6 found !
@dragos
dragos / gist:c43590e4c764d4a24f17
Created August 5, 2014 09:47
Shapeless PC bug.
// build.sbt
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")
)
// For Scala 2.11.0
scalaVersion := "2.11.0"
libraryDependencies ++= Seq(
val tpe = typeOf[test.GenericFoo[Int]] //> tpe : reflect.runtime.universe.Type = test.GenericFoo[Int]
tpe.getClass //> res0: Class[?0] = class scala.reflect.internal.Types$TypeRef$$anon$5
tpe.takesTypeArgs //> res1: Boolean = false
val tpe1 = typeOf[test.GenericFoo[_]].typeSymbol.typeSignature
//> tpe1 : reflect.runtime.universe.Type = [T]AnyRef{def <init>(): test.Generic
//| Foo[T]}
@dragos
dragos / gist:5031512
Created February 25, 2013 17:27
changelog script output.
bash GenChangeLog.bash release/scala-ide-2.1.0-m2-2.10 master:
Mon, 25 Feb 2013 02:00:41 -0800 - Iulian Dragos
* Use Scala specific task markers.
Sat, 23 Feb 2013 09:34:01 +0100 - Luc Bourlier
*