instruction
stringclasses
1 value
output
stringlengths
5
1M
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:
/* * 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.github.mdr.mash.ns.core import com.github.mdr.mash.classes.{ Field, MashClass, NewStaticMethod } import com.github.mdr.mash.inference.Type object FieldAndValueClass extends MashClass("core.FieldAndValue") { object Fields { val Name = Field("name", Some("Field name"), Type.Any) val Value = Field...
Explain and rewrite the following Scala code:
package org.psliwa.idea.composerJson.intellij.codeAssist.composer import org.psliwa.idea.composerJson.ComposerBundle import org.psliwa.idea.composerJson.intellij.codeAssist.InspectionTest import org.psliwa.idea.composerJson.settings.{PatternItem, ProjectSettings} class PackageVersionInspectionTest extends InspectionT...
Explain and rewrite the following Scala code:
package com.twitter.finagle.kestrelx.integration import com.twitter.conversions.time._ import com.twitter.finagle.Service import com.twitter.finagle.builder.ClientBuilder import com.twitter.finagle.kestrelx.Server import com.twitter.finagle.kestrelx.protocol._ import com.twitter.io.Buf import com.twitter.util.{Await, ...
Explain and rewrite the following Scala code:
/* sbt -- Simple Build Tool * Copyright 2009, 2010 Mikko Peltonen, Stuart Roebuck, Mark Harrah */ package sbt import BasicCommandStrings.ClearOnFailure import State.FailureWall import annotation.tailrec import java.io.File import sbt.io.PathFinder import sbt.internal.io.{ SourceModificationWatch, WatchState } impo...
Explain and rewrite the following Scala code:
/* *\\ ** Squants ** ** ** ** Scala Quantities and Units of Measure Library and DSL ** ** (c) 2013-2015, G...
Explain and rewrite the following Scala code:
/** * Licensed to the Minutemen Group under one or more contributor license * agreements. See the COPYRIGHT file distributed with this work for * additional information regarding copyright ownership. * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in complian...
Explain and rewrite the following Scala code:
package razie.diesel /** gateway into diesel */ object Diesel { final val PAYLOAD = "payload" final val RESULT = "result" }
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 to...
Explain and rewrite the following Scala code:
package io.mpjsons.impl.factoryimpl import io.mpjsons.JsonTypeSerializer import io.mpjsons.impl.util.Context import scala.collection.immutable.Map import scala.reflect.runtime.universe._ /** * @author Marcin Pieciukiewicz */ class SerializerFactoryMemoizer extends SerializerFactoryImpl { private var getSeriali...
Explain and rewrite the following Scala code:
/* * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH * under one or more contributor license agreements. See the NOTICE file * distributed with this work for additional information regarding copyright * ownership. Camunda licenses this file to you under the Apache License, * Version 2.0; y...
Explain and rewrite the following Scala code:
package com.github.gdefacci.briscola.web package modules import com.github.gdefacci.briscola.player.PlayerId import com.github.gdefacci.briscola.web.util.{ WebSocketChannel, ServletPlan, ToPresentation } import com.github.gdefacci.briscola.presentation.competition.CompetitionPresentationAdapter import com.github.gde...
Explain and rewrite the following Scala code:
package edu.gemini.phase2.skeleton.factory import edu.gemini.model.p1.immutable.{ GnirsBlueprintSpectroscopy, AltairNGS, AltairNone, AltairLGS, Altair, GnirsBlueprintImaging} import edu.gemini.model.p1.mutable.{GnirsCentralWavelength, GnirsFpu, GnirsCrossDisperser, GnirsDisperser, GnirsFilter, GnirsPixelScale} import ...
Explain and rewrite the following Scala code:
package feh.tec.agentes.tarea1 import feh.tec.visual.{AppSurroundingSwingFrame, SwingNicolApp} import feh.tec.visual.api.{AppBasicControlApi, AgentApp} import feh.tec.agent.AgentDecision.CriteriaMessage import feh.tec.visual.util.AwtUtils import nicol.Scene /* class SwingTarea1 extends SwingNicolApp with LayoutDSLDef...
Explain and rewrite the following Scala code:
package models import java.sql.Connection case class ChangeCoupon(isCoupon: Boolean) { def update(itemId: ItemId)(implicit conn: Connection) { Coupon.update(itemId, isCoupon) } }
Explain and rewrite the following Scala code:
package org.oxbow.codebridge.ui.dialog import java.io.File import org.controlsfx.control.textfield.CustomTextField import org.oxbow.codebridge.ui.common.Glyphs import javafx.scene.Cursor import javafx.scene.control.ComboBox import javafx.scene.control.Label import javafx.scene.input.MouseEvent import javafx.scene.layo...
Explain and rewrite the following Scala code:
package edu.gemini.seqexec.server import java.util.concurrent.{ScheduledExecutorService, ScheduledThreadPoolExecutor} import java.util.concurrent.atomic.{AtomicBoolean, AtomicReference} import edu.gemini.pot.sp.SPObservationID import edu.gemini.seqexec.server.SeqexecFailure._ import edu.gemini.spModel.config2.{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:
/* * 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:
import java.util.concurrent.Executors import cats.effect.IO import scala.concurrent.ExecutionContext object PrintThread { def execute[A](block: => A): A = { print(s"[${Thread.currentThread().getName}] ") block } } object CatsEffect { def main(args: Array[String]): Unit = { val blockingService = Ex...
Explain and rewrite the following Scala code:
/** * Copyright (C) 2009-2011 the original author or authors. * See the notice.md file distributed with this work for additional * information regarding copyright ownership. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * Yo...
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:
//import java.io._ //import java.net._ //import java.awt._ //import java.awt.event._ //import javax.swing._ //import javax.swing.border._ //import javax.swing.event._ //import java.util._ // //import att.grappa._ // //class Grappa { // // val INSTANCES = "instances" // val SCRIPT = "formatDemo" // // val frame...
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 Normation SAS ************************************************************************************* * * This file is part of Rudder. * * Rudder is free software: you can redistribute it and/or modify * it under the...
Explain and rewrite the following Scala code:
package ammonite.terminal import java.io.OutputStreamWriter import ammonite.terminal.filters._ import GUILikeFilters.SelectionFilter import ammonite.terminal.LazyList.~: import scala.annotation.tailrec // Test Unicode: 漢語;𩶘da /** * A "full" test terminal including all readline-style functionality * included...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2020 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:
class Buffer { def f[@specialized(Int) T](): T = 0 match { case 0 => 0.asInstanceOf[T] case 1 => 0.asInstanceOf[T] } }
Explain and rewrite the following Scala code:
package openreveal /** * Created by Paul Lysak on 03.06.15. */ object Constants { val URI_PREFIX = "http://openreveal.org/data/" }
Explain and rewrite the following Scala code:
package kornell.server.api import com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException import javax.ws.rs._ import javax.ws.rs.core.{Context, SecurityContext} import kornell.core.entity.role.{RoleCategory, RoleType, Roles} import kornell.core.entity.{ChatThreadType, CourseClass} import kornell.co...
Explain and rewrite the following Scala code:
/* * ____ ____ _____ ____ ___ ____ * | _ \\ | _ \\ | ____| / ___| / _/ / ___| Precog (R) * | |_) | | |_) | | _| | | | | /| | | _ Advanced Analytics Engine for NoSQL Data * | __/ | _ < | |___ | |___ |/ _| | | |_| | Copyright (C) 2010 - 2013 SlamData, In...
Explain and rewrite the following Scala code:
package hedgehog import collection.mutable.Stack import org.scalatest._ class ExampleSpec extends FlatSpec with Matchers { "A Stack" should "pop values in last-in-first-out order" in { val stack = new Stack[Int] stack.push(1) stack.push(2) stack.pop() should be (2) stack.pop() should be (1) }...
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) 2017 HAT Data Exchange Ltd * SPDX-License-Identifier: AGPL-3.0 * * This file is part of the Hub of All Things project (HAT). * * HAT is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License * as published by the Free Software Founda...
Explain and rewrite the following Scala code:
import foo.barbaz.issue356._ import org.scalatest._ class NullValuesSpec extends FlatSpec with MustMatchers { val container = FooContainer() .withFoo(null) "null values" should "be None" in { container.foo must be (None) } }
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:
/* * Part of GDL book_api. * Copyright (C) 2017 Global Digital Library * * See LICENSE */ package io.digitallibrary.bookapi import java.time.{LocalDate, ZonedDateTime} import java.util.UUID import io.digitallibrary.bookapi.integration.crowdin.{BookMetaData, TranslatedChapter} import io.digitallibrary.bookapi.mo...
Explain and rewrite the following Scala code:
package com.deweyvm.gsudis trait OpPrinter { def print(parsed:ParsedOp):String } object OpPrinter { def padLeft(n:Int, s:String) = ("0"*n).substring(s.length) + s def reg(s:String) = "r" + Integer.parseInt(s, 16) def imm(s:String) = "#$" + padLeft(2, s) def imm4(a:String, b:String) = "#$" + padLeft(2, 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:
/* * Copyright (c) 2016 SnappyData, Inc. All rights reserved. * * 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 ap...
Explain and rewrite the following Scala code:
/* MET-API Copyright (C) 2014 met.no Contact information: Norwegian Meteorological Institute Box 43 Blindern 0313 OSLO NORWAY E-mail: met-api@met.no This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as publ...
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 almhirt.corex.spray.client import scala.reflect.ClassTag import scala.concurrent.duration._ import akka.actor._ import almhirt.common._ import almhirt.almvalidation.kit._ import almhirt.context._ import almhirt.akkax._ import almhirt.akkax.reporting._ import almhirt.akkax.reporting.Implicits._ import almhirt.h...
Explain and rewrite the following Scala code:
package com.twitter.finagle.http import org.junit.runner.RunWith import org.scalatest.FunSuite import org.scalatest.junit.JUnitRunner @RunWith(classOf[JUnitRunner]) class ParamMapTest extends FunSuite { test("no params") { val request = Request("/search.json") assert(request.params.get("q") == None) } ...
Explain and rewrite the following Scala code:
package com.mediapadtech.guestxp.models.common /** * This file is part of Guest eXPerience. * * Guest eXPerience 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...
Explain and rewrite the following Scala code:
package org.scalaide.core.internal.quickassist // Java imports import java.util.regex.Pattern /** * This object is used for applying code transformations based on the found and required type * extract from the annotation message (such as quick fix message) and the expression in the source code. * The object argume...
Explain and rewrite the following Scala code:
/* * Accio is a platform to launch computer science experiments. * Copyright (C) 2016-2018 Vincent Primault <v.primault@ucl.ac.uk> * * Accio 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...
Explain and rewrite the following Scala code:
package com.sksamuel.elastic4s.requests.searches.queries.term import com.sksamuel.elastic4s.EnumConversions import com.sksamuel.elastic4s.json.{XContentBuilder, XContentFactory} import com.sksamuel.elastic4s.requests.searches.queries.RegexQuery object RegexQueryBodyFn { def apply(q: RegexQuery): XContentBuilder = {...
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 ee.cone.c4gate_server import com.typesafe.scalalogging.LazyLogging import ee.cone.c4actor._ import ee.cone.c4assemble.Single import ee.cone.c4di.c4 @c4("SimpleMakerApp") final class SimpleMakerExecutable(execution: Execution, snapshotMaker: SnapshotMaker) extends Executable { def run(): Unit = { val raw...
Explain and rewrite the following Scala code:
package com.alanjz.meerkat.test class PerftTest { }
Explain and rewrite the following Scala code:
import scala.reflect.internal.util._ package bippity { trait DingDongBippy package bop { class Foo { class Bar object Bar } } } object Test { import bippity._ import bop._ def printSanitized(x: String) = println(x.filterNot(_.isDigit)) def main(args: Array[String]): Unit = { v...
Explain and rewrite the following Scala code:
package org.jetbrains.plugins.scala.lang.refactoring.extractMethod.duplicates import com.intellij.psi.PsiElement import org.jetbrains.plugins.scala.lang.psi.api.{ScalaPsiElement, ScalaRecursiveElementVisitor} import org.jetbrains.plugins.scala.lang.psi.api.expr.ScReferenceExpression import org.jetbrains.plugins.scala....
Explain and rewrite the following Scala code:
package fpinscala package parsing import ReferenceTypes._ import scala.util.matching.Regex object ReferenceTypes { /** A parser is a kind of state action that can fail. */ type Parser[+A] = ParseState => Result[A] /** `ParseState` wraps a `Location` and provides some extra * convenience functions. The sli...
Explain and rewrite the following Scala code:
package io.iohk.ethereum.network import java.net.URI import akka.actor.{ActorSystem, Props} import akka.testkit.TestProbe import com.miguno.akka.testing.VirtualTime import io.iohk.ethereum.blockchain.sync.EphemBlockchainTestSetup import io.iohk.ethereum.network.KnownNodesManager.KnownNodesManagerConfig import scala....
Explain and rewrite the following Scala code:
object sorting { def main(args: Array[String]) { // Put code here } }
Explain and rewrite the following Scala code:
/* Copyright (c) 2017 KAPSARC 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 dist...
Explain and rewrite the following Scala code:
package org.broadinstitute.clio.client.dispatch import akka.NotUsed import akka.stream.scaladsl.Source import cats.syntax.show._ import io.circe.Json import org.broadinstitute.clio.client.commands.MarkExternalCommand import org.broadinstitute.clio.client.util.IoUtil import org.broadinstitute.clio.client.webclient.Clio...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2018 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:
package org.jetbrains.plugins.scala package editor.todo import com.intellij.lexer.Lexer import com.intellij.psi.PsiFile import com.intellij.psi.impl.search.IndexPatternBuilder import com.intellij.psi.tree.{IElementType, TokenSet} import org.jetbrains.plugins.scala.lang.lexer.{ScalaLexer, ScalaTokenTypes} import org.je...
Explain and rewrite the following Scala code:
/* * Copyright (c) 2014-2020 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:
package pl.edu.agh.mplt.parser.AMPL.declarations import org.scalatest.{Matchers, FlatSpec} import pl.edu.agh.mplt.parser.{AMPLParser, IntercodeImplicits} import pl.edu.agh.mplt.parser.phrase.set._ import pl.edu.agh.mplt.parser.member.SetMember import pl.edu.agh.mplt.parser.reference.{IndexedReference, SimpleRefe...
Explain and rewrite the following Scala code:
package io.johnmurray.docem.module import io.johnmurray.docem.service._ import scaldi.Module /** * Defines simple binding for the repositories */ class ServiceModule extends Module { bind [ProjectService] to new ProjectServiceImpl }
Explain and rewrite the following Scala code:
// Fun with by name parameters def twice (block: => Unit) { block block } twice { println("Hello!") }
Explain and rewrite the following Scala code:
package com.geishatokyo.sqlgen.process.converter.csv import com.geishatokyo.sqlgen.core.{Sheet, Workbook} import com.geishatokyo.sqlgen.process._ /** * Created by takezoux2 on 2017/07/05. */ class SingleFileCSVConverterProc extends ConverterProc[String]{ override def dataKey = Key("single_file.csv") overrid...
Explain and rewrite the following Scala code:
package com.harpribot.corenlp_scala /** * Created by harshal on 1/12/17. */ import java.io.File import java.nio.charset.Charset import java.util.Properties import com.google.common.io.Files import edu.stanford.nlp.coref.CorefCoreAnnotations import edu.stanford.nlp.coref.data.CorefChain import edu.stanford.nlp.pip...
Explain and rewrite the following Scala code:
/* * Copyright 2012-2013 Stephane Godbillon (@sgodbillon) and Zenexity * * 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 req...
Explain and rewrite the following Scala code:
package ly.stealth.shaihulud.reader import java.io.{ByteArrayOutputStream, FileOutputStream, PrintStream} import java.security.MessageDigest import org.apache.hadoop.conf.Configuration import org.apache.hadoop.hbase.HBaseConfiguration import org.apache.hadoop.hbase.client.{Get, HTable, Result, Scan} import org.apache...
Explain and rewrite the following Scala code:
package io.buoyant.namer import com.twitter.conversions.DurationOps._ import com.twitter.util._ import io.buoyant.test.FunSuite class InstrumentedVarTest extends FunSuite { test("start, update, stop") { @volatile var running = false val updateP = new Promise[Int] val iv = InstrumentedVar(0) { up => ...
Explain and rewrite the following Scala code:
/** * Log analyzer and summary builder written in Scala built for JVM projects * * @package LogAnalyzer * @copyright Apache V2 License (see LICENSE) * @url https://github.com/mcross1882/LogAnalyzer */ package mcross1882.loganalyzer.analyzer /** * Analyzer trait matches predefined tokens against * the l...
Explain and rewrite the following Scala code:
package sorm.driver import embrace._ import sext._ import sorm.ddl._ import sorm.jdbc._ import sorm.sql.Sql class Postgres (protected val connection : JdbcConnection) extends DriverConnection with StdConnection with StdTransaction with StdAbstractSqlToSql with StdQuote with StdSqlRendering with StdState...
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 ch02 import scala.annotation.tailrec object Ex22Sorter { def isSorted[A](as: Array[A], ordered: (A, A) => Boolean): Boolean = { @tailrec def doIt(n: Int): Boolean = { if (n >= as.length - 1) true else if (ordered(as(n), as(n + 1))) false else doIt(n + 1) } doIt(0) } }
Explain and rewrite the following Scala code:
package com.trueaccord.scalapb.compiler import com.google.protobuf.Descriptors._ import com.google.protobuf.{CodedOutputStream, ByteString} import com.google.protobuf.compiler.PluginProtos.{CodeGeneratorRequest, CodeGeneratorResponse} import scala.collection.JavaConversions._ case class GeneratorParams(javaConversion...
Explain and rewrite the following Scala code:
package com.mz.training.domains.user import akka.actor.{ActorRef, ActorSystem} import com.mz.training.common.jdbc.JDBCConnectionActor import com.mz.training.common.rest.AbstractRestService import com.mz.training.domains.address.{AddressRepositoryActor, AddressServiceActor} import spray.json.RootJsonFormat import scal...
Explain and rewrite the following Scala code:
package co.rc.smservice.api.routing import co.rc.smservice.api.infrastructure.managers.{ CredentialsManager, JsonManager } import co.rc.smservice.app.BaseContext import net.ceedubs.ficus.Ficus._ import spray.routing.{ RouteConcatenation, Directives } import co.rc.smservice.api.infrastructure.auditing.AuditingHelper /...
Explain and rewrite the following Scala code:
package com.sbuljat.mailgunner import java.util.concurrent.TimeUnit import com.sbuljat.mailgunner.json.SendMessageRequestJsonProtocol import com.sbuljat.mailgunner.model.{SendMessageResponse, SendMessageRequest} import com.sbuljat.mailgunner.service.{ActorService, MailgunService} import spray.json._ import scala.con...
Explain and rewrite the following Scala code:
/* * Copyright 2014-2022 Netflix, 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:
package domala.internal import scala.collection.immutable.Stream.Empty object WrapStream { def of[T](javaStream: java.util.stream.Stream[T]): Stream[T] = { val it = javaStream.iterator() of(it) } def of[T](it: java.util.Iterator[T]): Stream[T] = { if(it.hasNext) { val next = it.next() n...
Explain and rewrite the following Scala code:
package bad.robot.radiate import java.util.concurrent.ScheduledFuture import bad.robot.radiate.monitor._ class MonitoringTasks(factory: MonitoringTasksFactory, monitor: Monitor) extends Iterable[MonitoringTask] { private var scheduled = List.empty[ScheduledFuture[_]] val tasks = factory.create.valueOr(error => ...
Explain and rewrite the following Scala code:
/* * */ package see.values private[see] case class Assoc(key: Val, value: Val) extends Container { override def selType = 'Assoc override def isType(typeId: Symbol) = (typeId == 'Assoc) || super.isType(typeId) override def size = 1 override def isEmpty = false override def at(index: Val) = va...
Explain and rewrite the following Scala code:
/* ************************************************************************************* * Copyright 2011 Normation SAS ************************************************************************************* * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero Ge...
Explain and rewrite the following Scala code:
package space.thedocking.infinitu.universe import space.thedocking.infinitu.dimension._ import scala.collection.immutable.SortedSet trait ObjectAddress { val dimensions: List[Dimension[_]] val values: List[DimensionValue[_]] for ((d, v) <- dimensions.zip(values)) { d.asInstanceOf[Dimension[Comparable[_]...
Explain and rewrite the following Scala code:
package com.github.mtailor.srtplayground.analysis import com.github.mtailor.srtdissector.Vocabulary._ import com.github.mtailor.srtplayground.analysis.SrtsTextualMatchingHelper.TextualMatchingParameters import org.specs2.mutable.Specification class SrtsTextualMatchingHelperTest extends Specification { implicit val...
Explain and rewrite the following Scala code:
/** * Created by Kotobotov.ru on 02.06.2018. * https://www.codingame.com/ide/puzzle/the-last-crusade-episode-1 * */ import math._ import scala.util._ object Player extends App { // w: number of columns. // h: number of rows. case class Pos(x: Int, y: Int) sealed trait Move { def allo...
Explain and rewrite the following Scala code:
/* * Copyright 2022 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:
import _root_.io.gatling.core.scenario.Simulation import ch.qos.logback.classic.{Level, LoggerContext} import io.gatling.core.Predef._ import io.gatling.http.Predef._ import org.slf4j.LoggerFactory import scala.concurrent.duration._ /** * Performance test for the ShortAnswerSubmittedAnswer entity. */ class ShortAns...
Explain and rewrite the following Scala code:
package com.karasiq.shadowcloud.webapp.styles import com.karasiq.shadowcloud.webapp.context.AppContext.CssSettings._ object FolderTreeStyles extends StyleSheet.Inline { import dsl._ val subTree = style( paddingLeft(5 px) ) val folderActions = style( marginLeft(2 px), cursor.pointer, opacit...
Explain and rewrite the following Scala code:
/** * Copyright 2012 Netflix, 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 i...
Explain and rewrite the following Scala code:
package chess case class Situation(board: Board, color: Color) { lazy val actors = board actorsOf color lazy val moves: Map[Pos, List[Move]] = actors collect { case actor if actor.moves.nonEmpty ⇒ actor.pos -> actor.moves } toMap lazy val destinations: Map[Pos, List[Pos]] = moves mapValues { ms ⇒ ms map...
Explain and rewrite the following Scala code:
package com.gu.management import javax.servlet._ import http.{HttpServletResponse, HttpServletRequest} abstract class AbstractHttpFilter extends Filter { def init(filterConfig: FilterConfig) { } def destroy() { } final def doFilter(req: ServletRequest, resp: ServletResponse, chain: FilterChain) { (req, re...
Explain and rewrite the following Scala code:
package com.shocktrade.server.services.yahoo import com.shocktrade.server.services.yahoo.YahooFinanceProfileService._ import io.scalajs.nodejs.Error import io.scalajs.npm.htmlparser2 import io.scalajs.npm.htmlparser2.{ParserHandler, ParserOptions} import io.scalajs.npm.request.Request import scala.concurrent.{Executi...
Explain and rewrite the following Scala code:
package services.publisher import common.publisher.{BasicPubSubService, Event} import javax.inject.{Inject, Singleton} import models.Counter import monix.execution.Scheduler @Singleton class CounterPubSubServiceImpl @Inject()(implicit scheduler: Scheduler) extends BasicPubSubService[Event[Counter]]
Explain and rewrite the following Scala code:
package com.sijali.util import com.sijali.SlackBot._ import scala.concurrent.Future import scala.concurrent.ExecutionContext.Implicits.global import slack.models.{Channel, Group, User} object Slack { /** Try the option function, if it is none, try to do the future function, and return a function from * string t...
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 org.scalatra package util package conversion import java.util.Date import java.text.{DateFormat, SimpleDateFormat} import scala.util.control.Exception.allCatch import scala._ /** * Support types and implicits for [[org.scalatra.util.conversion.TypeConverter]]. */ trait TypeConverterSupport { implicit def...
Explain and rewrite the following Scala code:
package dotty.tools package dotc package transform import core._ import Contexts._ import Symbols._ import Flags._ import Names._ import NameOps._ import Decorators._ import TypeUtils._ import Types._ import util.Spans.Span import config.Printers.transforms /** A utility class for generating access proxies. Currently...
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 im.actor.server.webhooks.http.routes import akka.http.scaladsl.model.StatusCodes._ import akka.http.scaladsl.model.{ StatusCode, StatusCodes } import akka.http.scaladsl.server.Directives._ import akka.http.scaladsl.server.PathMatchers.Segment import akka.http.scaladsl.server.Route import akka.http.scaladsl.uti...