Skip to content

Instantly share code, notes, and snippets.

View steinybot's full-sized avatar

Jason Pickens steinybot

View GitHub Profile
@steinybot
steinybot / README.md
Last active June 11, 2020 21:09
Diagnosing implicit resolution errors in a single file.

First set the sources to a single file

sbt> set `integration-tests`/Test/sources ~= (_.filter(_.name == "UploadsControllerSpec.scala"))

Then enable implicit logging

sbt> set `integration-tests`/scalacOptions += "-Xlog-implicits"
@steinybot
steinybot / ADTEnumerationFormat.scala
Last active June 8, 2020 07:16
Play Json formats for ADTs and Enums
import play.api.libs.json._
trait ADTEnumerationFormat[A] {
// Implement this with sealerate.
def values: Set[A]
private val valueMap: Map[String, A] = {
values.map { value =>
value.toString -> value
@steinybot
steinybot / direnvrc
Created May 13, 2020 01:02
Direnv configuration that actually works
use_nvm() {
local nvm_sh
if [[ -n ${NVM_DIR} && -e "$NVM_DIR/nvm.sh" ]]; then
nvm_sh="$NVM_DIR/nvm.sh"
elif [[ -e '~/.nvm/nvm.sh' ]]; then
nvm_sh='~/.nvm/nvm.sh'
elif [[ -e '/usr/local/opt/nvm/nvm.sh' ]]; then
nvm_sh='/usr/local/opt/nvm/nvm.sh'
else
@steinybot
steinybot / cmd
Created May 11, 2020 04:47
IntelliJ dump sbt project structure
;set _root_.scala.collection.Seq(historyPath := None,shellPrompt := { _ => "" },SettingKey[_root_.scala.Option[_root_.sbt.File]]("sbtStructureOutputFile") in _root_.sbt.Global := _root_.scala.Some(_root_.sbt.file("/private/var/folders/_l/q8t5_1gj5yx49v31fk6mr1p40000gn/T/sbt-structure.xml")),SettingKey[_root_.java.lang.String]("sbtStructureOptions") in _root_.sbt.Global := "download, resolveClassifiers, resolveSbtClassifiers");apply -cp "/Users/jason/Library/Application Support/JetBrains/IntelliJIdea2020.1/plugins/Scala/repo/org.jetbrains/sbt-structure-extractor/scala_2.12/sbt_1.0/2018.2.1+4-88400d3f/jars/sbt-structure-extractor.jar" org.jetbrains.sbt.CreateTasks;*/*:dumpStructure
# Node Version Manager
# Implemented as a POSIX-compliant function
# Should work on sh, dash, bash, ksh, zsh
# To use source this file from your bash profile
#
# Implemented by Tim Caswell <[email protected]>
# with much bash help from Matthew Ranney
# "local" warning, quote expansion warning
# shellcheck disable=SC2039,SC2016,SC2001
@steinybot
steinybot / Macro.scala
Created April 8, 2020 23:35
Evaluating values in a Scala macro
import scala.reflect.macros.blackbox
object Macro {
def filterRanges(ranges: List[(Char, Char)])(f: Char => Boolean): List[(Char, Char)] =
macro filterRangesImpl
def filterRangesImpl(
c: blackbox.Context
)(
@steinybot
steinybot / terraform-trace.log
Created March 17, 2020 05:36
Terraform tace log
❯ TF_LOG=trace terraform plan
2020/03/17 18:35:06 [INFO] Terraform version: 0.12.23
2020/03/17 18:35:06 [INFO] Go runtime version: go1.12.13
2020/03/17 18:35:06 [INFO] CLI args: []string{"/usr/local/Cellar/tfenv/1.0.2/versions/0.12.23/terraform", "plan"}
2020/03/17 18:35:06 [DEBUG] Attempting to open CLI config file: /Users/jason/.terraformrc
2020/03/17 18:35:06 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/03/17 18:35:06 [INFO] CLI command args: []string{"plan"}
2020/03/17 18:35:06 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2020/03/17 18:35:06 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2020/03/17 18:35:06 [DEBUG] New state was assigned lineage "b7d7f93e-5dfa-a01a-61c0-8afc255a5b65"
@steinybot
steinybot / SbtUpdatesOnLoadPlugin.scala
Last active February 23, 2021 12:26
Run sbt-updates onLoad
import sbt._
import Keys._
import sbt.internal.BuildStructure
object SbtUpdatesOnLoadPlugin extends AutoPlugin {
override def trigger = allRequirements
override def globalSettings: Seq[Setting[_]] = Seq(
onLoad := {
@steinybot
steinybot / README.md
Last active November 8, 2019 03:43
Go Module confusion

I have a couple of cmd apps with some imports:

cmd/monitorrules/main.go:

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
@steinybot
steinybot / .bashrc
Last active October 14, 2019 01:05
Setup Lightbend Console local
function podsready {
kubectl --request-timeout=1s get --all-namespaces pod -o json | jq '.items[].status.containerStatuses[0].ready'
}
function wait_for_pods {
echo -n "waiting for pods to start"
sleep 1
until
podsready | grep -q true
do