View RuntimeTypeTag.scala
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.reflect.runtime.universe._ | |
import scala.reflect.api | |
def runtimeTypeTagOf(name: String, parent: ClassLoader, url: java.net.URL): TypeTag[_] = | |
runtimeTypeTagOf(name, parent, Seq(url)) | |
def runtimeTypeTagOf(name: String, parent: ClassLoader, urls: Seq[java.net.URL]): TypeTag[_] = | |
runtimeTypeTagOf(name, new java.net.URLClassLoader(urls.toArray, parent)) | |
def runtimeTypeTagOf(name: String, cl: ClassLoader): TypeTag[_] = { | |
val c = Class.forName(name, true, cl) | |
val mirror: Mirror = runtimeMirror(cl) |
View TypeTag2ClassTag.scala
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 reflect.runtime.universe._ | |
import reflect.ClassTag | |
def typeTag2ClassTag[T: TypeTag]: ClassTag[T] = { | |
ClassTag[T]( typeTag[T].mirror.runtimeClass( typeTag[T].tpe ) ) | |
} |
View SimilarSchema.scala
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 object spark { | |
import org.apache.spark.sql.types.StructType | |
implicit class StructTypeExtension(schema: StructType) { | |
import org.apache.spark.sql.types.StructField | |
implicit def similar(other: StructType): Boolean = _similar(schema, other) | |
implicit val fieldOrdering: Ordering[StructField] = Ordering.by(field => field.name) | |
private final def _similar(_this: StructType, _other: StructType): Boolean = |
View ProductExtension.scala
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.reflect.runtime.universe.TypeTag | |
implicit class ProductExtension[T <: Product : TypeTag](o: T) { | |
def productElementNames: Iterator[String] = { | |
import scala.reflect.runtime.universe._ | |
typeOf[T].members | |
.collect { case m: MethodSymbol if m.isCaseAccessor => m.name.toString } | |
.toList.reverse.toIterator | |
} | |
View SparkExampleTests.scala
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 com.example | |
import utest._ | |
object SparkExampleTests extends TestSuite { | |
import scala.util.{Try,Success,Failure} | |
import org.apache.spark.sql.SparkSession | |
val _spark: Try[SparkSession] = | |
Try { |
View Configs.scala
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
//file: project/Configs.scala | |
import sbt._ | |
object Configs { | |
val FunctionalTest = config("ft") extend (Test) | |
val AcceptanceTest = config("at") extend (Test) | |
val PerformanceTest = config("pt") extend (Test) | |
val Tools = config("tools") extend (Test) | |
} |
View sbt_disable_publishing.sbt
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
def disablePublishing: Seq[Setting[_]] = | |
Seq( | |
publish/skip := true, | |
publishLocal/skip := true | |
) |
View SlickConfig.scala
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
trait SlickConfig { | |
import scala.util.{Try, Success, Failure} | |
private val RegexDB2 = "^jdbc:(db2):.*//(.*):(.*)/([^;]*)[?:;](.*)".r | |
private val RegexDerby = "^jdbc:(derby):.*//(.*):(.*)/([^;]*)[?:;](.*)".r | |
private val RegexH2 = "^jdbc:(h2):(?:mem):()()([^;]*)[?:;](.*)".r | |
private val RegexHsqlDB = "^jdbc:(hsqldb):.*//(.*):(.*)/([^;]*)[?:;](.*)".r | |
private val RegexSqlServer = "^jdbc:(sqlserver)://(.*):(.*);DatabaseName=([^;]*)[?:;](.*)".r | |
private val RegexjTDS = "^jdbc:(jtds):sqlserver://(.*):(.*)/([^;]*)[?:;](.*)".r | |
private val RegexMySQL = "^jdbc:(mysql):.*//(.*):(.*)/([^;]*)[?:;](.*)".r |
View sequence.scala
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.util.{Try,Success,Failure} | |
def sequence[T](seq: Seq[Try[T]]): Try[Seq[T]] = | |
seq | |
.foldRight(Try(List.empty[T])) { | |
case (item, acc) => for { a <- acc; i<- item } yield i :: a | |
} |
View yaml_solve_references.rs
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
#![allow(unused_parens)] | |
use anyhow::{Context,Result, anyhow}; | |
use clap::{arg, App, AppSettings}; | |
use std::ffi::OsStr; | |
fn main() -> Result<()> { | |
let matches = App::new("mkvm") | |
.about("Make virtual machines easily!") | |
.setting(AppSettings::SubcommandRequiredElseHelp) |
NewerOlder