Skip to content

Instantly share code, notes, and snippets.

package ch.epfl.bluebrain.nexus.delta.rdf.jsonld.encoder
import cats.implicits._
import ch.epfl.bluebrain.nexus.delta.rdf.IriOrBNode.BNode
import ch.epfl.bluebrain.nexus.delta.rdf.graph.{Dot, NTriples}
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.{JsonLdApi, JsonLdOptions}
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution}
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.{CompactedJsonLd, ExpandedJsonLd}
import ch.epfl.bluebrain.nexus.delta.rdf.syntax._
import ch.epfl.bluebrain.nexus.delta.rdf.{IriOrBNode, RdfError}
@umbreak
umbreak / Top2.scala
Created August 30, 2020 17:42
Have an enum bind to a return type of a class hierarchy
sealed trait Top
object Top {
final case class A(v: String) extends Top { def a: A = this }
final case class B(v: String) extends Top { def b: B = this }
def apply[V <: Top](select: TopEnum[V], value: String): V =
select match {
@umbreak
umbreak / Top.scala
Created August 30, 2020 17:41
CanBuild scala
// An example of building a Concrete class with implicitly available CanBuild
sealed trait Top {
type ActualType
}
trait CanBuild[A <: Top] {
def apply(v: String): A#ActualType
}
object Top {
@umbreak
umbreak / README.md
Last active May 7, 2020 09:58
Blue Brain Graph POC

Blue Brain Graph POC

A service which will do the following:

Ingestion

  1. Listen to Nexus SSE of type {Paper} on project {literature}.
  2. Split each paper into sentences.
  3. Make an API call to Blue Brain Search to get the dense vector for each sentence.
  4. For each sentence, insert a document in ES index (paper_sentences):
@umbreak
umbreak / ExampleSpec.scala
Last active June 6, 2019 10:10
Mockito fails with Malformed class name when using java 8
import ExampleSpec._
import org.mockito.IdiomaticMockito
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{Matchers, WordSpecLike}
import scala.concurrent.Future
// Mockito fails with 'Malformed class name' when using java 8
class ExampleSpec extends WordSpecLike with Matchers with IdiomaticMockito with ScalaFutures {
@umbreak
umbreak / schema.json
Created July 24, 2018 14:42
Resolver schema
{
"@context": {
"nxv": "https://bluebrain.github.io/nexus/vocabulary/",
"distribution": {
"@id": "http://schema.org/distribution"
},
"id": "@id",
"type": "@type",
"links": {
"@id": "nxv:links"
import ch.epfl.bluebrain.nexus.admin.ld.other.CustomRefinements.CustomType
import ch.epfl.bluebrain.nexus.admin.ld.other.ProjectRefinements.{ProjectReference, ProjectReferencePredicate}
import eu.timepit.refined._
import eu.timepit.refined.api._
import eu.timepit.refined.collection._
import eu.timepit.refined.auto._
import eu.timepit.refined.string.MatchesRegex
object Collect {
@umbreak
umbreak / MigrationSpec.scala
Last active December 21, 2017 15:15
KG migration v0.8
import java.util.regex.Pattern
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.alpakka.cassandra.scaladsl.CassandraSource
import akka.stream.scaladsl.Sink
import akka.testkit.TestKit
import com.datastax.driver.core._
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{Matchers, WordSpecLike}
@umbreak
umbreak / MigrationSpec.scala
Created November 21, 2017 15:04
KG migration v0.7.6 and IAM migration v0.3.4
import java.util.{Date, UUID}
import akka.actor.ActorSystem
import akka.event.Logging
import akka.stream.ActorMaterializer
import akka.stream.alpakka.cassandra.scaladsl.CassandraSource
import akka.testkit.TestKit
import com.datastax.driver.core._
import org.scalatest.{Matchers, WordSpecLike}
import io.circe.parser._