instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2013 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 is distr... |
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 algorithm.genetic
import scala.util.{Random, Sorting}
object GeneticAlgorithm
{
def apply(featureSpace: Int, objective: Array[Int]): GeneticAlgorithm =
{
var g = new GeneticAlgorithm(FeatureSpace = featureSpace, Objective = objective)
g.population = g.initialPopulation(featureSpace, objective)
... |
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: | /*
* Copyright 2016 Nikolay Donets
*
* 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 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) Nikolai Koudelia
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available... |
Explain and rewrite the following Scala code: | package models
import scalikejdbc._
import org.joda.time.{DateTime}
case class HbfBookmark(
id: Long,
hbfSitePageId: Long,
hbfUserId: Long,
createdAt: Option[DateTime] = None,
updatedAt: Option[DateTime] = None) {
def save()(implicit session: DBSession = HbfBookmark.autoSession): HbfBookmark = HbfBookmar... |
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 controller
import org.scalatest._
import skinny.test.{ FactoryGirl, MockController }
import model.Company
import skinny.Format
import unit.DBSettings
class CompaniesControllerSpec extends FunSpec with Matchers with DBSettings {
describe("CompaniesController") {
def newCompany = FactoryGirl(C... |
Explain and rewrite the following Scala code: | /**
* Copyright 2013, 2014 Gianluca Amato <gamato@unich.it>
*
* This file is part of JANDOM: JVM-based Analyzer for Numerical DOMains
* JANDOM 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 versi... |
Explain and rewrite the following Scala code: | /*
* ******************************************************************************
* * Copyright (C) 2013 Christopher Harris (Itszuvalex)
* * Itszuvalex@gmail.com
* *
* * This program is free software; you can redistribute it and/or
* * modify it under the terms of the GNU General Public License
* * as p... |
Explain and rewrite the following Scala code: | package au.id.cxd.math.probability.analysis
import au.id.cxd.math.function.Constants
import au.id.cxd.math.function.column.ColMeans
import au.id.cxd.math.function.distance.{Cov, MahalanobisDistance}
import au.id.cxd.math.probability.continuous.{ChiSquare, LogNormal, Normal, StudentT}
import breeze.linalg.qr.QR
import ... |
Explain and rewrite the following Scala code: | package org.gtri.util.scala.xsdbuilder
import elements.{XsdElementUtil, XsdElement}
import org.gtri.util.scala.xmlbuilder.XmlEvent
sealed trait XsdEvent {
def locator : Any
}
case class StartXsdDocumentEvent(encoding : String, version : String, isStandAlone : Boolean, characterEncodingScheme : String, locator : An... |
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.gmail.at.pukanito.model.repository.knmitxt
/**
* Load data from KNMI text file.
*/
class KnmiTxtRepository {
}
|
Explain and rewrite the following Scala code: | package io.react2.scalata.translation
import org.scalatest._
/**
* @author dbalduini
*/
class DataStructureSpec extends FlatSpec with Matchers {
"DataStructureSpec" should "load structure spec to json" in {
}
}
|
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2017
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the foll... |
Explain and rewrite the following Scala code: | package net.snowflake.spark.snowflake
import net.snowflake.spark.snowflake.Parameters.MergedParameters
import net.snowflake.spark.snowflake.pushdowns.querygeneration.SourceQuery
import org.scalatest.FunSuite
import scala.collection.immutable.HashMap
class QueryGenerationSuite extends FunSuite{
test("Test canJoin"... |
Explain and rewrite the following Scala code: | package org.chafed.samples
import org.chafed._
/**
* Count the number of pages in the first page of results from search
* Google for: scala web scraping
*/
object GoogleSearch {
def main(args: Array[String]) {
val ua = new UserAgent(logger = PrintfLogger)
val results = for {
google <- ua GET("http://... |
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
* distributed ... |
Explain and rewrite the following Scala code: | package breeze.linalg;
import breeze.util.Opt
import breeze.macros.expand
import breeze.math.Complex
/**
* @author ktakagaki
* @date 04/17/2014.
*/
object Options {
//Options for CanPad
// <editor-fold defaultstate="collapsed" desc=" OptPadDimensions ">
sealed abstract class OptPadDimensions extends Opt
... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.hocon.manipulators
import com.intellij.psi.ElementManipulators
import org.jetbrains.plugins.hocon.HoconTestUtils._
import org.jetbrains.plugins.hocon.psi.HString
import org.jetbrains.plugins.hocon.{HoconFileSetTestCase, TestSuiteCompanion}
import org.junit.runner.RunWith
import org.junit.... |
Explain and rewrite the following Scala code: | /*
* @author Philip Stutz
* @author Sara Magliacane
*
* Copyright 2014 University of Zurich & VU University Amsterdam
*
* 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: | /***********************************************************************
* Copyright (c) 2013-2016 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and is ... |
Explain and rewrite the following Scala code: | object ParametetricPolymorphismMain extends App {
case class Car(make: String)
def head[A](xs: List[A]): A = xs(0)
println( head(1 :: 2 :: Nil) )
println( head(Car("Civic") :: Car("CR-V") :: Nil) )
} |
Explain and rewrite the following Scala code: | package com.twitter.finagle
import com.twitter.conversions.time._
import com.twitter.finagle.stats.InMemoryStatsReceiver
import com.twitter.util.{Future, Await}
import java.net.{UnknownHostException, InetAddress}
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.JUnitRunner
@Run... |
Explain and rewrite the following Scala code: | package org.jetbrains.sbt
import com.intellij.testFramework.UsefulTestCase
import com.intellij.testFramework.exceptionCases.AbstractExceptionCase
/**
* @author Nikolay Obedin
* @since 6/9/15.
*/
trait UsefulTestCaseHelper { self: UsefulTestCase =>
def assertException[T <: Throwable](expectedMessage: Option[Strin... |
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 io.scalac.amqp
/** Routing key envelope for a [[Message]] */
final case class Routed(routingKey: String, message: Message)
|
Explain and rewrite the following Scala code: | /*
* Copyright 2015 Webtrends (http://www.webtrends.com)
*
* See the LICENCE.txt 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: | package lila.oauth
import org.joda.time.DateTime
import play.api.mvc.{ RequestHeader, Result }
import lila.common.{ Bearer, HTTPRequest }
import lila.db.dsl._
import lila.user.{ User, UserRepo }
final class OAuthServer(
tokenApi: AccessTokenApi,
userRepo: UserRepo,
cacheApi: lila.memo.CacheApi
)(implicit... |
Explain and rewrite the following Scala code: | package mesosphere.marathon.health
import mesosphere.marathon.Protos.HealthCheckDefinition.Protocol
import mesosphere.marathon.api.v2.ValidationHelper
import mesosphere.marathon.state.Command
import mesosphere.marathon.{ MarathonTestHelper, MarathonSpec, Protos }
import play.api.libs.json.Json
import scala.collection... |
Explain and rewrite the following Scala code: | package model
import skinny.orm._, feature._
import scalikejdbc._
import org.joda.time._
case class MessageBasic(
id: Long,
accountId: Long,
schoolId: Option[Long] = None,
lessonId: Option[Long] = None,
status: Int,
deleteFlg: Boolean,
createdBy: Option[String] = None,
createdAt: Option[DateTime] = No... |
Explain and rewrite the following Scala code: | package org.crudible.core.binding.traits
import org.crudible.core.util.Decoratable
trait HasAutosize extends Decoratable {
case class HasAutosizeDecorator(isAutosize: Boolean)
def autosize(max: Boolean): this.type = {
this.decorateWith(HasAutosizeDecorator(max))
}
def autosize() = {
this.getDecorat... |
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: | object ArrayAccess {
def zero: Int = 0
def reset(a: Array[Int]): Unit = {
require(a.length > 0)
a(zero) = 0
a(0) = 0
}
}
|
Explain and rewrite the following Scala code: | package org.leialearns.crystallize.util
import java.lang.ref.Reference
import java.util.concurrent.atomic.AtomicReference
object Dump {
def dump(prefix: String, thing: Any): Iterator[String] = {
thing match {
case custom: DumpCustom => dump(prefix, custom.dumpAs)
case reference: Reference[_] => dump... |
Explain and rewrite the following Scala code: | package finloader.entities
import com.github.tototoshi.slick.JdbcJodaSupport._
import org.joda.time.LocalDate
import scala.slick.driver.JdbcDriver
import JdbcDriver._
import scala.slick.driver.JdbcDriver.Implicit._
import scala.slick.lifted.{TableQuery, Tag}
/**
* @author Paul Lysak
* Date: 02.07.13
* ... |
Explain and rewrite the following Scala code: | package dbis.test.pig
import dbis.pig.parser.PigParser.parseScript
import dbis.pig.op._
import dbis.pig.plan.DataflowPlan
import dbis.pig.plan.rewriting.Rewriter._
import org.scalatest.FlatSpec
import org.scalatest.Matchers
import org.scalatest.BeforeAndAfter
import dbis.pig.plan.MaterializationManager
import dbis.pig... |
Explain and rewrite the following Scala code: | // Copyright (C) 2011-2012 the original author or authors.
// See the LICENCE.txt 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.
// You ... |
Explain and rewrite the following Scala code: | package fpinscala.datastructures
sealed trait Tree[+A]
case class Leaf[A](value: A) extends Tree[A]
case class Branch[A](left: Tree[A], right: Tree[A]) extends Tree[A]
object Tree {
def size[A](t: Tree[A]): Int = {
def go(t: Tree[A], acc: Int): Int = t match {
case Leaf(x) => acc + 1
case Branch(l... |
Explain and rewrite the following Scala code: | package com.spacerangerwes.intellidjent
import org.kohsuke.github.GHContent
import scalax.collection.Graph
import scalax.collection.GraphEdge.DiEdge
/**
* App to create an Intellidjent Pipeline
*/
object IntellidjentDriver extends App {
val retriever: GithubOrgRetriever = GithubOrgRetriever("http_github_v3_api... |
Explain and rewrite the following Scala code: | /*
* The MIT License (MIT)
*
* Copyright (c) 2013 Association du Paris Java User Group.
*
* 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 limitat... |
Explain and rewrite the following Scala code: | /* __ *\\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
** __\\ \\/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\\___/_/... |
Explain and rewrite the following Scala code: | package io.github.mandar2812.dynaml.probability
import io.github.mandar2812.dynaml.pipes.DataPipe
/**
* Created by mandar on 09/01/2017.
*/
trait JointProbabilityScheme[
Domain1, Domain2,
P <: RandomVariable[Domain1], D <: RandomVariable[Domain2]]
extends RandomVariable[(Domain1, Domain2)] {
val prior: P
... |
Explain and rewrite the following Scala code: | package mr.merc.map.pathfind
import mr.merc.economics.Culture.LatinHuman
import mr.merc.map.UniversalGrid
import org.scalatest.funsuite.AnyFunSuite
import mr.merc.map.hex.Hex
import mr.merc.map.hex.HexField
import mr.merc.map.hex.TerrainHexField
import mr.merc.map.hex.TerrainHex
import mr.merc.map.terrain._
import mr.... |
Explain and rewrite the following Scala code: | package main
import org.scalatest.{FlatSpec, Matchers}
import main.Main.top
/**
* Created by kasonchan on 12/18/15.
*/
class MainSuite extends FlatSpec with Matchers {
"Test" should "pass" in {
top
}
}
|
Explain and rewrite the following Scala code: | package dotty.tools.dotc
package core
import Types._
import scala.util.hashing.{ MurmurHash3 => hashing }
import annotation.tailrec
object Hashable {
/** A null terminated list of BindingTypes. We use `null` here for efficiency */
class SomeBinders(val tp: BindingType, val next: Binders)
type Binders = SomeBi... |
Explain and rewrite the following Scala code: | package com.box.castle.router.kafkadispatcher.messages
import com.box.castle.router.kafkadispatcher.processors.RequesterInfo
import com.box.castle.consumer.{ConsumerId, OffsetType}
import com.box.castle.router.messages.OffsetAndMetadata
import kafka.api._
import kafka.common.TopicAndPartition
/**
* This file contain... |
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 pl.touk.nussknacker.processCounts.influxdb
import pl.touk.nussknacker.engine.util.metrics.common.naming.{nodeIdTag, scenarioIdTag}
import sttp.client.UriContext
case class InfluxConfig(influxUrl: String, user: Option[String], password: Option[String],
database: String,
... |
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: | /*
* # Trove
*
* This file is part of Trove - A FREE desktop budgeting application that
* helps you track your finances, FREES you from complex budgeting, and
* enables you to build your TROVE of savings!
*
* Copyright Β© 2016-2019 Eric John Fredericks.
*
* Trove is free software: you can redistribute it ... |
Explain and rewrite the following Scala code: | package org.odfi.indesign.core.module.artifactresolver
import org.scalatest.BeforeAndAfterAll
import java.io.File
import org.scalatest.BeforeAndAfterAllConfigMap
import org.scalatest.ConfigMap
import org.odfi.tea.file.DirectoryUtilities
import java.net.URL
import org.odfi.indesign.core.module.artifactresolver.Aethe... |
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... |
Explain and rewrite the following Scala code: | package io.github.facaiy.dag.core
/**
* Created by facai on 5/5/17.
*/
case class LazyCell[+A](get: () => A) {
import LazyCell._
def map[B](f: A => B): LazyCell[B] = lazyCell(f(get()))
def flatMap[B](f: A => LazyCell[B]): LazyCell[B] = map(f(_).get())
def map2[B, C](that: LazyCell[B])(f: (A, B) => C): Laz... |
Explain and rewrite the following Scala code: | package com.wavesplatform.mining
import java.time.LocalTime
import cats.syntax.either._
import com.wavesplatform.account.KeyPair
import com.wavesplatform.block.Block._
import com.wavesplatform.block.{Block, BlockHeader, SignedBlockHeader}
import com.wavesplatform.consensus.PoSSelector
import com.wavesplatform.consens... |
Explain and rewrite the following Scala code: | /**
* Copyright (c) 2012-2013, Tomasz Kaczmarzyk.
*
* This file is part of BeanDiff.
*
* BeanDiff 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 o... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 RONDHUIT Co.,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 agre... |
Explain and rewrite the following Scala code: | package templemore.liftjson.provider.jsr311
import org.specs2.Specification
import templemore.liftjson.provider.ErrorResponse
import javax.ws.rs.core.MediaType
class Jsr311ResponseAdapterSpec extends Specification { def is =
"Specification for the Jsr-311 Response Adapter" ^
... |
Explain and rewrite the following Scala code: | package scalaFP
/**
* A Naperian functor is a container with a fixed size, such as
* `data Triple a = Triple a a a`, or Stream, but not List or Option.
*
* All Naperian functors are equivalent to a functor (P => ?), for some P,
* where P is the type of positions in the container.
* e.g. for Triple, P = 3 a... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2012 Yahoo! 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 applicable law
* or a... |
Explain and rewrite the following Scala code: | /*
* Copyright 2014β2018 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 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 2012-2020 the original author or 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 ap... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2016 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org... |
Explain and rewrite the following Scala code: | /*
* Copyright 2001-2014 Stephen Colebourne
*
* 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... |
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.microsoft.awt.components
import org.scalajs.angularjs.{Controller, Scope}
import org.scalajs.dom.browser.console
import scala.scalajs.js
/**
* Verification Controller
* @author lawrence.daniels@gmail.com
*/
class VerificationController($scope: VerificationScope, $routeParams: VerificationRouteParam... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 Dennis Vriend
*
* 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 t... |
Explain and rewrite the following Scala code: | package com.twitter.finagle.netty4.proxy
import io.netty.channel.Channel
import io.netty.channel.embedded.EmbeddedChannel
import io.netty.handler.proxy.{Socks5ProxyHandler, ProxyHandler}
import io.netty.util.concurrent.DefaultPromise
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.sca... |
Explain and rewrite the following Scala code: | package mesosphere.marathon.core.task.tracker
import akka.actor.ActorRef
import akka.stream.Materializer
import mesosphere.marathon.core.base.Clock
import mesosphere.marathon.core.leadership.LeadershipModule
import mesosphere.marathon.core.task.tracker.impl._
import mesosphere.marathon.core.task.update.TaskUpdateStep
... |
Explain and rewrite the following Scala code: | package code
package model
import net.liftweb._
import mapper._
import common._
object ExtSession extends ExtSession with MetaProtoExtendedSession[ExtSession] {
override def dbTableName = "ext_session"
val TOKEN_TYPE_WEB = ""
val TOKEN_TYPE_CLIENT_API = "CLIENT-API"
def logUserIdIn(uid: String): Unit = User... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package lang
package psi
package impl
package expr
import com.intellij.lang.ASTNode
import com.intellij.openapi.util.TextRange
import com.intellij.psi._
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.IncorrectOperationException
import org.jetbrains.plugins.scala.e... |
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 cqrs.queries
import java.time.Instant
import java.util.UUID
import io.circe.{Decoder, Encoder}
import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder}
import io.circe.java8.time._
import scala.collection.immutable.SortedMap
/**
* This is the model used for querying.
*/
// TODO Add useful stats
c... |
Explain and rewrite the following Scala code: | package com.roundeights.foldout
import com.roundeights.scalon._
import com.roundeights.hasher.Hasher
import scala.annotation.tailrec
import java.net.URL
import scala.io.Source
import java.io.{File, FileNotFoundException}
/**
* ViewSpec Companion
*/
object ViewSpec {
/** Constructor */
def apply ( map: Str... |
Explain and rewrite the following Scala code: | package com.telegram.api
import com.telegram.api.ChatAction.ChatAction
import com.telegram.http.{TelegramHttpClient, HttpClient}
import com.telegram.json.JsonUtils
import org.json4s._
import org.json4s.native.JsonMethods._
import scala.concurrent.{ExecutionContext, Future}
import ExecutionContext.Implicits.global
im... |
Explain and rewrite the following Scala code: | package com.twitter.app
import java.io.{File, IOException}
import java.net.{URI, URISyntaxException, URLClassLoader}
import java.util.jar.JarFile
import scala.collection.JavaConverters._
import scala.collection.mutable
/**
* Inspect and load the classpath. Inspired by
* Guava's ClassPath utility.
*
* @note This ... |
Explain and rewrite the following Scala code: | import scala.tools.nsc.doc.model._
import scala.tools.partest.ScaladocModelTest
object Test extends ScaladocModelTest {
override def code = """
object Foo {
trait Config {
/** The bar obviously. */
def bar: Int
}
class ConfigBuilder extends Config {
/** @inheritdoc
*
* The default value... |
Explain and rewrite the following Scala code: | // Copyright (C) 2014 Dmitry Yakimenko (detunized@gmail.com).
// Licensed under the terms of the MIT license. See LICENCE for details.
package net.detunized.iteratorz
class RepeatingIteratorSpec extends IteratorSpec[Int] {
"is empty on an empty iterator" in {
mk()(_ => 1) must beEmpty
}
"is empty with zero... |
Explain and rewrite the following Scala code: | package scorex.crypto.hash
class SkeinSpecification extends HashTest {
hashCheckString(Skein256,
Map(
"" -> "39ccc4554a8b31853b9de7a1fe638a24cce6b35a55f2431009e18780335d2621",
"The quick brown fox jumps over the lazy dog" -> "b3250457e05d3060b1a4bbc1428bc75a3f525ca389aeab96cfa34638d96e492a",
"... |
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: | /*
* 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: | import java.io.{OutputStream, PrintWriter, FileOutputStream}
import System.out
import System.err
import java.util.Random
/**
* Main
*
* 5-MAR-2015 - (mayton) 'if-else' codeblock has been refactored with 'match'
*/
object Main {
def main(args: Array[String]): Unit = {
val begin = System.currentTimeMillis... |
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.phasmid.laScala
/**
* NOTE: you will need to change the value of VERSION before doing a release
*
* Created by scalaprof on 7/31/16.
*/
import org.scalatest._
import scala.util._
class VersionSpec extends FlatSpec with Matchers with Inside {
// TODO you must increment this every time version c... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016-2017 Chris de Vreeze
*
* 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 info.glennengstrand.news.service
import javax.inject.{Inject, Provider}
import play.api.MarkerContext
import play.api.Logger
import scala.concurrent.{ExecutionContext, Future}
import play.api.libs.json._
import info.glennengstrand.news.model._
import info.glennengstrand.news.dao._
import info.glennengstrand... |
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 dmtest
import java.nio.file.{Files, Paths}
import dmtest._
import dmtest.stack._
class MiscTest extends DMTestSuite {
test("<> op") {
val res = 100 <> 10
if (isDebugMode)
assert(res === 10)
else
assert(res === 100)
}
test("chdir and run cmd") {
val output = Shell.at(Paths.get... |
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.arcusys.learn.notifications
trait MessageTemplateLoader {
import MessageTemplateLoader._
def getFor(mtype: MessageType.Value): Option[MessageTemplate]
def render(tpl: MessageTemplate, data: Map[String, _]): String
}
object MessageTemplateLoader {
case class MessageTemplate(subject: String, typ: Me... |
Explain and rewrite the following Scala code: | /*
*
* Copyright (c) 2016 Sylvain Julmy
*
* 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 2 of the License, or
* (at your option) any later version.
*
* This program is... |
Explain and rewrite the following Scala code: | package org.dbpedia.spotlight.model
/**
* @author Joachim Daiber
*/
class Token(val token: String, val offset: Int, var tokenType: TokenType) extends HasFeatures {
override def hashCode() = "%s, %d".format(token, offset).hashCode
override def equals(obj: Any): Boolean = {
obj match {
case token: Tok... |
Explain and rewrite the following Scala code: | /* Copyright (C) 2008-2014 University of Massachusetts Amherst.
This file is part of "FACTORIE" (Factor graphs, Imperative, Extensible)
http://factorie.cs.umass.edu, http://github.com/factorie
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2014 - 2016 Softwaremill <http://softwaremill.com>
* Copyright (C) 2016 - 2019 Lightbend Inc. <http://www.lightbend.com>
*/
package akka.kafka.internal
import akka.NotUsed
import akka.actor.Status
import akka.actor.{ActorRef, ExtendedActorSystem, Terminated}
import akka.annotation.InternalApi
im... |
Explain and rewrite the following Scala code: | package chehao.myscala
object CloseExample {
def main(args: Array[String]): Unit = {
val con = new Connection();
//withClose will run close with connection, input 2 is to implement process with connection
withClose(con, conn => println("execute connection "))
withClose2(con)(conn=>println("execute c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.