This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // scala 2.13.6 | |
| // ammonite 2.4.0 | |
| import scala.math.Integral | |
| import scala.math.{BigDecimal,BigInt} | |
| object NumericUtil { | |
| def gcd[T :Integral](a:T,b:T):T = { | |
| if(b == 0){ | |
| a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // scala 2.13.6 | |
| // ammonite 2.4.0 | |
| import scala.math.Integral | |
| import scala.math.{ BigDecimal, BigInt } | |
| object NumericUtil { | |
| def gcd[T: Integral](a: T, b: T): T = { | |
| if (b == 0) { | |
| a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // scala 2.13.6 | |
| // ammonite 2.4.0 | |
| def bubbleSort[T: Ordering](orderables: Seq[T]): Seq[T] = { | |
| swapRec(orderables).splitAt(orderables.length - 1) match { | |
| case (Nil, Nil) => Nil | |
| case (Nil, head) => head | |
| case (head, last) => bubbleSort(head) ++ last | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // scala 2.13.6 | |
| // ammonite 2.4.0 | |
| import $ivy.`org.typelevel::cats-effect:3.1.1` | |
| import $ivy.`org.typelevel::cats-core:2.2.0` | |
| import cats.effect.IO | |
| import cats.syntax.apply._ | |
| import cats.syntax._ | |
| import scala.concurrent.duration._ | |
| import cats.effect.unsafe.implicits.global |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl https://cli-assets.heroku.com/apt/release.key | sudo apt-key add - | |
| sudo apt update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Stack | |
| import java.util.Deque | |
| import scala.collection.mutable.ArrayDeque | |
| // scala 2.13.6 | |
| // ammonite 2.4.0 | |
| def hammingDistance(one: Int, another: Int): Int = { | |
| // note: xor γ§ η°γͺγθ ε士γ γγγ©γ°γη«γ€ | |
| (one ^ another).toBinaryString.count { s => s == '1' } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension[T<:Tuple] (i:T) { | |
| def flatten = flattenTuple(i) | |
| private def flattenTuple[A <: Tuple](tuple: A): FlattenTypeOf[A] = { | |
| val flatten = tuple match { | |
| case h *: remains => | |
| h match { | |
| case subtpl: Tuple => flattenTuple(subtpl) ++ flattenTuple(remains) | |
| case _ => h *: flattenTuple(remains) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.jetbrains.jwm.examples; | |
| import org.jetbrains.jwm.*; | |
| import org.jetbrains.skija.*; | |
| import java.util.*; | |
| import java.util.concurrent.*; | |
| import java.util.function.*; | |
| import java.util.stream.*; | |
| import java.io.File; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HMODULE hUser = GetModuleHandleA("user32.dll"); | |
| if (hUser) | |
| { | |
| pfnSetWindowCompositionAttribute setWindowCompositionAttribute = (pfnSetWindowCompositionAttribute)GetProcAddress(hUser, "SetWindowCompositionAttribute"); | |
| if (setWindowCompositionAttribute) | |
| { | |
| ACCENT_POLICY accent = { ACCENT_ENABLE_BLURBEHIND, 0, 0, 0 }; | |
| WINDOWCOMPOSITIONATTRIBDATA data; | |
| data.Attrib = WCA_ACCENT_POLICY; | |
| data.pvData = &accent; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import $ivy.`com.chuusai::shapeless:2.3.7` | |
| import shapeless._ | |
| trait VecLike[T]{ | |
| def dim:Int | |
| def add(a:T,b:T):T | |
| def sub(a:T,b:T):T | |
| } | |
| implicit def doubleVec2D:VecLike[(Double,Double)] = | |
| new VecLike[(Double,Double)] { |
OlderNewer