instruction
stringclasses
1 value
output
stringlengths
5
1M
Explain and rewrite the following Scala code:
/* * AutoViewImpl.scala * (GUIFlitz) * * Copyright (c) 2013-2021 Hanns Holger Rutz. All rights reserved. * * This software is published under the GNU Lesser General Public License v2.1+ * * For further information, please contact Hanns Holger Rutz at * contact@sciss.de */ package de.sciss.guiflitz pack...
Explain and rewrite the following Scala code:
package edu.uwm.cs.pir.utils import org.scalatest.FunSuite import org.scalatest.BeforeAndAfter import org.scalatest.junit.JUnitRunner import org.junit.runner.RunWith import edu.uwm.cs.pir.utils.AWSS3API.AWSS3Config import edu.uwm.cs.mir.prototypes.utils.Utils import java.io.ByteArrayInputStream import java.io.InputS...
Explain and rewrite the following Scala code:
package notebook.io import java.nio.file.Path import notebook.Notebook import scala.concurrent.ExecutionContext.Implicits.global import org.scalatest.concurrent.ScalaFutures import org.scalatest.time.{Millis, Seconds, Span} import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpec} import play.api.libs.json.{JsNum...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2015 by its authors. Some rights reserved. * See the project homepage at: http://www.monifu.org * * 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://...
Explain and rewrite the following Scala code:
package extruder.map import extruder.core.Decode import extruder.data.Validation trait MapDecoder extends Decode { self: MapDataSource => override type InputData = Map[String, String] override type DecodeData = Map[String, String] override type DecodeDefault[A] = Validation[A] }
Explain and rewrite the following Scala code:
object Test extends dotty.runtime.LegacyApp { import scala.collection.mutable.DoubleLinkedList empty builder_1 builder_2 chaining_1 chaining_2 insert_1 insert_2 append_1 append_2 def empty: Unit = { val none = DoubleLinkedList() require(none.size == 0) none.foreach( _ => require(fals...
Explain and rewrite the following Scala code:
/* * Copyright 2001-2014 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 org.jetbrains.plugins.scala.components.libextensions import org.jetbrains.plugins.scala.components.ScalaPluginVersionVerifier.Version import scala.collection.immutable.ArraySeq import scala.language.postfixOps import scala.xml.{Elem, XML} @SerialVersionUID(1L) case class ExtensionDescriptor(interface: String...
Explain and rewrite the following Scala code:
package linkchecker.distribution import akka.actor.Actor import scala.concurrent.duration._ import akka.actor.ReceiveTimeout import akka.actor.ActorSystem import akka.actor.Props import akka.cluster.Cluster import akka.cluster.ClusterEvent import akka.actor.ActorLogging import akka.actor.RootActorPath import akka.acto...
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 xsbt import dotty.tools.dotc._ import core.Contexts._ class TestDriver extends Driver { override protected def sourcesRequired = false def getCompiler(args: Array[String], rootCtx: Context) = { val (fileNames, ctx) = setup(args, rootCtx) (newCompiler(ctx), ctx) } }
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 not u...
Explain and rewrite the following Scala code:
/* * The MIT License (MIT) * * Copyright (c) 2014 MineFormers * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, ...
Explain and rewrite the following Scala code:
sealed trait Nat case class S(n: Nat) extends Nat case object Z extends Nat inline def pred(n: Nat) = inline n match { case S(m) => m case Z => compiletime.error("n cannot be Z") } class Test { pred(S(Z)) }
Explain and rewrite the following Scala code:
/* * Copyright 2014–2017 SlamData 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 agr...
Explain and rewrite the following Scala code:
/* * Copyright 2015 Tarık Yılmaz * * 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...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2021 by The Monix Project Developers. * See the project homepage at: https://monix.io * * 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...
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 kr.scala.experiments.tests.akka import akka.actor.{Props, ActorSystem, Actor} import kr.scala.experiments.tests.AbstractExperimentTest /** * ActorSample * @author Sunghyouk Bae */ class ActorSample extends AbstractExperimentTest { test("HelloActor") { val system = ActorSystem("AkkaSystem") ...
Explain and rewrite the following Scala code:
/* * Bioinformatics Algorithms in Scala * Copyright (C) 2016 Jason Mar * * This program 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 License, or * (at your option) any later ...
Explain and rewrite the following Scala code:
package sangria.validation.rules import sangria.ast import sangria.ast.AstVisitorCommand._ import sangria.renderer.{QueryRenderer, SchemaRenderer} import sangria.validation._ /** * Known argument names * * A GraphQL field is only valid if all supplied arguments are defined by * that field. */ class KnownArgument...
Explain and rewrite the following Scala code:
package dsentric.util class StringContextOps(val sc: StringContext) extends AnyVal { def i = IgnoreCaseMatcher(sc.raw()) } case class IgnoreCaseMatcher(value:String) { def unapply(s:String):Boolean = value.equalsIgnoreCase(s) } trait ToStringContextOps { implicit def toIgnoreCase(sc:StringContext):String...
Explain and rewrite the following Scala code:
/* * Scala (https://www.scala-lang.org) * * Copyright EPFL and Lightbend, Inc. * * Licensed under Apache License 2.0 * (http://www.apache.org/licenses/LICENSE-2.0). * * See the NOTICE file distributed with this work for * additional information regarding copyright ownership. */ package scala.tools package re...
Explain and rewrite the following Scala code:
package controllers import javax.inject._ import play.api._ import play.api.mvc._ import play.filters.csrf._ class Application @Inject() extends Controller { def logout = Action { implicit request => Ok("Bye").withNewSession } }
Explain and rewrite the following Scala code:
/* * (c) Copyright 2016 Hewlett Packard Enterprise Development LP * * 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 b...
Explain and rewrite the following Scala code:
package controllers.support import play.api.Play.current import play.api.db.slick.Config.driver.simple.Session import play.api.db.slick.DB import play.api.mvc.{AnyContent, Result} import securesocial.core.{Authorization, SecureSocial, SecuredRequest} import service.Login trait SecureSocialDB extends SecureSocial { ...
Explain and rewrite the following Scala code:
package uk.gov.homeoffice.io import java.io.{FileNotFoundException, InputStream, IOException, File} import java.net.URL import scala.io.Codec import scala.io.Source._ import scala.util.{Success, Failure, Try} /** * Read resource */ trait IO { /** * Acquire resource as input stream from class path * @par...
Explain and rewrite the following Scala code:
package io.buoyant.linkerd.protocol import com.twitter.finagle.http.{Request, Status} import io.buoyant.linkerd.Linker import io.buoyant.linkerd.tls.TlsUtils import io.buoyant.test.FunSuite import java.net.InetSocketAddress class ClientAuthTest extends FunSuite { test("client auth") { TlsUtils.withCerts("clien...
Explain and rewrite the following Scala code:
package nl.malienkolders.htm.lib.util import scala.sys.SystemProperties import java.awt.Desktop import java.net.URI import java.net.NetworkInterface import java.net.InetAddress import java.util.Hashtable import com.google.zxing.EncodeHintType import com.google.zxing.qrcode.QRCodeWriter import com.google.zxing.qrcode.d...
Explain and rewrite the following Scala code:
package controllers import play.api.libs.Crypto import play.api.mvc.{Request, Action, Controller} import utils.WunderAPI import scala.concurrent.Future import scala.util.{Try, Random} object Tasks extends Controller with WunderAPI with ListsAPIWrappers { import utils._ import play.api.libs.concurrent.Execution.I...
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s.searches.aggs import com.sksamuel.elastic4s.ScriptBuilder import org.elasticsearch.search.aggregations.AggregationBuilders import org.elasticsearch.search.aggregations.bucket.range.RangeAggregationBuilder import scala.collection.JavaConverters._ object RangeAggregationBuilder { def ...
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 2013 - 2020 Outworkers Ltd. * * 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...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala package lang.types.existentialSimplification import java.io.File import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.{CharsetToolkit, LocalFileSystem} import com.intellij.psi.util.PsiTreeUtil import org.jetbr...
Explain and rewrite the following Scala code:
package com.twitter.jvm import scala.util.Random /** * An estimator for values of type T. */ trait Estimator[T] { /** A scalar measurement `m` was taken */ def measure(m: T) /** Estimate the current value */ def estimate: T } /** * A simple Kalman filter to estimate a scalar value. */ class Kalman(N: In...
Explain and rewrite the following Scala code:
/* __ *\\ ** ________ ___ / / ___ Scala API ** ** / __/ __// _ | / / / _ | (c) 2003-2010, LAMP/EPFL ** ** __\\ \\/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\\___/_/...
Explain and rewrite the following Scala code:
package io.youi.stream sealed trait Tag object Tag { case class Open(tagName: String, attributes: Map[String, String], start: Int, end: Int, close: Option[Close]) extends Tag case class Close(tagName: String, start: Int, end: Int) extends Tag }
Explain and rewrite the following Scala code:
package benchmarks import zio.prelude._ import zio.test._ import spire.implicits._ //import spire.math._ import Benchmarks._ import Generators._ object BenchmarkTests extends DefaultRunnableSpec { val zero3 = NonEmptyList(0.0, 0.0, 0.0) // val epsilon = 1e-15 // def epsilonF(precision: Double) = 1.0 / (10.0...
Explain and rewrite the following Scala code:
package com.chobostudy.loustler.datastructure import com.chobostudy.datastructure.{ListFactory, List} /** * @author loustler * @since 08/18/2017 20:22 */ trait SolutionP51 extends ListFactory with ListUtil {} object SolutionP51 extends ListFactory with SolutionP51 {}
Explain and rewrite the following Scala code:
package cpup.mc.testMod.content import net.minecraft.client.renderer.texture.IIconRegister import net.minecraft.init.Items import net.minecraft.item.{ItemSword, Item, EnumAction, ItemStack} import net.minecraft.world.World import net.minecraft.entity.player.EntityPlayer import net.minecraftforge.event.entity.player.{A...
Explain and rewrite the following Scala code:
/* * Copyright 2018 CJWW Development * * 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 agree...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.cbt.project import com.intellij.openapi.externalSystem.service.settings.AbstractImportFromExternalSystemControl import com.intellij.openapi.fileChooser.FileChooserDescriptor import com.intellij.openapi.project.ProjectManager import org.jetbrains.plugins.cbt.project.settings._ import org.j...
Explain and rewrite the following Scala code:
object Test { class Foo(val name: String, val children: Int *) object Foo { def unapply(f: Foo) = Some((f.name, f.children)) } def foo(f: Foo) = f match { case Foo(name, cs *) => name :: cs.reverse.toList.map(_.toString) } def main(args: Array[String]) = { println(foo(new Foo("hi", 1, 2, 3)).mk...
Explain and rewrite the following Scala code:
package jp.pigumer.sbt.cloud.aws.cloudformation import sbt.File import com.amazonaws.auth.{AWSCredentialsProviderChain, DefaultAWSCredentialsProviderChain} case class AwscfSettings(region: String = "us-east-1", bucketName: Option[String] = None, projectName: String =...
Explain and rewrite the following Scala code:
package dotty.tools.dotc package transform import core._ import TreeTransforms._ import Contexts.Context import Flags._ import SymUtils._ import Symbols._ import SymDenotations._ import Types._ import Decorators._ import DenotTransformers._ import StdNames._ import NameOps._ import ast.Trees._ import dotty.tools.dotc....
Explain and rewrite the following Scala code:
package com.atomist.rug.ts import _root_.java.io.File import com.atomist.param.SimpleParameterValues import com.atomist.rug.compiler.typescript.TypeScriptCompiler import com.atomist.rug.compiler.typescript.compilation.CompilerFactory import com.atomist.source.{ArtifactSource, FileArtifact, FileEditor} import com.atom...
Explain and rewrite the following Scala code:
/** * Copyright 2015 Thomson Reuters * * 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:
package lila.insight import reactivemongo.api.bson._ import lila.db.dsl._ import lila.db.AsyncColl import lila.rating.BSONHandlers.perfTypeIdHandler import lila.rating.PerfType final private class Storage(val coll: AsyncColl)(implicit ec: scala.concurrent.ExecutionContext) { import Storage._ import BSONHandlers...
Explain and rewrite the following Scala code:
package com.wavesplatform.lang.v1 import cats.syntax.either._ import com.wavesplatform.lang.ValidationError.ScriptParseError import com.wavesplatform.lang.contract.meta.{FunctionSignatures, MetaMapper, ParsedMeta} import com.wavesplatform.lang.contract.{ContractSerDe, DApp} import com.wavesplatform.lang.directives.val...
Explain and rewrite the following Scala code:
package com.twitter.inject.thrift.integration.serviceperendpoint import com.twitter.finagle.Filter import com.twitter.finagle.Service import com.twitter.test.thriftscala.EchoService.Echo import com.twitter.util.logging.Logging class EchoFilter extends Filter[Echo.Args, Echo.SuccessType, Echo.Args, Echo.SuccessTyp...
Explain and rewrite the following Scala code:
package collins.controllers import scala.concurrent.Future import scala.concurrent.duration._ import akka.util.Timeout import play.api.mvc.Result import play.api.test.{Helpers => TestHelper} object Extract { def from(r: Future[Result]): (Int, Map[String,String], String) = { implicit val timeout = Timeout(5 sec...
Explain and rewrite the following Scala code:
package org.http4s.client.oauth1 import org.http4s._ import org.http4s.client.oauth1 import org.http4s.util.CaseInsensitiveString import org.specs2.mutable.Specification import scalaz.\\/- class OAuthTest extends Specification { // some params taken from http://oauth.net/core/1.0/#anchor30, others from // http:...
Explain and rewrite the following Scala code:
package sbt package logic import org.scalacheck._ import Prop.secure import Logic.{ LogicException, Matched } object LogicTest extends Properties("Logic") { import TestClauses._ property("Handles trivial resolution.") = secure(expect(trivial, Set(A))) property("Handles less trivial resolution.") = secure(expec...
Explain and rewrite the following Scala code:
package org.jetbrains.sbt package annotator import com.intellij.lang.annotation.{AnnotationHolder, Annotator} import com.intellij.psi.{PsiComment, PsiElement, PsiWhiteSpace} import org.jetbrains.annotations.NonNls import org.jetbrains.plugins.scala.annotator.ScalaAnnotationHolder import org.jetbrains.plugins.scala.ann...
Explain and rewrite the following Scala code:
package example import io.circe.generic.semiauto._ import io.circe.syntax._ import io.circe.{Decoder, Encoder, Json} case class Response(rid: String, status: Int, error: String) object Response { implicit val encoder: Encoder[Response] = new Encoder[Response] { final def apply(a: Response): Json = Json.obj( ...
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:
/* * 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 2011-2022 GatlingCorp (https://gatling.io) * * 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 appli...
Explain and rewrite the following Scala code:
package scala.meta.tests package contrib import munit.FunSuite import scala.meta._ import scala.meta.contrib._ class ModExtractionTest extends FunSuite { test("Test extract class mods with no mods") { val mods = q"class Foo".extract[Mod] assert(mods == Nil) } test("Test extract class mods with mods") {...
Explain and rewrite the following Scala code:
package play.api.mvc.request /** * A cell represents a memory location that stores a value. The cell abstracts * away the details of how the value is stored. For example, an [[AssignedCell]] * stores a simple value, whereas a [[LazyCell]] only calculates the value when * it is first needed. */ trait Cell[+A] { ...
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:
/* * 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 not u...
Explain and rewrite the following Scala code:
package sectery import org.slf4j.LoggerFactory import zio.ZIO object Runtime: def catchAndLog[R, E, A]( z: ZIO[R, E, A], orElse: => A ): ZIO[R, Nothing, A] = z.catchAllCause { cause => LoggerFactory .getLogger(this.getClass()) .error(cause.prettyPrint) ZIO.succeed(orEl...
Explain and rewrite the following Scala code:
package models import java.sql.Connection case class UpdateCategoryNameTable( categoryNames: Seq[UpdateCategoryName] ) { def save()(implicit conn: Connection) { categoryNames.foreach { _.save() } } } case class UpdateCategoryName( categoryId: Long, localeId: Long, name: String )( implicit cat...
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 org.jetbrains.plugins.scala.lang.parameterInfo.functionParameterInfo package generated class FunctionParameterInfoSimpleTest extends FunctionParameterInfoTestBase { //This class was generated by build script, please don't change this override def folderPath: String = super.folderPath + "simple/" def t...
Explain and rewrite the following Scala code:
package es.weso.rdf.validator.jena import org.scalatest._ import util._ import es.weso.rdf.jena.RDFAsJenaModel import es.weso.rdf.nodes.RDFNode import es.weso.rdf.nodes.IRI import es.weso.shex.Label import es.weso.rdf.parser._ import es.weso.utils.JenaUtils import es.weso.utils.Parsed import es.weso.utils.NotParsed ...
Explain and rewrite the following Scala code:
package com.teambytes.inflatable.raft.config import akka.actor.{ExtendedActorSystem, ExtensionIdProvider, ExtensionId} private[inflatable] object RaftConfiguration extends ExtensionId[RaftConfig] with ExtensionIdProvider { def lookup() = RaftConfiguration def createExtension(system: ExtendedActorSystem): RaftCo...
Explain and rewrite the following Scala code:
package com.github.sorhus.webalytics.akka import java.util.concurrent.TimeUnit import akka.NotUsed import akka.actor.{ActorRef, ActorSystem} import akka.stream.ActorMaterializer import akka.http.scaladsl.Http import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport import akka.http.scaladsl.server.Directives ...
Explain and rewrite the following Scala code:
object Main { def main(args: Array[String]): Unit = { val t1 = HuffmanCode.getSampleTree(); val enc1 = HuffmanCode.encode(t1)(StringUtils.string2Chars("abd")); println(enc1); println(HuffmanCode.quickEncode(t1)(StringUtils.string2Chars("abd"))) println(HuffmanCode.decodedSecret); } }
Explain and rewrite the following Scala code:
package BIDMach.models import BIDMat.{Mat,SBMat,CMat,DMat,FMat,IMat,HMat,GMat,GIMat,GSMat,SMat,SDMat} import BIDMat.MatFunctions._ import BIDMat.SciFunctions._ import BIDMach.datasources._ import BIDMach.updaters._ import BIDMach._ /** * Latent Dirichlet Model using repeated Gibbs sampling. * * This ve...
Explain and rewrite the following Scala code:
// Jubatus: Online machine learning framework for distributed environment // Copyright (C) 2014-2015 Preferred Networks and Nippon Telegraph and Telephone Corporation. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License version 2.1...
Explain and rewrite the following Scala code:
/* * Copyright (C) Lightbend Inc. <https://www.lightbend.com> */ package scalaguide.forms.scalaforms { import javax.inject.Inject import java.net.URL import play.api.Configuration import play.api.Environment import play.api.i18n._ import scalaguide.forms.scalaforms.controllers.routes import play.api...
Explain and rewrite the following Scala code:
package utils import akka.actor.Actor import akka.actor.ActorLogging import org.joda.time.DateTime import play.api._ import Play.current import models.Dump import models.Tag import models.Bucket import play.cache.Cache case class CleanUp() class CleanUpActor extends Actor { lazy val maxNumberOfDum...
Explain and rewrite the following Scala code:
package com.d_limitd.sample.sprayswagger.boot import com.typesafe.config.ConfigFactory object SampleConfig { private val config = ConfigFactory.load() object HttpConfig { private val httpConfig = config.getConfig("http") lazy val interface = httpConfig.getString("interface") lazy val port = httpConfi...
Explain and rewrite the following Scala code:
package almhirt.httpx.spray import org.scalatest._ import almhirt.httpx.spray.marshalling._ import almhirt.http.AlmhirtMediaTypeVendorProvider import almhirt.http.HasCommonAlmMediaTypesProviders import almhirt.http.VendorBasedCommonAlmMediaTypesProviders import almhirt.http.AlmCharacterEncoding class CommonC...
Explain and rewrite the following Scala code:
package com.cloudray.scalapress.plugin.form import javax.persistence.{FetchType, Column, ElementCollection, CascadeType, OneToMany, JoinColumn, ManyToOne, GenerationType, GeneratedValue, Id, Table, Entity} import com.cloudray.scalapress.item.Item import com.cloudray.scalapress.folder.Folder import scala.beans.BeanProp...
Explain and rewrite the following Scala code:
import java.net.InetAddress import java.util.Date import java.util.concurrent.SynchronousQueue import com.typesafe.scalalogging.Logger import io.netty.channel.{ChannelHandlerContext, SimpleChannelInboundHandler} /** * Created by larryf on 12/18/2016. * * Handles a client-side channel. * */ obje...
Explain and rewrite the following Scala code:
package io.youi.app import fabric.parse.Json import io.youi.ajax.AjaxRequest import io.youi.app.screen.ScreenManager import io.youi.app.sourceMap.ErrorTrace import io.youi.net._ import io.youi.storage.{LocalStorage, UniversalStorage} import io.youi.{History, JavaScriptError, JavaScriptLog} import org.scalajs.dom.{Erro...
Explain and rewrite the following Scala code:
package http import org.jboss.netty.handler.codec.http._ import com.twitter.util.{Await, Future} import com.twitter.finagle._ object HttpClient extends App { val client: Service[HttpRequest, HttpResponse] = Http.newService("localhost:8080") val request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod....
Explain and rewrite the following Scala code:
/* * #%L * MITH General Utilities * %% * Copyright (C) 2011 Maryland Institute for Technology in the Humanities * %% * 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://w...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014 Oculus Info Inc. * http://www.oculusinfo.com/ * * Released under the MIT License. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, includ...
Explain and rewrite the following Scala code:
package com.twitter.hello import com.codahale.metrics.MetricFilter import com.google.inject.Stage import com.twitter.finagle.metrics.MetricsStatsReceiver import com.twitter.finatra.http.test.EmbeddedHttpServer import com.twitter.inject.server.FeatureTest class HelloWorldStartupTest extends FeatureTest { override v...
Explain and rewrite the following Scala code:
package org.http4s.util import java.util.Locale import cats.Show import cats.kernel.laws.{GroupLaws, OrderLaws} import org.http4s.Http4sSpec import org.scalacheck.{Prop, Arbitrary, Gen} class CaseInsensitiveStringSpec extends Http4sSpec { "equals" should { "be consistent with equalsIgnoreCase of the values" in...
Explain and rewrite the following Scala code:
/** * Copyright (c) 2002-2012 "Neo Technology," * Network Engine for Objects in Lund AB [http://neotechnology.com] * * This file is part of Neo4j. * * Neo4j 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 Foundati...
Explain and rewrite the following Scala code:
package edu.gemini.model.p1.immutable import edu.gemini.model.p1.{mutable => M} import scala.collection.JavaConverters._ object Flamingos2BlueprintMos { def apply(m: M.Flamingos2BlueprintMos): Flamingos2BlueprintMos = new Flamingos2BlueprintMos(m) } case class Flamingos2BlueprintMos(disperser: Flamingos2Disper...
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 initialization import com.excilys.ebi.gatling.core.Predef._ import com.excilys.ebi.gatling.http.Predef._ import com.excilys.ebi.gatling.jdbc.Predef._ import com.excilys.ebi.gatling.http.Headers.Names._ import akka.util.duration._ import bootstrap._ class FullSimulationSecondaryPreferred extends Simulation { ...
Explain and rewrite the following Scala code:
/** * This code is generated using [[https://www.scala-sbt.org/contraband/ sbt-contraband]]. */ // DO NOT EDIT MANUALLY package sbt.internal.langserver /** Represents a location inside a resource, such as a line inside a text file. */ final class Location private ( val uri: String, val range: sbt.internal.langse...
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:
object Test { inline def h(x: Boolean) = if (x) 1 else "" val z = h(true) val zc: Int = z // error inline def g <: Any = 1 val y = g val yc: Int = y // OK inline def f: Any = 1 val x = f val xc: Int = x // error }
Explain and rewrite the following Scala code:
package com.crealytics import org.scalatest.Tag package object tags { object WIP extends Tag("com.crealytics.tags.WIP") }
Explain and rewrite the following Scala code:
package tyler.breakout import config.Configuration class BatGameState(pos: ImmutableVector2f, vel: ImmutableVector2f) extends MovableGameState(pos, vel) { override def left = pos.x override def right = pos.x + Configuration.batWidth override def top = pos.y override def bottom = pos.y + Configuration.batHeigh...
Explain and rewrite the following Scala code:
package dotty.tools.backend.jvm import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.junit.Test import scala.tools.asm.Opcodes._ import org.junit.Assert._ import ASMConverters._ class StringConcatTest extends DottyBytecodeTest { import ASMConverters._ @Test def appendOverloadNoBoxing():...
Explain and rewrite the following Scala code:
package com.ftchinese.jobs.ui import com.ftchinese.jobs.common.Logging import scala.collection.mutable /** * Task Queue * Created by wanbo on 16/3/23. */ object PushTaskQueue extends Serializable with Logging { val maxSize = 1 private val taskQueue = mutable.Queue[PushTask]() /** * Push a task ...
Explain and rewrite the following Scala code:
package com.socrata.datacoordinator.service.collocation import org.scalacheck.Gen import org.scalacheck.Prop.forAll import org.scalatest.{FunSuite, Matchers} class WeightedCostOrderingTest extends FunSuite with Matchers { test("A WeightedCostOrdering must have all non-negative parameters and movesWeight must be po...
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 com.twitter.finagle.memcached import _root_.java.lang.{Boolean => JBoolean, Long => JLong} import _root_.java.net.{InetSocketAddress, SocketAddress} import com.twitter.concurrent.Broker import com.twitter.conversions.time._ import com.twitter.finagle import com.twitter.finagle._ import com.twitter.finagle.buil...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2002-2018 "Neo Technology," * Network Engine for Objects in Lund AB [http://neotechnology.com] * * This file is part of Neo4j. * * Neo4j 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 Foundatio...
Explain and rewrite the following Scala code:
package me.hawkweisman.lsystems import me.hawkweisman.lsystems.turtle.Command /** * Created by hawk on 2/14/15. */ case class LSystem ( angle: Float, rules: Map[Char,String], commands: Map[Char,Command], start: String ) { def first: LSystemIteration = LSystemIteration(this,start,0) } case class LSystemIt...