instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
package scjson.converter import scutil.lang.* import scjson.converter.{ CollectionConverters as CC, AltSeqConverters as ASC } trait NullOptionJsonReaders extends NullOptionJsonReadersLow { private given NullOptionJsonUnitReader:JsonReader[Unit] = UnitConverters.UnitReader given OptionOptionReader[T](using ev:J...
Explain and rewrite the following Scala code:
package ru.pavkin.todoist.api.core import org.scalatest.FunSuite import org.scalatest.prop.Checkers import shapeless.test.{illTyped, typed} import shapeless.{::, HNil} class CommandReturnsSpec extends FunSuite with Checkers { implicit val i1 = new CommandReturns[Int] { type Result = String } implicit val i...
Explain and rewrite the following Scala code:
package io.pipeline.prediction.tensorflow import java.io._ import java.util._ import java.util.zip._ object ZipFileUtil { def unzip(filename: String, outputPath: String): Unit = { val BUFFER = 2048; try { var dest: BufferedOutputStream = null var is: BufferedInputStream = null ...
Explain and rewrite the following Scala code:
package opencl.ir.pattern import ir.ast._ import lift.arithmetic.PosVar case class MapLane(override val f: Lambda1) extends AbstractMap(f, "MapLane", PosVar("lane_id")) { override def copy(f: Lambda): Pattern = MapLane(f) }
Explain and rewrite the following Scala code:
package chandu0101.scalajs.react.components.demo.components import chandu0101.scalajs.react.components.all._ import japgolly.scalajs.react.vdom.prefix_<^._ import japgolly.scalajs.react.{BackendScope, ReactComponentB, _} /** * Created by chandrasekharkode . */ object AppHeader { object Style { val headerSty...
Explain and rewrite the following Scala code:
package com.twitter.concurrent import java.util.concurrent.atomic.AtomicLong import com.google.caliper.SimpleBenchmark /** * Measure Scheduler.submit/run time when there are multiple threads. Previous * to changing SampleScale from 50 to 1000, there was sometimes contention for * the global threads lock in getCu...
Explain and rewrite the following Scala code:
package com.tmersov.wsclient import akka.actor.{Terminated, ActorSystem} import akka.testkit.TestProbe import com.typesafe.config.ConfigFactory import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner import org.scalatest.matchers.ShouldMatchers import org.scalatest.path import org.specs2.mock.Mockito i...
Explain and rewrite the following Scala code:
package ch14 object ex04 { abstract class Item case class Article(description: String, price: Double) extends Item case class Bundle(description: String, discount: Double, items: Item*) extends Item case class Multiple(m: Int, a: Item) extends Item def price(it: Item): Double = it match { case Article(...
Explain and rewrite the following Scala code:
package controllers import javax.inject._ import service.ProdutoService import play.api.mvc._ @Singleton class ProdutoController @Inject()(cc: ControllerComponents) extends AbstractController(cc) { def index(id: Long) = Action { implicit request: Request[AnyContent] => try { val json = (new ...
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s.source /** A Typeclass that is used by index requests to convert a type into a document for use by Elasticsearch */ trait Indexable[-T] { def json(t: T): String }
Explain and rewrite the following Scala code:
/* * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Explain and rewrite the following Scala code:
package honor import models.db.MasterShipBase import ranking.common.EvolutionBase /** * * @author ponkotuy * Date: 15/03/18 */ object InitShip extends HonorCategory { override def category: Int = 9 override def approved(memberId: Long, db: HonorCache): List[String] = { val result = for { ship <- db...
Explain and rewrite the following Scala code:
package models.product import play.api.libs.json.Json case class CategoryTree(tree: Seq[CategoryTreeItem]) object CategoryTree { implicit val jsonReads = Json.reads[CategoryTree] }
Explain and rewrite the following Scala code:
/******************************************************************************* * Copyright 2017 Capital One Services, LLC and Bitwise, Inc. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at...
Explain and rewrite the following Scala code:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\\ * @ @ * * # # # # (c) 2017 CAB * * # # # # # # ...
Explain and rewrite the following Scala code:
package forcomp import org.scalatest.FunSuite import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner import Anagrams._ @RunWith(classOf[JUnitRunner]) class AnagramsSuite extends FunSuite { test("wordOccurrences: abcd") { assert(wordOccurrences("abcd") === List(('a', 1), ('b', 1), ('c', 1), ('...
Explain and rewrite the following Scala code:
package edu.berkeley.cs package scads package piql package gradit import storage.TestScalaEngine object TestScadr { def main(args: Array[String]): Unit = { val client = new GraditClient(TestScalaEngine.newScadsCluster(), new SimpleExecutor) val word = new Word(0) word.word = "test" word.definition ...
Explain and rewrite the following Scala code:
package com.catinthedark.ld36 import com.badlogic.gdx.backends.lwjgl.{LwjglApplication, LwjglApplicationConfiguration} import com.catinthedark.common.Const object DesktopLauncher { def main(args: Array[String]) { val conf = new LwjglApplicationConfiguration System.setProperty("org.lwjgl.opengl.Display.allow...
Explain and rewrite the following Scala code:
package org.http4s import scala.reflect.macros.blackbox /** Thanks to ip4s for the singlePartInterpolator implementation * https://github.com/Comcast/ip4s/blob/b4f01a4637f2766a8e12668492a3814c478c6a03/shared/src/main/scala/com/comcast/ip4s/LiteralSyntaxMacros.scala */ object LiteralSyntaxMacros { def uriInterp...
Explain and rewrite the following Scala code:
// Copyright (C) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See LICENSE in project root for information. package com.microsoft.ml.spark import java.io.File import java.net.URI import org.apache.spark.ml.feature.{OneHotEncoder, StringIndexerModel} import com.microsoft.ml.spark.Read...
Explain and rewrite the following Scala code:
/** * Copyright 2012-2013 StackMob * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to i...
Explain and rewrite the following Scala code:
package fr.renoux.gaston.model import cats.Monoid import cats.implicits._ import fr.renoux.gaston.util.CollectionImplicits._ import fr.renoux.gaston.util.{BitSet, Context, testOnly} /** * A schedule is an association of people, to topics, to slots. * What we're trying and testing and looking for a good one. */ ...
Explain and rewrite the following Scala code:
package mvgk.db.model object ResourceEnum extends Enumeration { type ResourceEnum = Value val Kickass, Afisha, Rutracker = Value }
Explain and rewrite the following Scala code:
package com.github.pedrovgs.haveaniceday.extensions import java.util.Date import org.joda.time.DateTime object date { implicit def asDateTime(date: Date) = new DateTime(date.getTime) implicit def asDate(dateTime: DateTime) = dateTime.toDate }
Explain and rewrite the following Scala code:
package sky.supervisor.example3 import akka.actor.{ActorRef, Props, ActorSystem} /** * Created by szekai on 19/08/2014. */ case class Result() case class DeadWorker() case class RegisterWorker(val worker: ActorRef, val supervisor: ActorRef) object MyActorSystem { def main(args: Array[String]): Unit = { val sy...
Explain and rewrite the following Scala code:
package scala import ru.harati.scavel.d2.inline.Vec2d import ru.harati.scavel.d2.{Point2, Vec2} import ru.harati.scavel.d3.inline.Vec3d import ru.harati.scavel.d3.{AABB, Point3, Vec3} import utest._ /** * Creation date: 17.08.2016 * Copyright (c) harati */ object ScavelTests extends TestSuite { val tests = T...
Explain and rewrite the following Scala code:
package com.lunatic.mlx.kddcup99.mllib.modgen import com.lunatic.mlx.kddcup99._ import com.lunatic.mlx.kddcup99.mllib.Configuration import com.lunatic.mlx.kddcup99.mllib.transformers.InputAnalyzer import org.apache.spark.SparkContext import scala.io.Source /** * Analyse the input data and provide suggestions for ...
Explain and rewrite the following Scala code:
/* * Copyright (C) FuseSource, Inc. * http://fusesource.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by ...
Explain and rewrite the following Scala code:
package drt.shared object Ports { val domestic: Seq[PortCode] = Seq( "ABB", "ABZ", "ADV", "ADX", "AYH", "BBP", "BBS", "BEB", "BEQ", "BEX", "BFS", "BHD", "BHX", "BLK", "BLY", "BOH", "BOL", "BQH", "BRF", "BRR", "BRS", "BSH", "BUT", "BWF", "BWY", "BYT", "BZZ", "CAL", "CAX", "CBG", "CEG", "CHE", "CLB", "COL"...
Explain and rewrite the following Scala code:
/* * Copyright 2017 Datamountaineer. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed ...
Explain and rewrite the following Scala code:
/* * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distri...
Explain and rewrite the following Scala code:
import scala.quoted._ object Macros { def assertImpl(expr: Expr[Boolean])(using QuoteContext) = '{ if !($expr) then throw new AssertionError(s"failed assertion: ${$expr}") } }
Explain and rewrite the following Scala code:
package org.oneugene.join import org.scalatest.FlatSpec import org.scalatest.Matchers import org.scalatest.OptionValues import org.scalatest.prop.PropertyChecks /** * Contains sample code which shows how to use join api */ class JoinSamples extends FlatSpec with Matchers with OptionValues with PropertyChecks { ...
Explain and rewrite the following Scala code:
package controllers import javax.inject._ import play.api._ import play.api.mvc._ // imports for handling date import java.util.Calendar import java.util.Date import java.text.SimpleDateFormat /** * This controller creates an `Action` to handle HTTP requests to the * application's home page. */ @Singleton class H...
Explain and rewrite the following Scala code:
// Copyright: 2010 - 2016 https://github.com/ensime/ensime-server/graphs // Licence: http://www.gnu.org/licenses/gpl-3.0.en.html package org.ensime.sexp.formats import org.ensime.sexp._ // these are a sort of aggregated test, investigating behaviours of // interactions between the different formats. class DefaultSexp...
Explain and rewrite the following Scala code:
/* * Copyright 2017-2020 Aleksey Fomkin * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or ag...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ...
Explain and rewrite the following Scala code:
package worker object MainManyMasters extends Startup { def main(args: Array[String]): Unit = { val joinAddress = startBackend(None, "backend-shard1") Thread.sleep(5000) startBackend(Some(joinAddress), "backend-shard1") startWorker(joinAddress) Thread.sleep(5000) startFrontend(joinAddress) ...
Explain and rewrite the following Scala code:
package org.scalatest.concurrent import org.scalatest.time.{Span, Millis} /** * Trait that defines an abstract <code>patienceConfig</code> method that is implemented in <a href="PatienceConfiguration.html"><code>PatienceConfiguration</code></a> and can * be overriden in stackable modification traits such as <a hre...
Explain and rewrite the following Scala code:
package org.rbudzko.fundamentals.training import java.net.URL import akka.actor.{Actor, ActorSystem, Props} import akka.event.Logging import org.slf4j.LoggerFactory object CreatingActor extends App { val log = LoggerFactory.getLogger(CreatingActor.getClass) val system = ActorSystem() val scribe = system.actorO...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2005, The Beangle Software. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This...
Explain and rewrite the following Scala code:
package io.buoyant.linkerd.protocol.http.istio import com.twitter.finagle.http.{Request, Response, Status} import com.twitter.util.Future import io.buoyant.k8s.istio.identifiers.IstioProtocolSpecificRequestHandler import io.buoyant.linkerd.protocol.http.ErrorResponder.HttpResponseException import istio.proxy.v1.config...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
package sharry.backend.share import sharry.common._ import sharry.store.records.RShare case class ShareItem( share: RShare, published: Option[ShareItem.PublishSummary], alias: Option[ShareItem.AliasInfo], files: ShareItem.FileSummary ) object ShareItem { case class FileSummary(count: Int, size: By...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
import sbt._ import Keys._ import play.Project._ import com.typesafe.config._ object ApplicationBuild extends Build { val conf = ConfigFactory.parseFile(new File("conf/application.conf")).resolve() val appName = conf.getString("application.name") println("DEBUG: found application name: " + appName) val ...
Explain and rewrite the following Scala code:
package dk.gp.cogp.svi import java.io.File import org.junit._ import org.junit.Assert._ import breeze.linalg._ import dk.gp.cogp.lb._ import dk.gp.cogp.testutils.createCogpToyModel import dk.gp.cov.CovFunc import dk.gp.cogp.testutils._ class stochasticUpdateVTest { @Test def test_5_data_points = { val data ...
Explain and rewrite the following Scala code:
package net.manub.embeddedkafka class KafkaUnavailableException(msg: String, cause: Throwable) extends RuntimeException(msg, cause) { def this(msg: String) = this(msg, null) def this(cause: Throwable) = this(null, cause) } class KafkaSpecException(msg: String) extends RuntimeException(msg)
Explain and rewrite the following Scala code:
/* * Copyright 2001-2013 Artima, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agre...
Explain and rewrite the following Scala code:
/** * @author Yuuto */ package yuuto.enhancedinventories.client.renderer.model import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; import net.minecraft.util.Vec3; class ModelIconCube { protected var hideFace:Array[Boolean] = new Array[Boolean](6); var lightValue:Int = 15; ...
Explain and rewrite the following Scala code:
package crm import scala.language._ import scala.util.control.Exception._ import scopt._ import org.w3c.dom._ import dispatch._ import scala.concurrent.Await import scala.concurrent.duration._ import scala.async.Async._ import scala.util._ import org.log4s._ import com.lucidchart.open.xtract.{ XmlReader, _ } import Xm...
Explain and rewrite the following Scala code:
package sri.sangria.mongoserver.graphql import reactivemongo.bson.BSONObjectID import sangria.relay.Connection import sangria.schema.WithArguments import sri.sangria.mongoserver.models.{Todo, User} import sri.sangria.mongoserver.services.TodoService import scala.concurrent.ExecutionContext.Implicits.global import sca...
Explain and rewrite the following Scala code:
package ml.example import ml._ import org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS import org.apache.spark.mllib.linalg.Vector import org.apache.spark.mllib.regression.LabeledPoint import org.apache.spark.sql.Row class LogisticRegression(override val id: String) extends Estimator { def this()...
Explain and rewrite the following Scala code:
package org.bitcoins.dlc.oracle.config import com.typesafe.config.Config import org.bitcoins.commons.config.AppConfigFactory import org.bitcoins.core.api.dlcoracle.db.EventOutcomeDbHelper import org.bitcoins.core.config._ import org.bitcoins.core.hd.HDPurpose import org.bitcoins.core.protocol.blockchain.{ BitcoinCha...
Explain and rewrite the following Scala code:
package shred.man.nn import shred.man.nn.layers.Layer import types._ class NN(layers: Seq[_ <: Layer]) { def apply(x: DMat): DMat = { var curr = x for (layer <- layers) { curr = layer(curr) } curr } }
Explain and rewrite the following Scala code:
/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); yo...
Explain and rewrite the following Scala code:
package example.herding.cats package foldleft // Typeclasses examples package ex1 { object FoldLeft extends App { def foldLeft[A, B](xs: List[A], b: B, f: (B, A) ⇒ B) = xs.foldLeft(b)(f) import ex3.{IntMonoid, Monoid} def sum[A: Monoid](xs: List[A]): A = { val m = implicitly[Monoid[A]] foldL...
Explain and rewrite the following Scala code:
// Copyright (c) 2013-2020 Rob Norris and Contributors // This software is licensed under the MIT License (MIT). // For more information see LICENSE or https://opensource.org/licenses/MIT package doobie /** * High-level database API. The constructors here are defined * in terms of those in `doobie.free.connection` ...
Explain and rewrite the following Scala code:
package controllers.iteratees // TODO rename package to "streams" import akka.stream.{Attributes,FlowShape,Inlet,Outlet} import akka.stream.stage._ import akka.util.ByteString /** Smooshes and slices input ByteStrings so output ByteStrings are all the same * length (except the final ByteString, which may be smaller...
Explain and rewrite the following Scala code:
/* Copyright 2012 Twitter, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
Explain and rewrite the following Scala code:
package org.scalatra package servlet import test.scalatest.ScalatraFunSuite class ServletContextAttributesTest extends ScalatraFunSuite with AttributesTest { addServlet(new AttributesServlet { def attributesMap = servletContext }, "/*") }
Explain and rewrite the following Scala code:
/* * Copyright 2015 Sanford Ryza, Uri Laserson, Sean Owen and Joshua Wills * * See LICENSE file for further information. */ package com.cloudera.datascience.risk import org.apache.spark.SparkContext._ import org.apache.spark.rdd.RDD import org.apache.spark.util.StatCounter import org.apache.commons.math3.util.Fas...
Explain and rewrite the following Scala code:
package views.html import play.templates._ import play.templates.TemplateMagic._ import play.api.templates._ import play.api.templates.PlayMagic._ import models._ import controllers._ import java.lang._ import java.util._ import scala.collection.JavaConversions._ import scala.collection.JavaConverters._ import play....
Explain and rewrite the following Scala code:
package scala.macros package semantic import scala.macros.internal.prettyprinters._ private[macros] trait Denotations { self: Universe => type Denotation >: Null <: AnyRef implicit def denotSyntaxInstance[T <: Denotation](implicit m: Mirror): Syntax[T] = { Syntax((p, x) => abstracts.denotSyntax(p, x)) } ...
Explain and rewrite the following Scala code:
package com.mesosphere.cosmos.rpc.v1.model import com.mesosphere.cosmos.finch.MediaTypedDecoder import com.mesosphere.cosmos.finch.MediaTypedRequestDecoder import com.mesosphere.cosmos.rpc.MediaTypes import io.circe.Decoder import io.circe.Encoder import io.circe.generic.semiauto.deriveDecoder import io.circe.generic....
Explain and rewrite the following Scala code:
package scala.collection.immutable import org.junit.Assert._ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 @RunWith(classOf[JUnit4]) class TreeMapTest { @Test def hasCorrectDropAndTakeMethods() { val tree = TreeMap(1 -> "a", 2 -> "b", 3 -> "c") assertEquals(TreeMa...
Explain and rewrite the following Scala code:
/* Copyright 2012 Twitter, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
Explain and rewrite the following Scala code:
package me.bowdon.ddldiff import me.bowdon.ddldiff.ast._ /** MigrationGenerator converts Migrations to DDL statements * * Main method here is "generate" to actually output the DDL statement Strings. * Accompanying methods are "show*" to print bits of AST back to SQL Strings. * (Preferring not to override toString...
Explain and rewrite the following Scala code:
/* * Copyright 2014 The SIRIS Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applica...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.failed.typeInference import org.jetbrains.plugins.scala.PerfCycleTests import org.jetbrains.plugins.scala.base.libraryLoaders.{ScalaZCoreLoader, ThirdPartyLibraryLoader} import org.jetbrains.plugins.scala.lang.typeInference.TypeInferenceTestBase import org.junit.experimental.categor...
Explain and rewrite the following Scala code:
package akka.guice.annotation.test.examples import akka.actor.{Actor, ActorLogging} import akka.guice.annotation.injectableActor /** * This example shows off creating Actors with parameters. * * @param func A function that will determine the value replied when * sent a GetValue() message. */ @in...
Explain and rewrite the following Scala code:
/* * Copyright 2012-2013 Eligotech BV. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed ...
Explain and rewrite the following Scala code:
package de.leanovate.swaggercheck.schema.model.formats import de.leanovate.swaggercheck.schema.model.{JsonPath, ValidationResult} object NumberFormats { object FloatNumber extends ValueFormat[BigDecimal] { override def validate(path: JsonPath, value: BigDecimal): ValidationResult = { if (value.isDecimalD...
Explain and rewrite the following Scala code:
/* * Copyright 2001-2013 Artima, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agre...
Explain and rewrite the following Scala code:
package samples.scalaexchange.step8 import akka.actor.ActorSystem import akka.http.scaladsl.Http import akka.http.scaladsl.marshallers.sprayjson.SprayJsonStreamingSupport import akka.http.scaladsl.model._ import akka.http.scaladsl.server.Directives import akka.http.scaladsl.server.directives.EntityStreamingDirectives ...
Explain and rewrite the following Scala code:
package org.flowpaint.renderer.packedsurface import java.awt.{Color, Graphics} import org.flowpaint.property.Data import org.flowpaint.pixelprocessor.ScanlineCalculator import org.flowpaint.util.DataSample import org.flowpaint.renderer.PictureProvider /** * A Surface that provides run length encoded packing of the...
Explain and rewrite the following Scala code:
/* * Copyright 2017-2018 Azad Bolour * Licensed under GNU Affero General Public License v3.0 - * https://github.com/azadbolour/boardgame/blob/master/LICENSE.md */ package com.bolour.boardgame.scala.server.domain import com.bolour.plane.scala.domain.Axis.Axis import com.bolour.boardgame.scala.server.domain.GameE...
Explain and rewrite the following Scala code:
package kr.ac.kaist.ir.deep.layer import kr.ac.kaist.ir.deep.fn._ import play.api.libs.json.JsObject /** * __Layer__ : Reconstructable Basic Layer * * @param IO is a pair of input & output, such as 2 -> 3 * @param act is an activation function to be applied * @param w is initial weight matrix for the case that i...
Explain and rewrite the following Scala code:
/* * Copyright 2017 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2009-2017 Lightbend Inc. <https://www.lightbend.com> */ package play.api.libs.streams import java.util.Optional import java.util.concurrent.CompletionStage import akka.stream.Materializer import akka.stream.scaladsl.{ Flow, Keep, Sink, Source } import scala.compat.java8.FutureConverters import s...
Explain and rewrite the following Scala code:
package connectors.misp import javax.inject.{Inject, Singleton} import scala.concurrent.duration.{Duration, DurationInt, FiniteDuration} import scala.util.Try import play.api.{Configuration, Logger} import com.typesafe.config.ConfigMemorySize import services.CustomWSAPI @Singleton class MispConfig(val interval: Fin...
Explain and rewrite the following Scala code:
package com.ebay.neutrino.channel import java.net.SocketAddress import com.ebay.neutrino.channel.NeutrinoPipelineChannel.ChannelState import com.ebay.neutrino.metrics.Instrumented import com.typesafe.scalalogging.slf4j.StrictLogging import io.netty.channel._ import io.netty.util.{Attribute, AttributeKey, ReferenceCou...
Explain and rewrite the following Scala code:
package models case class User(email: String, password: String, firstName: String, lastName: String, facebook: String, google: String, github: String, foursquare: String, linkedin: String, ...
Explain and rewrite the following Scala code:
package org.velvia.filo import org.openjdk.jmh.annotations.Benchmark import org.openjdk.jmh.annotations.BenchmarkMode import org.openjdk.jmh.annotations.{Mode, State, Scope} import org.openjdk.jmh.annotations.OutputTimeUnit import scalaxy.loops._ import scala.language.postfixOps import java.util.concurrent.TimeUnit ...
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
/* * Copyright (C) 2014 Cathal Mc Ginley * * This file is part of TomatoJuice, a Pomodoro timer-tracker for GNOME. * * TomatoJuice is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published * by the Free Software Foundation; either version 3 of the...
Explain and rewrite the following Scala code:
package backend import akka.actor._ import akka.cluster.Cluster import akka.util.Timeout import asobu.distributed.protocol.Prefix import asobu.distributed.{EndpointsRegistry, DefaultEndpointsRegistry} import asobu.distributed.service._ import backend.endpoints.AMixedController import backend.school.StudentService impo...
Explain and rewrite the following Scala code:
package scala.collection import scala.util.Try import org.scalacheck.{Arbitrary, Gen, Properties, Shrink} import org.scalacheck.Test.Parameters import org.scalacheck.Prop._ object FloatFormatTest extends Properties("FloatFormat") { import StringParsers._ val genDec = for { sign <- Gen.oneOf("", "+", "-") ...
Explain and rewrite the following Scala code:
package org.scalawebtest.integration.json import org.scalawebtest.integration.ScalaWebTestBaseSpec import play.api.libs.json.Json class ReducedJsonSpec extends ScalaWebTestBaseSpec { path = "/jsonResponse.json.jsp" def json = Json.parse(webDriver.getPageSource) "Dijkstra" should "have the correct firstname" in...
Explain and rewrite the following Scala code:
package aims.cqrs import aims.core.Restlet import aims.core.RestletResult._ import aims.model.Event import aims.routing.PatternMatcher import aims.util.Tuples import akka.http.model.HttpMethods._ import akka.http.model.StatusCodes._ import akka.http.model.{ HttpMethod, HttpResponse } /** * Component: * Description:...
Explain and rewrite the following Scala code:
package com.humbinal.normandie.rest.bean import scala.beans.BeanProperty class Person(private val _age: Int, val _name: String) { @BeanProperty val age: Int = _age @BeanProperty val name: String = _name override def toString: String = return new String("name:" + name + ",age:" + age) }
Explain and rewrite the following Scala code:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
Explain and rewrite the following Scala code:
package rta.model.triggers import android.net.wifi.WifiManager import enumeratum.Enum import rta.common.{action, category} import rta.model._ trait WiFiModels { @category("wifi") sealed abstract class WiFi(companion: ModelCompanion[WiFi]) extends Model[WiFi](companion) @action(WifiManager.WIFI_STATE_CHANGED_AC...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.lang.psi.types import com.intellij.psi.PsiTypeParameter import org.jetbrains.plugins.scala.project.ProjectContext /** * @author adkozlov */ package object api { implicit class TypeParametersArrayExt(private val typeParameters: Array[TypeParameter]) extends AnyVal { def d...
Explain and rewrite the following Scala code:
package com.ox.bigdata.util.kafka import com.ox.bigdata.util.log.LogSupport import org.apache.zookeeper.ZooDefs.Ids import org.apache.zookeeper.ZooKeeper.States import org.apache.zookeeper._ object SimpleUtils extends LogSupport { private def wait(zk: ZooKeeper) { if (zk != null) { var isConnected = fal...
Explain and rewrite the following Scala code:
package activetag.dom.structure /** * Created by ppremont on 2/1/2014. */ sealed trait NodeStructure case class TextStructure(text: String) extends NodeStructure case class ElementStructure(name: String, attributes: List[(String, String)], childNodes: List[NodeStructure]) extends NodeStructure
Explain and rewrite the following Scala code:
/* * Copyright 2016 The BigDL Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agr...
Explain and rewrite the following Scala code:
/* This file is part of scala-conduit. scala-conduit is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. scala-c...
Explain and rewrite the following Scala code:
package com.twitter.finagle.dispatch import com.twitter.conversions.time._ import com.twitter.finagle.stats.InMemoryStatsReceiver import com.twitter.finagle.transport.Transport import com.twitter.finagle.{Failure, WriteException} import com.twitter.util._ import org.junit.runner.RunWith import org.mockito.Matchers._ i...
Explain and rewrite the following Scala code:
/** * Copyright (C) 2011 Orbeon, Inc. * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU Lesser General Public License as published by the Free Software Foundation; either version * 2.1 of the License, or (at your option) any later version. * * This program i...