Skip to content

Instantly share code, notes, and snippets.

View retronym's full-sized avatar

Jason Zaugg retronym

View GitHub Profile
package demo
import java.io.{File, PrintWriter, StringWriter}
import scala.annotation.nowarn
import scala.reflect.internal.Flags.STATIC
import scala.reflect.internal.util.ScalaClassLoader.URLClassLoader
import scala.tools.nsc.backend.jvm.AsmUtils
import scala.tools.nsc.{Global, Phase}
import scala.tools.nsc.plugins.{Plugin, PluginComponent}
import scala.tools.nsc.transform.TypingTransformers
@retronym
retronym / log.txt
Created November 10, 2022 06:43
SBT bill of materials
tail local.sbt project/local.sbt
==> local.sbt <==
TaskKey[Unit]("printBillOfMaterials") := (Def.taskDyn {
val proj = thisProject.value
val filter = ScopeFilter(inProjects(proj.aggregate: _*))
Def.task {
(updateSbtClassifiers.value :: update.all(filter).value.toList).flatMap(_.configurations).flatMap(_.modules).flatMap(_.artifacts).flatMap(_._1.url).distinct.foreach(println)
()
}
}).value
@retronym
retronym / Kayo.bsstrategy
Last active October 26, 2022 06:26
Beardie Config for Stan Sports and Kayo (https://github.com/Bonapara/beardie)
BSStrategy = {
version: 1,
displayName: "Kayo",
accepts: {
method: "predicateOnTab",
format: "%K LIKE[c] '*kayosports.com.au/*/*'",
args: ["URL"]
},
toggle: function () { console.log("toggle"); document.querySelector('[aria-label="Toggle play/pause"]').click(); },
pause: function () { console.log("pause") },
class covariant extends scala.annotation.StaticAnnotation with scala.annotation.TypeConstraint
object SetFactory {
def empty[K]: Set[K @covariant] = Set.empty[K @covariant]
}
class Client {
val x = if (true) Set("") else SetFactory.empty
}
@retronym
retronym / IteratorLinter.scala
Created January 16, 2022 23:42
iterator escape
package demo.compat
import scala.collection.{GenIterableLike, mutable}
import scala.tools.nsc.plugins.{Plugin, PluginComponent}
import scala.tools.nsc.{Global, Phase, Settings}
object IteratorLinter {
def main(args: Array[String]): Unit = {
println("go!")
val g = new Global(new Settings) {
@retronym
retronym / gh-markdown-api.sh
Last active October 8, 2021 01:35
Render the body of a GitHub issue in a local HTML file
curl --silent --fail https://raw.githubusercontent.com/sindresorhus/github-markdown-css/gh-pages/github-markdown.css > /tmp/gh.css && (
echo '<html><head><link rel="stylesheet" href="/tmp/gh.css"/><style>@page { size: A4 landscape; }</style>
</head><body><div class="markdown-body">' && \
gh api repos/lightbend/scala-team/issues/188 -t '{{.body}}' |
gh api --field text=@- /markdown && \
echo '</div></body></html>' \
) > /tmp/out.html
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-gpu --headless --print-to-pdf-no-header --print-to-pdf=/tmp/out.pdf /tmp/out.html
@retronym
retronym / M.scala
Last active September 14, 2021 01:50
Rich Map woes
class M {
type AnyIterableOps[+A, Repr] = collection.IterableOps[A, Any, Repr]
def richMap[K, V, CC <: collection.MapOps[K, V, AnyIterableOps, CC]] = ()
def foo(m: scala.collection.immutable.Map[String, String]): AnyIterableOps[(String, String), scala.collection.immutable.Map[String, String]] = m
richMap[Int, String, scala.collection.immutable.Map[Int, String]]
}
object FindCollectionReturningHofs extends App {
import scala.tools.nsc._
val global = new Global(new Settings)
import global._
import global.settings
settings.usejavacp.value = true
settings.embeddedDefaults(getClass.getClassLoader)
+++ MANIFEST.MF
Manifest-Version: 1.0
Automatic-Module-Name: scala.tools.nsc
Bundle-ManifestVersion: 2
Bundle-Name: Scala Compiler
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-SymbolicName: org.scala-lang.scala-compiler
Bundle-Version: 2.12.15.v20210703-050957-52d9dbd
Class-Path: scala-reflect.jar scala-library.jar
[
{
"jmhVersion" : "1.29",
"benchmark" : "org.sample.Jdk11PerfRegressionBenchmark.setPhase",
"mode" : "avgt",
"threads" : 1,
"forks" : 2,
"jvm" : "/Users/jz/.jabba/jdk/[email protected]/Contents/Home/bin/java",
"jvmArgs" : [
],