This file contains 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 contracts | |
import _root_.algebra.CommutativeGroup | |
import _root_.algebra.ring.Signed | |
import _root_.algebra.ring.Field | |
import spire.algebra.VectorSpace | |
import cats.syntax.group.* | |
import spire.syntax.vectorSpace.* |
This file contains 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 wut | |
import scala.language.higherKinds | |
import cats.{ Functor } | |
object FreeShit { | |
/** | |
*/ | |
case class Done[F[_]: Functor, A](a: A) extends Free[F, A] |
This file contains 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
// Jeremie Miserez <jeremie@miserez.org>, 2016 | |
// | |
// A little bit of Javascript to let you export your Google Music library, playlists, and album track lists :) | |
// | |
// I posted this as an answer here: http://webapps.stackexchange.com/questions/50311/print-playlist-from-google-play-music | |
// | |
// 1. Go to: https://play.google.com/music/listen#/all (or your playlist) | |
// | |
// 2. Open a developer console (F12 for Chrome). Paste | |
// code below into the console. |
This file contains 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 scala.language.postfixOps | |
def maxProfitScan(prices: List[Int]): Int = { | |
require(prices.size >= 2) | |
final case class State(hi: Int, lo: Int, pl: Option[Int] = None) { | |
def profit: Int = hi - lo | |
} |
This file contains 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
/** res ipsa loquitur */ | |
trait Module { | |
trait Repo { | |
type T | |
final def save(t: T): String = s"saved $t" | |
} | |
abstract class ActiveRepo[R <: Repo](val repo: R) { |
This file contains 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
object XmlToJson { | |
import scala.language.postfixOps | |
import scala.xml._ | |
import upickle.{ Js, json } | |
def apply(nodes: NodeSeq, excludes: NodeSeq = NodeSeq.Empty): String = { | |
def attrsToTaggedJsVals(attrs: MetaData): List[(String, Js.Str)] = attrs.asAttrMap.toList map { | |
case (tag, value) => tag -> Js.Str(value) |
This file contains 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.time.temporal.ChronoUnit | |
object timescratch { | |
import java.time._ | |
val myTz = ZoneId.systemDefault //> myTz : java.time.ZoneId = America/Los_Angeles | |
val zTz = ZoneId of "Z" //> zTz : java.time.ZoneId = Z | |
def zDaySpan(dayStart: ZonedDateTime) = { |
This file contains 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
/* | |
* Copyright 2014-2016 Panavista Technologies, LLC | |
* | |
* 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 |
This file contains 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 scratch | |
// scalatest 2.0.M8 | |
import org.scalatest.WordSpec | |
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.concurrent.AsyncAssertions | |
import org.scalatest.time.{ Span, Millis } | |
class WaiterSpec extends WordSpec with ShouldMatchers with AsyncAssertions { |
This file contains 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
// requires Scala 2.10.0-M7 | |
// updated for Scala 2.10-RC5 | |
def kind[A: scala.reflect.runtime.universe.TypeTag]: String = { | |
import scala.reflect.runtime.universe._ | |
def typeKind(sig: Type): String = sig match { | |
case PolyType(params, resultType) => | |
(params map { p => | |
typeKind(p.typeSignature) match { | |
case "*" => "*" | |
case s => "(" + s + ")" |
NewerOlder