repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
gaborh-da/daml | ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/services/transaction/SandboxTransactionService.scala | // Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.sandbox.services.transaction
import java.util.concurrent.atomic.AtomicLong
import akka.NotUsed
import akka.stream.Materializer
import akka.stream... |
gaborh-da/daml | ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/SandboxServer.scala | <gh_stars>0
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.sandbox
import java.time.Instant
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Sink... |
gaborh-da/daml | daml-lf/interface/src/test/scala/com/digitalasset/daml/lf/iface/TypeSpec.scala | // Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.daml.lf.iface
import com.digitalasset.daml.lf.data.ImmArray.ImmArraySeq
import com.digitalasset.daml.lf.data.Ref.{Identifier, QualifiedName, PackageId}
imp... |
gaborh-da/daml | ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/sandbox/services/SandboxFixture.scala | <reponame>gaborh-da/daml<filename>ledger/sandbox/src/test/lib/scala/com/digitalasset/platform/sandbox/services/SandboxFixture.scala
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.sandbox.service... |
gaborh-da/daml | ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/stores/ledger/inmemory/InMemoryLedger.scala | <reponame>gaborh-da/daml
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.sandbox.stores.ledger.inmemory
import java.time.Instant
import akka.NotUsed
import akka.stream.scaladsl.Source
import co... |
gaborh-da/daml | ledger/sandbox/src/main/scala/com/digitalasset/platform/sandbox/LedgerIdGenerator.scala | // Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.sandbox
import java.util.UUID
object LedgerIdGenerator {
def generateRandomId(): String = s"sandbox-${UUID.randomUUID().toString}"
}
|
gaborh-da/daml | bazel_tools/runfiles/src/main/scala/com/digitalasset/daml/bazeltools/BazelRunfiles.scala | <gh_stars>0
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.daml.bazeltools
import com.google.devtools.build.runfiles.Runfiles
trait BazelRunfiles {
private val MainWorkspace = "com_github_digital_as... |
gaborh-da/daml | navigator/backend/src/main/scala/com/digitalasset/navigator/model/converter/LedgerApiV1.scala | // Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.navigator.model.converter
import java.time.{Instant, LocalDate}
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit
import com.... |
gaborh-da/daml | ledger/ledger-api-common/src/main/scala/com/digitalasset/ledger/api/validation/TransactionServiceRequestValidator.scala | // Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.ledger.api.validation
import brave.propagation.TraceContext
import com.digitalasset.daml.lf.data.Ref.Party
import com.digitalasset.ledger.api.domain
import... |
gaborh-da/daml | ledger/ledger-api-integration-tests/src/test/itsuite/scala/com/digitalasset/platform/tests/integration/ledger/api/identity/LedgerIdentityServiceGivenIT.scala | // Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.tests.integration.ledger.api.identity
import com.digitalasset.platform.common.LedgerIdMode
@SuppressWarnings(Array("org.wartremover.warts.Any"))
... |
gaborh-da/daml | ledger/sandbox/src/test/suite/scala/com/digitalasset/platform/sandbox/services/transaction/EventFilterSpec.scala | // Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.sandbox.services.transaction
import com.digitalasset.ledger.api.v1.event.Event.Event.{Archived, Created}
import com.digitalasset.ledger.api.v1.eve... |
gaborh-da/daml | ledger/ledger-api-integration-tests/src/main/scala/com/digitalasset/platform/semantictest/StandaloneSemanticTestRunner.scala | <filename>ledger/ledger-api-integration-tests/src/main/scala/com/digitalasset/platform/semantictest/StandaloneSemanticTestRunner.scala
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.semantictest... |
gaborh-da/daml | ledger/ledger-api-integration-tests/src/test/itsuite/scala/com/digitalasset/platform/tests/integration/ledger/api/WitnessesIT.scala | // Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.platform.tests.integration.ledger.api
import scala.concurrent.Future
import org.scalatest.{AsyncFreeSpec, Matchers}
import com.digitalasset.ledger.api.test... |
gaborh-da/daml | ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/LedgerApiTestTool.scala | <filename>ledger/ledger-api-test-tool/src/main/scala/com/daml/ledger/api/testtool/LedgerApiTestTool.scala
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.daml.ledger.api.testtool
import java.io.{File, PrintWriter, St... |
gaborh-da/daml | daml-lf/data/src/main/scala/com/digitalasset/daml/lf/data/Utf8.scala | // Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.daml.lf.data
import java.nio.charset.StandardCharsets
import java.security.MessageDigest
import scala.annotation.tailrec
// The DAML-LF strings are suppo... |
gaborh-da/daml | daml-lf/data/src/main/scala/com/digitalasset/daml/lf/data/MatchingStringModule.scala | <filename>daml-lf/data/src/main/scala/com/digitalasset/daml/lf/data/MatchingStringModule.scala
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.daml.lf.data
import scalaz.Equal
import scala.util.matching.... |
gaborh-da/daml | ledger/backend-api/src/main/scala/com/digitalasset/ledger/backend/api/v1/LedgerBackend.scala | <filename>ledger/backend-api/src/main/scala/com/digitalasset/ledger/backend/api/v1/LedgerBackend.scala
// Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package com.digitalasset.ledger.backend.api.v1
import akka.NotUsed
import akk... |
igieon/sbt-assembly | build.sbt | lazy val commonSettings: Seq[Setting[_]] = Seq(
version in ThisBuild := "0.14.7-SNAPSHOT",
organization in ThisBuild := "com.eed3si9n"
)
lazy val root = (project in file(".")).
// enablePlugins(GitVersioning).
settings(commonSettings: _*).
settings(
sbtPlugin := true,
name := "sbt-assembly",
desc... |
rise-lang/2021-CGO-artifact | lib/harris-rise-and-shine/build.sbt | scalaVersion := "2.12.10"
lazy val root = (project in file("."))
.dependsOn(shine)
.settings(
name := "harris-rise-and-shine",
javaOptions ++= Seq("-Xss20m", "-Xms512m", "-Xmx4G")
)
lazy val shine = ProjectRef(file("../shine"), "shine") |
rise-lang/2021-CGO-artifact | lib/harris-rise-and-shine/Main.scala | package imgproc_rise_and_shine
import apps.harrisCornerDetectionHalide.harris
import apps.harrisCornerDetectionHalide.ocl._
import apps.harrisCornerDetectionHalideRewrite.{ocl => rewrite}
object Main {
def genKernel(e: rise.core.Expr, name: String, path: String): Unit = {
val lowered = rewrite.unrollDots(rise.c... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/internal/TracedTFunctions.scala | <reponame>fehu/opentracing-scala
package com.github.fehu.opentracing.internal
import cats.data.StateT
import cats.effect.{ IO, LiftIO, Sync }
import cats.syntax.functor._
import cats.{ Applicative, ApplicativeError, Functor, ~> }
import io.opentracing.propagation.Format
import com.github.fehu.opentracing.Traced
impor... |
fehu/opentracing-scala | akka/src/main/scala/akka/fehu/MessageInterceptingActor.scala | package akka.fehu
import scala.util.control.NonFatal
import akka.actor.Actor
trait MessageInterceptingActor extends Actor {
override protected[akka] def aroundReceive(receive: Receive, msg: Any): Unit = {
try super.aroundReceive(receive, interceptIncoming(msg))
catch { case NonFatal(err) => afterReceive(So... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/util/FunctionK2.scala | <filename>scala/src/main/scala/com/github/fehu/opentracing/util/FunctionK2.scala
package com.github.fehu.opentracing.util
trait FunctionK2[F[*[_]], G[*[_]]] extends Serializable { self =>
def apply[A[_]](fa: F[A]): G[A]
def compose[E[*[_]]](f: FunctionK2[E, F]): FunctionK2[E, G] =
new FunctionK2[E, G] {
... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/propagation/TextMapPropagation.scala | package com.github.fehu.opentracing.propagation
import java.util.{ Iterator => JIterator, Map => JMap }
import scala.collection.mutable
import scala.collection.JavaConverters._
import io.opentracing.propagation.{ Format, TextMap }
final class TextMapPropagation private (map: mutable.SortedMap[String, String]) exten... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/propagation/BinaryPropagation.scala | package com.github.fehu.opentracing.propagation
import java.nio.ByteBuffer
import io.opentracing.propagation.{ Binary, Format }
final class BinaryPropagation private (private var buff: ByteBuffer) extends Propagation {
type Underlying = Binary
val underlying: Binary = new Binary {
def extractionBuffer(): By... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/util/ErrorLogger.scala | <filename>scala/src/main/scala/com/github/fehu/opentracing/util/ErrorLogger.scala
package com.github.fehu.opentracing.util
import cats.{ Applicative, Defer }
trait ErrorLogger {
def apply[F[_]: Applicative: Defer](message: String, error: Throwable): F[Unit]
}
object ErrorLogger {
lazy val stdout: ErrorLogger = n... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/transformer/TracedT.scala | package com.github.fehu.opentracing.transformer
import cats.{ FlatMap, Functor, ~> }
import cats.data.StateT
import cats.effect.{ Effect, IO, LiftIO }
import com.github.fehu.opentracing.internal.{ State, TracedTFunctions, TracedTFunctionsForSync, TracedTInstances }
final case class TracedT[F[_], A](stateT: StateT[F,... |
fehu/opentracing-scala | scala/src/test/scala/com/github/fehu/opentracing/propagation/PropagationSpec.scala | <reponame>fehu/opentracing-scala
package com.github.fehu.opentracing.propagation
import cats.effect.Effect
import cats.effect.syntax.effect._
import cats.syntax.flatMap._
import cats.syntax.functor._
import org.scalatest.Ignore
import org.scalatest.freespec.AnyFreeSpec
import com.github.fehu.opentracing.syntax._
impo... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/transformer/package.scala | package com.github.fehu.opentracing
import cats.effect.IO
package object transformer {
type TracedIO[A] = TracedT[IO, A]
}
|
fehu/opentracing-scala | build.sbt | <gh_stars>1-10
// scalac plugin has its own version
val scala212 = "2.12.14"
val scala213 = "2.13.6"
ThisBuild / crossScalaVersions := List(scala212, scala213)
ThisBuild / scalaVersion := scala213
ThisBuild / version := "0.6.0"
ThisBuild / organization := "com.github.fehu"
inThisBuild(Seq(
a... |
fehu/opentracing-scala | scala/src/test/scala/com/github/fehu/opentracing/TraceSpec.scala | package com.github.fehu.opentracing
import scala.concurrent.duration._
import org.scalatest.freespec.AnyFreeSpec
import cats.effect.{ ContextShift, Effect, Timer }
import cats.effect.syntax.effect._
import cats.syntax.apply._
import cats.syntax.flatMap._
import cats.syntax.functor._
import org.scalatest.Ignore
impor... |
fehu/opentracing-scala | compiler-plugin/build.sbt | name := "opentracing-jaeger-scalac-implicits"
version := "0.1.3"
libraryDependencies ++= Seq(
Dependencies.`scala-compiler`.value,
Dependencies.`jaeger-client`
// [Assembly] slf4j implementation is not included despite the warnings that appear on plugin usage
)
// Assembly - dependencies aren't provided by sbt... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/internal/syntax/LowPrioritySyntax.scala | <gh_stars>1-10
package com.github.fehu.opentracing.internal.syntax
import io.opentracing.SpanContext
import io.opentracing.propagation.Format
import com.github.fehu.opentracing.{ Traced, Traced2 }
protected[opentracing] trait LowPrioritySyntax {
final implicit class Traced2WrapOps[G[_], A](ga: G[A]) {
def tra... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/internal/Stubs.scala | package com.github.fehu.opentracing.internal
import cats.effect.Resource
import cats.{Applicative, Defer, ~>}
import io.opentracing.SpanContext
import io.opentracing.propagation.Format
import com.github.fehu.opentracing.Traced
protected[opentracing] class TracedStub[F[_]](implicit A: Applicative[F], D: Defer[F]) ext... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/syntax/package.scala | package com.github.fehu.opentracing
import scala.language.existentials
import cats.{ Applicative, Defer, FlatMap, Functor, Monad, ~> }
import cats.effect.{ Resource, Sync }
import cats.syntax.flatMap._
import cats.syntax.functor._
import io.opentracing.{ SpanContext, Tracer }
import io.opentracing.propagation.Format
... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/internal/TracedTInstances.scala | <reponame>fehu/opentracing-scala
package com.github.fehu.opentracing.internal
import scala.concurrent.ExecutionContext
import scala.concurrent.duration.{ FiniteDuration, TimeUnit }
import cats.{ Applicative, CommutativeApplicative, Monad, MonadError, Parallel, ~> }
import cats.data.{ IndexedStateT, StateT }
import ca... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/internal/Tools.scala | package com.github.fehu.opentracing.internal
import cats.effect.Sync
import cats.Endo
import io.opentracing.{ Span, SpanContext, Tracer }
import com.github.fehu.opentracing.Traced
private[opentracing] object Tools {
def newSpan[F[_]: Sync](tracer: Tracer,
parent: Option[Either[Span, Span... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/internal/State.scala | <reponame>fehu/opentracing-scala
package com.github.fehu.opentracing.internal
import scala.collection.JavaConverters._
import cats.effect.Sync
import cats.~>
import cats.instances.option._
import cats.syntax.applicative._
import cats.syntax.flatMap._
import cats.syntax.functor._
import cats.syntax.traverse._
import i... |
fehu/opentracing-scala | akka/src/main/scala/com/github/fehu/opentracing/akka/AskTracing.scala | <reponame>fehu/opentracing-scala
package com.github.fehu.opentracing.akka
import akka.actor.ActorRef
import akka.pattern
import akka.util.Timeout
import cats.effect.{ Async, ContextShift }
import cats.syntax.flatMap._
import cats.syntax.functor._
import com.github.fehu.opentracing.Traced
import com.github.fehu.opentr... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/propagation/Propagation.scala | package com.github.fehu.opentracing.propagation
import io.opentracing.propagation.Format
trait Propagation {
type Underlying
def underlying: Underlying
def format: Format[Underlying]
type Repr
def repr: Repr
}
trait PropagationCompanion[C <: Propagation] {
def apply(): C
def apply(repr: C#Repr): C
... |
fehu/opentracing-scala | akka/src/main/scala/com/github/fehu/opentracing/akka/package.scala | package com.github.fehu.opentracing
import _root_.akka.actor.ActorRef
import _root_.akka.util.Timeout
import cats.effect.{ Async, ContextShift }
package object akka {
def ask[F[_]: Async: ContextShift: Traced](actorRef: ActorRef, message: Any, sender: ActorRef)
(implicit... |
fehu/opentracing-scala | scala/src/test/scala/com/github/fehu/opentracing/propagation/io/PropagationTracedIOSpec.scala | package com.github.fehu.opentracing.propagation.io
import cats.effect.Effect
import com.github.fehu.opentracing.Traced
import com.github.fehu.opentracing.propagation.PropagationSpec
import com.github.fehu.opentracing.transformer._
import com.github.fehu.opentracing.util.ErrorLogger
class PropagationTracedIOSpec exte... |
fehu/opentracing-scala | fs2/src/main/scala/com/github/fehu/opentracing/syntax/FS2.scala | package com.github.fehu.opentracing.syntax
import _root_.fs2.Stream
import cats.~>
import cats.effect.Bracket
import cats.syntax.apply._
import io.opentracing.SpanContext
import io.opentracing.propagation.Format
import com.github.fehu.opentracing.Traced
import com.github.fehu.opentracing.propagation.{ Propagation, Pr... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/Traced.scala | package com.github.fehu.opentracing
import scala.language.{ existentials, implicitConversions }
import cats.{ Show, ~> }
import cats.effect.Resource
import cats.syntax.show._
import io.opentracing.propagation.Format
import io.opentracing.{ Span, SpanContext, Tracer, tag }
import com.github.fehu.opentracing.util.Erro... |
fehu/opentracing-scala | scala/src/main/scala/com/github/fehu/opentracing/transformer/Untraced.scala | package com.github.fehu.opentracing.transformer
import cats.{Applicative, Defer}
import com.github.fehu.opentracing.Traced
import com.github.fehu.opentracing.internal.TracedStub
object Untraced {
/** Get a stub [[Traced]] instance for `F[_]`. */
def tracedStub[F[_]: Applicative: Defer]: Traced[F] = new TracedStu... |
fehu/opentracing-scala | scala/src/test/scala/com/github/fehu/opentracing/io/TracedIOSpec.scala | <gh_stars>1-10
package com.github.fehu.opentracing.io
import scala.concurrent.ExecutionContext
import cats.effect.{ ContextShift, Effect, IO, Timer }
import com.github.fehu.opentracing.transformer._
import com.github.fehu.opentracing.TraceSpec
class TracedIOSpec extends TraceSpec[TracedIO] {
implicit lazy val eff... |
fehu/opentracing-scala | akka/src/main/scala/com/github/fehu/opentracing/akka/TracingActor.scala | package com.github.fehu.opentracing.akka
import akka.fehu.MessageInterceptingActor
import io.opentracing.{ Span, SpanContext, Tracer }
import com.github.fehu.opentracing.Traced
final case class TracedMessage[A](message: A, spanContext: Option[SpanContext])
trait TracingActor extends MessageInterceptingActor {
imp... |
fehu/opentracing-scala | scala/src/test/scala/com/github/fehu/opentracing/Spec.scala | package com.github.fehu.opentracing
import java.util.concurrent.atomic.AtomicLong
import scala.collection.JavaConverters._
import _root_.io.opentracing.mock.{ MockSpan, MockTracer }
import org.scalatest.{ BeforeAndAfter, BeforeAndAfterAll, Suite }
import org.scalatest.matchers.should.Matchers
trait Spec extends Mat... |
fehu/opentracing-scala | compiler-plugin/src/main/scala/com/github/fehu/opentracing/compile/ImplicitSearchTracingPlugin.scala | package com.github.fehu.opentracing.compile
import scala.collection.mutable
import scala.reflect.internal.util.NoSourceFile
import scala.tools.nsc.Global
import scala.tools.nsc.plugins.{ Plugin, PluginComponent }
import io.jaegertracing.Configuration
import io.jaegertracing.Configuration.SamplerConfiguration
import i... |
rorygraves/akka-scalaclean-test | src/main/scala/akka/japi/tuple/Tuples.scala | <filename>src/main/scala/akka/japi/tuple/Tuples.scala<gh_stars>0
// auto-generated by sbt-boilerplate
/*
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package akka.japi.tuple
/**
* Used to create tuples with 3 elements in Java.
*/
object Tuple3 {
def create[T1, T2, T3](t1: T1, t2: T2, t... |
rorygraves/akka-scalaclean-test | src/main/scala/akka/japi/function/Functions.scala | // auto-generated by sbt-boilerplate
/**
* Copyright (C) 2015-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package akka.japi.function
/**
* A Function interface. Used to create 3-arg first-class-functions is Java.
* `Serializable` is needed to be able to grab line number for Java 8 lambdas.
*/
@SerialVersio... |
rorygraves/akka-scalaclean-test | build.sbt | import Dependencies._
ThisBuild / scalaVersion := "2.12.8"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / organization := "com.example"
ThisBuild / organizationName := "example"
lazy val root = (project in file("."))
.settings(
name := "Akka ScalaClean Test",
addCompilerPlugin("org.scala... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/93.scala | package net.tisue.euler
// By using each of the digits from the set {1, 2, 3, 4} exactly once, and
// making use of the four arithmetic operations (+, -, *, /) and parentheses,
// it is possible to form different positive integer targets.
//
// For example,
// 8 = (4 * (1 + 3)) / 2
// 14 = 4 * (3 + 1 / 2)
// 19 = 4... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/84.scala | package net.tisue.euler
// In a game of Monopoly, statistically it can be shown that the three most
// popular squares, in descending order, are JAIL, E3, and GO (squares 10, 24, 0
// = 102400). If, instead of using two 6-sided dice, two 4-sided dice are used,
// find the three winners.
//
// This can be solved by Mon... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/90.scala | <reponame>SethTisue/Project-Euler
package net.tisue.euler
class Problem90 extends Problem(90, "1217"):
def solve =
val squares = List("01", "04", "09", "16", "25", "36", "49", "64", "81")
def isSolution(die1: Seq[Int], die2: Seq[Int]) =
val rolls =
for d1 <- die1
d2 <- die2
... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/110.scala | <gh_stars>1-10
package net.tisue.euler
import Primes.*
// Like problem 108, but we have to be smarter.
// We are asked to find the first solution n for which A018892(n) exceeds 4,000,000. Empirically, the
// factorCounts values which reach new highs for A018892(n) look like:
// (1)
// (2)
// (1, 1)
// (2, 1)
// (3, ... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/46.scala | <reponame>SethTisue/Project-Euler<gh_stars>1-10
package net.tisue.euler
import Primes.*
// What is the smallest odd composite that cannot be written as the sum of a prime and twice a
// square?
class Problem46 extends Problem(46, "5777"):
def square(n: Int) = n * n
def isSquare(n: Int) =
n == square(math.rou... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/37.scala | <reponame>SethTisue/Project-Euler
package net.tisue.euler
import Primes.*
// Find the sum of the only eleven primes that are both truncatable from left to right and right to
// left. (Example: 3797. 379, 37, 3, 797, 97, and 7 are all prime.)
class Problem37 extends Problem(37, "748317"):
def solve =
def isTru... |
SethTisue/Project-Euler | build.sbt | <filename>build.sbt<gh_stars>1-10
scalaVersion := "3.1.1-RC2"
libraryDependencies += "org.scalameta" %% "munit" % "0.7.29" % Test
scalacOptions ++= Seq(
"-encoding", "us-ascii",
"-deprecation",
"-feature",
"-Xfatal-warnings",
"-source:future",
)
|
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/86.scala | <gh_stars>1-10
package net.tisue.euler
// A spider, S, sits in one corner of a cuboid room, measuring 6 by 5 by 3, and
// a fly, F, sits in the opposite corner. By travelling on the surfaces of the
// room the shortest "straight line" distance from S to F is 10 and the path is
// shown on the diagram. However, there ... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/83.scala | <filename>src/test/scala/net/tisue/euler/83.scala<gh_stars>1-10
package net.tisue.euler
// Find the minimal path sum in matrix.txt (from problems 81 and 82), from the top left to the
// bottom right by moving left, right, up, and down.
// http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
import collection.immutabl... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/27.scala | <reponame>SethTisue/Project-Euler<filename>src/test/scala/net/tisue/euler/27.scala
package net.tisue.euler
import Primes.*
// Considering quadratics of the form:
// n^2 + an + b, where |a| < 1000 and |b| < 1000
// where |n| is the absolute value of n
// Find the product of the coefficients, a and b, for the quadratic
... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/108.scala | <reponame>SethTisue/Project-Euler<gh_stars>1-10
package net.tisue.euler
import Primes.*
// In the following equation x, y, and n are positive integers:
// 1/x + 1/y = 1/n
// For n = 4 there are exactly three distinct solutions:
// 1/5 + 1/20 = 1/4
// 1/6 + 1/12 = 1/4
// 1/8 + 1/ 8 = 1/4
// What is the least value of n... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/98.scala | <reponame>SethTisue/Project-Euler
package net.tisue.euler
// Find all the square anagram word pairs (e.g. CARE 1296 = 36^2, RACE 9216 = 96^2).
// What is the largest square number formed by any member of such a pair?
class Problem98 extends Problem(98, "18769"):
val words: Iterable[String] =
io.Source.fromResou... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/101.scala | package net.tisue.euler
// There are a lot of different ways you can solve this.
// Cramer's Rule is one, Pascal's triangle is another.
// Instead of anything fancy I used the method of successive differences which
// is taught to schoolchildren and which is easy to do with pencil and paper.
// The "diagonal" method ... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/54.scala | <reponame>SethTisue/Project-Euler
package net.tisue.euler
// The input file contains one thousand random poker hands dealt to two players.
// How many hands does player one win?
// (note: glguy's Haskell solution on the Euler forum is more elegant)
class Problem54 extends Problem(54, solution = "376"):
case class... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/29.scala | <reponame>SethTisue/Project-Euler<filename>src/test/scala/net/tisue/euler/29.scala<gh_stars>1-10
package net.tisue.euler
import Primes.*
// How many distinct terms are in the sequence generated by a^b for
// 2 <= a <= 100 and 2 <= b <= 100?
class Problem29 extends Problem(29, "9183"):
def solve =
def factors(n:... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/69.scala | <reponame>SethTisue/Project-Euler
package net.tisue.euler
import Primes.*
// Euler's Totient function phi(n) is used to determine the number of numbers less than n which are
// relatively prime to n. n=6 produces a maximum n/phi(n) for n <= 10. Find the value of n <=
// 1,000,000 for which n/phi(n) is a maximum.
/... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/5.scala | <reponame>SethTisue/Project-Euler
package net.tisue.euler
// What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?
class Problem5 extends Problem(5, "232792560"):
// en.wikipedia.org/wiki/Least_common_multiple#Calculating_the_least_common_multiple
def lcm(a: BigInt, b: BigInt): ... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/58.scala | package net.tisue.euler
import Primes.*
// Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side
// length 7 is formed.
// 37 36 35 34 33 32 31
// 38 17 16 15 14 13 30
// 39 18 5 4 3 12 29
// 40 19 6 1 2 11 28
// 41 20 7 8 9 10 27
// 42 21 22 23 24 25 26
// 43 44 45 46 ... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/88.scala | package net.tisue.euler
import Primes.*
// A natural number, N, that can be written as the sum and product of a given set of at least two
// natural numbers, {a1, a2, ... , ak} is called a product-sum number: N = a1 + a2 + ... + ak = a1
// * a2 * ... * ak.
// For a given set of size, k, we shall call the smallest N w... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/85.scala | <gh_stars>1-10
package net.tisue.euler
// By counting carefully it can be seen that a rectangular grid
// measuring 3 by 2 contains eighteen rectangles: Although there
// exists no rectangular grid that contains exactly two million
// rectangles, find the area of the grid with the nearest solution.
// Analytically, 1... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/33.scala | package net.tisue.euler
// The fraction 49/98 is a curious fraction, as an inexperienced
// mathematician in attempting to simplify it may incorrectly believe
// that 49/98 = 4/8, which is correct, is obtained by cancelling the
// 9s. We shall consider fractions like, 30/50 = 3/5, to be trivial
// examples. There ar... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/51.scala | <gh_stars>1-10
package net.tisue.euler
import Primes.*
// By replacing the 1st digit of *57, it turns out that six of the possible values: 157, 257, 457,
// 557, 757, and 857, are all prime.
// By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit number is the
// first example having seven p... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/105.scala | package net.tisue.euler
// Identify the special sum sets in sets.txt and find the sum of their sums.
class Problem105 extends Problem(105, "73702"):
type SumSet = List[List[Int]]
def augment(ss: SumSet, x: Int) =
if ss.isEmpty then
List(List(x))
else
(ss.head :+ x) +: ss.sliding(2).collect{cas... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/91.scala | <reponame>SethTisue/Project-Euler
package net.tisue.euler
// The points P (x1, y1) and Q (x2, y2) are plotted at integer co-ordinates and are joined to the
// origin, O(0, 0), to form triangle OPQ. Given that 0 <= x1, y1, x2, y2 <= 50, how many right
// triangles can be formed?
class Problem91 extends Problem(91, "1... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/41.scala | <gh_stars>1-10
package net.tisue.euler
import Primes.*
// We shall say that an n-digit number is pandigital if it makes use
// of all the digits 1 to n exactly once. For example, 2143 is a
// 4-digit pandigital and is also prime.
// What is the largest n-digit pandigital prime that exists?
// It's not necessary to c... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/204.scala | package net.tisue.euler
import Primes.*
class Problem204 extends Problem(204, "2944730"):
val ps = primes.takeWhile(_ < 100)
def count(n: Long, p: Int): Int =
if n * p > 1000000000L then
0
else
1 + ps.dropWhile(_ < p)
.map(count(n * p, _))
.sum
def solve = count(1, 1)
... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/70.scala | <filename>src/test/scala/net/tisue/euler/70.scala
package net.tisue.euler
import Primes.*
// Find the value of n, 1 < n < 10^7, for which the totient phi(n) is a permutation of n and the ratio
// n/phi(n) produces a minimum.
// We're looking for a number that's a product of exactly two fairly large primes.
// That's... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/10.scala | <reponame>SethTisue/Project-Euler<gh_stars>1-10
package net.tisue.euler
import Primes.*
// Find the sum of all the primes below two million.
// this is much too slow: primes.takeWhile(_ < 2000000)
// so we use the prime sieve.
class Problem10 extends Problem(10, "142913828922"):
def solve = primesBelow(2000000).map... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/19.scala | <gh_stars>1-10
package net.tisue.euler
// How many Sundays fell on the first of the month during the
// twentieth century (1 Jan 1901 to 31 Dec 2000)?
class Problem19 extends Problem(19, "171"):
// The Java APIs for this are imperative so it's a bit awkward
import java.util.Calendar
def centuryBegin =
val c... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/87.scala | <reponame>SethTisue/Project-Euler<gh_stars>1-10
package net.tisue.euler
import Primes.*
// How many numbers below fifty million can be expressed as the sum of a prime square, prime cube, and
// prime fourth power? (There are exactly four such numbers below fifty.)
class Problem87 extends Problem(87, "1097343"):
d... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/72.scala | package net.tisue.euler
import Primes.*
// How many elements would be contained in the set of reduced proper fractions with denominator <=
// 1,000,000? (for denominator <= 8, there are 21)
// This is basically asking us for a sum of totients. See
// http://en.wikipedia.org/wiki/Euler%27s_totient_function
// (The... |
SethTisue/Project-Euler | src/main/scala/net/tisue/euler/BigRational.scala | <gh_stars>1-10
package net.tisue.euler
/// from Programming in Scala book, but converted to use BigInt
import annotation.alpha
class BigRational(n: BigInt, d: BigInt):
require(d != 0)
private val g = gcd(n.abs, d.abs)
private val Precision = 17
val numer = n / g
val denom = d / g
def this(n: BigInt) = th... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/123.scala | <gh_stars>1-10
package net.tisue.euler
import Primes.*
class Problem123 extends Problem(123, "21035"):
def r(n: Int) =
val p = BigInt(primes(n - 1))
((p - 1).pow(n) + (p + 1).pow(n)) % (p * p)
def solve =
def tooBig(n: Int) = r(n * 2 - 1) > 10000000000L // 10 ^ 9
val lowerBound =
LazyList.it... |
SethTisue/Project-Euler | src/test/scala/net/tisue/euler/121.scala | package net.tisue.euler
class Problem121 extends Problem(121, "2269"):
// the inputs are how many discs of each color I have drawn so far
def winChance(blue: Int, red: Int): BigRational =
if blue + red == 15 then
if blue > red then BigRational(1) else BigRational(0)
else
val rounds = blue + red... |
tamani-coding/scala-akka-http-server-example | src/main/scala/Main.scala | // akka specific
import akka.actor.typed.ActorSystem
import akka.actor.typed.scaladsl.Behaviors
// akka http specific
import akka.http.scaladsl.Http
import akka.http.scaladsl.model._
import akka.http.scaladsl.server.Directives.*
// spray specific (JSON marshalling)
import akka.http.scaladsl.marshallers.sprayjson.SprayJ... |
woggioni/sbt-delombok | DelombokJavadoc/src/main/scala/com/thoughtworks/sbt/DelombokJavadoc.scala | package com.thoughtworks.sbt
import com.thoughtworks.sbt.Delombok.autoImport._
import sbt.Keys._
import sbt._
/**
* @author 杨博 (<NAME>)
*/
object DelombokJavadoc extends AutoPlugin {
override def trigger = allRequirements
override def requires: Plugins = Delombok
override def projectSettings: Seq[Def.Sett... |
woggioni/sbt-delombok | build.sbt | organization in ThisBuild := "com.thoughtworks.sbt"
val Delombok = project
val DelombokJavadoc = project.dependsOn(Delombok)
|
woggioni/sbt-delombok | Delombok/src/main/scala/com/thoughtworks/sbt/Delombok.scala | <reponame>woggioni/sbt-delombok
package com.thoughtworks.sbt
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin
/**
* @author 杨博 (<NAME>)
*/
object Delombok extends AutoPlugin {
import autoImport._
override def trigger = allRequirements
override def requires = JvmPlugin
override def projectSe... |
woggioni/sbt-delombok | DelombokJavadoc/build.sbt | <reponame>woggioni/sbt-delombok<filename>DelombokJavadoc/build.sbt
sbtPlugin := true |
mscharley/drupal-deps | build.sbt | name := "drupal-deps"
scalaVersion := "2.11.8"
|
mscharley/drupal-deps | src/main/scala/Main.scala | import java.nio.file._
import scala.collection.JavaConverters._
object Main {
def main(args: Array[String]): Unit = {
val start =
if (args.length > 0) Paths.get(args(0))
else Paths.get("./")
val modules = Files
.walk(start)
.iterator()
.asScala
.filter { f =>
f.... |
mscharley/drupal-deps | src/main/scala/DrupalModule.scala | <reponame>mscharley/drupal-deps<gh_stars>0
import java.nio.charset.Charset
import java.nio.file.{Files, Path}
import scala.collection.JavaConverters._
object DrupalModule {
private val utf8 = Charset forName "UTF-8"
def fromFile(file: Path): DrupalModule[String] = {
val lines = Files.readAllLines(file, ut... |
vaibkv/websockets-exercise-someone-askedme-in-an-interview | src/main/scala/Server/Utils.scala | package Server
import java.io.{BufferedReader, InputStreamReader, PrintStream}
import java.net.Socket
object Utils {
def getInputStream(socket: Socket): BufferedReader = {
new BufferedReader(new InputStreamReader(socket.getInputStream))
}
def getOutputStream(socket: Socket): PrintStream = {
new PrintS... |
vaibkv/websockets-exercise-someone-askedme-in-an-interview | src/main/scala/Server/UserWorker.scala | <filename>src/main/scala/Server/UserWorker.scala
package Server
import java.net.Socket
import scala.concurrent.Future
import Utils._
import InitServer._
import scala.concurrent.ExecutionContext.Implicits.global
case class UserWorker(socket: Socket) {
var userName = ""
var isLoggedIn = false
//list - her maita... |
vaibkv/websockets-exercise-someone-askedme-in-an-interview | build.sbt | <filename>build.sbt
name := "segment-exercise"
version := "0.1"
scalaVersion := "2.13.6" |
vaibkv/websockets-exercise-someone-askedme-in-an-interview | src/main/scala/Server/InitServer.scala | package Server
import java.io.InputStreamReader
import java.net.{ServerSocket, Socket}
import Utils._
import java.util.concurrent.ConcurrentHashMap
import scala.collection.JavaConverters.mapAsScalaConcurrentMapConverter
import scala.collection.mutable.ListBuffer
object InitServer extends App {
//initial list
va... |
tomis9/cookbook | scratchpad/scala/fileWriter.scala | import java.io._
object fileWriter {
def main(args: Array[String]) {
val pw = new PrintWriter(new File("hello.txt" ))
val to_write = "some data to write"
pw.write(to_write)
pw.close
}
}
|
tomis9/cookbook | scratchpad/scala/db.scala | import java.sql.{Connection,DriverManager}
object ScalaJdbcConnectSelect extends App {
def main(args: Array[String]) {
val url = "jdbc:mysql://localhost:8889/mysql"
val driver = "com.mysql.jdbc.Driver"
val username = "dyrkat"
val password = "<PASSWORD>!"
var connection:Connection = _
try {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.