Skip to content

Instantly share code, notes, and snippets.

@richdougherty
richdougherty / connections-categoriser.user.js
Created September 22, 2024 08:22
Connections Categoriser userscript
// ==UserScript==
// @name Connections Categoriser
// @description Adds a category function to the NYT Connections game
// @match https://www.nytimes.com/games/connections
// @namespace http://tampermonkey.net/
// @version 0.1.0
// @grant none
// ==/UserScript==
// MIT License
@richdougherty
richdougherty / which-hunt.sh
Last active September 7, 2023 19:29
which-hunt - an alternative to 'which' that traces symlinks and shims
#!/bin/bash
# Copyright 2023 Rich Dougherty
# which-hunt - an alternative to 'which' that traces symlinks and shims
# - Examples -
#
# $ which java
# /usr/bin/java
#
@richdougherty
richdougherty / tls.txt
Last active April 20, 2018 00:01
Play 2.3.10 support for SSL/TLS with different versions of Java
Tested with https://github.com/rbsec/sslscan v1.11.11
===== Java 1.6.0_45 =====
Testing SSL server localhost on port 9443 using SNI name localhost
TLS Fallback SCSV:
Server does not support TLS Fallback SCSV
trait RequestFactory {
def createRequestHeader(
connection: RemoteConnection,
method: String,
target: RequestTarget,
version: String,
headers: Headers,
attrs: TypedMap): RequestHeader
}
@richdougherty
richdougherty / GreeterService.scala
Last active April 6, 2018 04:45
Richer types for akka-grpc generated code
trait GreeterService {
...
}
object GreeterService extends GreeterServiceCompanion[GreeterService] {
override val name = "helloworld.GreeterService"
...
}
class GreeterServiceClient(channel: Channel, options: CallOptions)(implicit mat: Materializer, ex: ExecutionContext) extends GreeterService {
@richdougherty
richdougherty / Handler.scala
Created April 3, 2018 22:18
Exploring more flexible handlers in Play
trait Handler
trait HandlerOp[+A]
case class HandlerVal[+A](value: A) extends HandlerOp[A]
case class HandlerThunk[+A](thunk: () => A) extends HandlerOp[A]
case class HandlerFuture[+A](future: Future[A]) extends HandlerOp[A]
case class HandlerEither[+A,B<:A,C<:A](either: Either[B,C]) extends HandlerOp[A]
object Handler {
trait RequestHeader
@richdougherty
richdougherty / gist:91649b8efd6304376ed4187cc427a6d0
Created February 27, 2018 21:31
Example of capturing logging output in Play Framework
/*
* Copyright (C) 2009-2017 Lightbend Inc. <https://www.lightbend.com>
*/
package play.it.http
import ch.qos.logback.classic.Logger
import ch.qos.logback.classic.spi.ILoggingEvent
import ch.qos.logback.core.AppenderBase
import org.slf4j.LoggerFactory
import org.specs2.execute.AsResult
@richdougherty
richdougherty / notes.md
Last active November 23, 2017 20:48
Play/Akka Coordinated Shutdown notes

Use CS to shut down Server and Application in Play

Changes to ApplicationLifecycle usage

  • Application components systems can continue to use ApplicationLifecycle
  • Can now also use CoordinatedShutdown if want richer API
    • Suggest that we don't change ApplicationLifecycle API to expose phases (yet)
  • Application can now create its own ApplicationLifecycle from the ActorSystem
    • Calls ApplicationLifecycle.stop() during a phase of CS
  • ApplicationLifecycle manages ordering (as suggested by Patrik)
@richdougherty
richdougherty / HandlerPipeline.scala
Created November 7, 2017 19:12
Plan for refactoring WebCommands
// Change DefaultHttpRequestHandler to take a pipeline
class DefaultHttpRequestHandler(
pipeline: Seq[Handler],
router: Router,
errorHandler: HttpErrorHandler,
configuration: HttpConfiguration,
filters: Seq[EssentialFilter]) extends HttpRequestHandler {
...
}
@richdougherty
richdougherty / BuildSettings.scala
Created October 9, 2017 02:45
Example of custom ProblemFilter
mimaBinaryIssueFilters ++= {
def excludeSymbols[P <: ProblemRef](
name: String,
symbolFilter: String => Boolean)(
implicit problemTag: ClassTag[P]): ProblemFilter = {
{ problem: Problem =>
// Check the problem type
if (problemTag.runtimeClass.isAssignableFrom(problem.getClass)) {
// Check the problem name