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
| //> using scala 2.13 | |
| //> using dep org.playframework::play-json:3.0.6 | |
| // because we were thinking through how to model a parameter in govuk-frontend | |
| // which uses an explicit null as a sentinel for "display nothing" but where | |
| // nothing at all is passed then it should fallback to a default. | |
| import play.api.libs.json._ | |
| import play.api.libs.json.Reads._ | |
| import play.api.libs.functional.syntax._ |
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
| //> using scala 2.13 | |
| //> using dep org.playframework::play-json:3.0.5 | |
| //> using dep com.lihaoyi::pprint:0.9.3 | |
| import play.api.libs.json._ | |
| sealed trait Content | |
| case object Empty extends Content | |
| case class Text(value: String) extends Content | |
| case class HtmlContent(value: String) extends Content |
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
| //> using scala 3 | |
| //> using toolkit latest | |
| import sttp.client4.* | |
| import scala.annotation.tailrec | |
| @main def main(): Unit = { | |
| val compromisedPackages = | |
| """ | |
| |@ahmedhfarag/ngx-perfect-scrollbar 20.0.20 |
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
| const { timeOrigin } = window.performance | |
| const unsentEvents = [] | |
| console.log("Analytics loaded") // shows that it is only run once, even though imported into multiple scripts | |
| document.addEventListener("visibilitychange", function sendAnalytics() { | |
| if (document.visibilityState === "hidden") { | |
| const events = unsentEvents.splice(0) |
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
| //> using scala 3.3 | |
| //> using toolkit typelevel:0.1.29 | |
| //> using dep com.softwaremill.macwire::macros:2.6.4 | |
| //> using dep org.scalameta:scalameta_2.13:4.7.7 | |
| //> using dep com.lihaoyi::pprint:0.9.0 | |
| import com.softwaremill.macwire.* | |
| import cats.effect.* | |
| import cats.syntax.all.* |
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
| //> using scala 2.13 | |
| //> using dep "org.scalameta::scalameta:4.7.7" | |
| //> using dep "com.lihaoyi::pprint:0.9.0" | |
| //> using dep "org.eclipse.jgit:org.eclipse.jgit:6.10.0.202406032230-r" | |
| //> using dep "org.eclipse.jgit:org.eclipse.jgit.ssh.apache.agent:6.10.0.202406032230-r" | |
| //> using toolkit 0.5.0 | |
| import java.nio.file._ | |
| import scala.meta.internal.semanticdb.{Locator, MethodSignature, SymbolInformation, TypeRef, ValueSignature} | |
| import scala.io.Source |
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
| // Note - updated to work with the HMRC Frontend implementation | |
| // https://github.com/hmrc/play-frontend-hmrc#adding-accessible-autocomplete-css-and-javascript | |
| if (typeof HMRCAccessibleAutocomplete != 'undefined' && document.querySelector('[data-module="hmrc-accessible-autocomplete"]') != null) { | |
| document.querySelectorAll('[data-module="hmrc-accessible-autocomplete"]').forEach(function (originalSelect) { | |
| // load autocomplete - now handled by the HMRC component wrapper in Twirl | |
| // accessibleAutocomplete.enhanceSelectElement({ | |
| // selectElement: originalSelect, | |
| // showAllValues: true |
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 uk.gov.hmrc.zap | |
| import uk.gov.hmrc.zap.ZapRelease.ZapVersion | |
| import java.io.File | |
| import java.net.URI | |
| import scala.sys.process._ | |
| import scala.concurrent.duration._ | |
| import cats.effect.{IO, Resource} |
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
| //> using dep com.lihaoyi::requests:0.9.0 | |
| //> using toolkit 0.5.0 | |
| //> using file RunZap.scala | |
| //> using mainClass getZap | |
| @main def getZap = | |
| os.write.over( | |
| os.pwd / "resources" / s"ZAP_${zapVersion}_Core.zip", | |
| requests.get.stream(s"https://github.com/zaproxy/zaproxy/releases/download/v$zapVersion/ZAP_${zapVersion}_Core.zip"), | |
| createFolders = true |
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
| //> using scala 3 | |
| trait Key { type Value; trait Provided } | |
| case class Person[+T] private(underlying: Map[Key, Any]): | |
| def apply(k: Key): Option[k.Value] = | |
| underlying.get(k).map(_.asInstanceOf[k.Value]) | |
| def set(k: Key, v: k.Value): Person[T & k.Provided] = | |
| Person[T & k.Provided](underlying + (k -> v)) |
NewerOlder