Skip to content

Instantly share code, notes, and snippets.

@ches
ches / docker-entrypoint.sh
Created June 21, 2023 14:29
Java app Docker entrypoint script, with a simple JVM flags file
#!/bin/bash
# Contains a few particularities of $DAYJOB's infra environment, but you get the, erm, gist.
set -o errexit
declare -r app_jar=/opt/myapp/my-app.jar
declare -r consul_template_config=/etc/consul.d/template/config.json
declare -r flags_file="${JVM_FLAGS_FILE:=/etc/myapp/application.ini}"
# For JMX's weird connection negotiation in a container world
@ches
ches / CustomWartsPlugin.scala
Last active February 24, 2023 23:49
sbt mini-plugin for a tool needing compile-time only Maven dependencies, in this case custom WartRemover extension lints
import sbt._, Keys._
import wartremover.WartRemover, WartRemover.autoImport.wartremoverClasspaths
trait CustomWartsKeys {
lazy val customWartsVersion = settingKey[String]("Version of the my-warts library dependency")
}
/** sbt plugin to integrate a package of custom WartRemover extension lints into a project's build.
*
* The purpose of an sbt plugin for this is to solve a problem with WartRemover's [[$custom-warts
@ches
ches / tasks.json
Last active April 21, 2021 14:50
A starter VS Code tasks.json file for Bloop, for Scala Metals projects
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "bloop: compile all",
"type": "shell",
"command": "bloop compile $(bloop projects)",
"group": { "kind": "build", "isDefault": true },
@ches
ches / ExitStatus.scala
Created February 16, 2019 12:08
A cute little application exit status value class
import scala.language.implicitConversions
/** A process exit status. */
sealed abstract class ExitStatus(val code: Int) extends Product with Serializable
/** Exit statuses used conventionally across components. */
object ExitStatus {
case object Success extends ExitStatus(0)
case object Error extends ExitStatus(1)
case object BadUsage extends ExitStatus(2) // 2 is conventional, e.g. bash builtins, grep

Keybase proof

I hereby claim:

  • I am ches on github.
  • I am ches (https://keybase.io/ches) on keybase.
  • I have a public key ASCIZr7iDy6SDxfmm4ZmlI-IfCYak4OLkqMWqBI3lp8f7Qo

To claim this, I am signing this object:

@ches
ches / futureutils.scala
Created June 2, 2016 13:03
Extra Future combinators for Scala
import java.util.concurrent.atomic.AtomicInteger
import scala.collection.generic.CanBuildFrom
import scala.concurrent._
import scala.util.{ Failure, Success }
/*
* Enrichments for some useful Future combinators absent from the standard
* library.
*
@ches
ches / .ctags
Last active July 16, 2018 22:10 — forked from mfwarren/.ctags
my .ctags syntax file for Groovy language (exuberant-ctags)
--langdef=groovy
--langmap=groovy:.groovy
--regex-groovy=/^[ \t]*package[ \t]+([a-zA-Z0-9.-_]+)/\1/p,package/
--regex-groovy=/^[ \t]*(private|public)?[ \t]*(abstract|final|static)?[ \t]*class[ \t]+([A-Za-z0-9_]+)/\3/c,class/
--regex-groovy=/^[ \t]*(private|public)?[ \t]*interface[ \t]+([A-Za-z0-9_]+)/\2/i,interface/
--regex-groovy=/^[ \t]*(private|public)?[ \t]*trait[ \t]+([A-Za-z0-9_]+)/\2/t,trait/
--regex-groovy=/^[ \t]*(private|public)?[ \t]*enum[ \t]+([A-Za-z0-9_]+)/\2/e,enum/
--regex-groovy=/^[ \t]*[(abstract|final|static) \t]*((def|void|byte|int|short|long|float|double|boolean|char|[A-Z][a-zA-Z0-9_]*)[ \t]+)?([a-zA-Z0-9_]+\(.*\))[ \t]+/~\3/m,package method/
--regex-groovy=/^[ \t]*public[ \t]+[(abstract|final|static) \t]*((def|void|byte|int|short|long|float|double|boolean|char|[A-Z][a-zA-Z0-9_]*)[ \t]+)?([a-zA-Z0-9_]+\(.*\))[ \t]+/+\3/m,public method/
--regex-groovy=/^[ \t]*protected[ \t]+[(abstract|final|static) \t]*((def|void|byte|int|short|long|float|double|boolean|char|[A-Z][a-zA-Z0-9_]*)[ \t]+)?([a-
@ches
ches / Itembase-Sandbox.postman_environment
Last active November 18, 2015 18:27
Postman collection and environment (variables) for the Itembase API, initially imported from their Swagger spec. Import both into Postman and configure the environment with real values for your credentials. You'll need an OAuth access token for the user you're testing with, set as the `bearer_token` variable. Or alternatively, set up Postman's b…
{
"id": "d8ee1407-d7e2-60a3-f905-61896360d6e3",
"name": "Itembase – Sandbox",
"values": [
{
"key": "api_version",
"value": "v1",
"type": "text",
"name": "api_version",
"enabled": true
@ches
ches / mapfilter.go
Created October 28, 2015 18:21
A quick untyped map & filter example for Go. Author unknown, source: http://play.golang.org/p/yU6KUS1y5w
package main
import "fmt"
type MapFunc func(interface{}) interface{}
type FilterFunc func(interface{}) bool
type Collection []interface{}
type User string
type Host string
@ches
ches / EventService.scala
Last active December 15, 2016 08:09
spray implicit allowing spray DateTimes to be deserialized from parameters directives
import spray.http.DateTime
import spray.httpx.unmarshalling._
/*
* Implicit allowing spray DateTimes to be deserialized from parameters directives.
*
* See: http://spray.io/documentation/1.2.2/spray-httpx/unmarshalling/
*/
// type FromStringOptionDeserializer[T] = Deserializer[Option[String], T]