Skip to content

Instantly share code, notes, and snippets.

View steinybot's full-sized avatar

Jason Pickens steinybot

View GitHub Profile
import pulumi_aws as aws
import ssh
temporary_key = ssh.GenerateSSHKey(
'GeneratedTemporaryPlatformSSHKey'
)
temporary_key_pair = aws.ec2.KeyPair(
'TemporaryPlatformSSHKey',
@steinybot
steinybot / __main__.py
Last active October 11, 2020 21:35
Pulumi Unknown Error
temporary_key = ssh.GenerateSSHKey(
'GeneratedTemporaryPlatformSSHKey'
)
platform_connection = ssh.ConnectionInputs(
host=platform_record.name,
username='ec2-user',
private_key=temporary_key.private_key,
private_key_passphrase=temporary_key.passphrase
)
@steinybot
steinybot / README.md
Last active March 7, 2022 00:46
GPG Commands

GPG Commands

Miscellaneous

HP laptop boot loader menu key: F9

List

Listing keys:

@steinybot
steinybot / RefinedBoxed.scala
Last active August 20, 2020 00:48
Boxed refined types to work with Play.
import eu.timepit.refined.api.{Refined, RefinedType, RefType, Validate}
import scala.reflect.macros.blackbox
final case class RefinedBoxed[FTP](value: FTP) {
override def toString: String = value.toString
}
object RefinedBoxed {
@steinybot
steinybot / ReadOps.scala
Created August 19, 2020 04:58
Play JSON Helpers
import play.api.libs.functional._
import play.api.libs.json.Reads._
import play.api.libs.json._
import scala.collection.GenTraversableOnce
trait ReadOps {
def updateFieldValues[A <: JsValue](reads: Reads[A]): Reads[JsObject] = {
of[JsObject].flatMap { obj =>
@steinybot
steinybot / README.md
Created August 5, 2020 03:53
Debugging Akka Streams

How to debug Akka Streams:

  1. Put a breakpoint in akka.stream.impl.PhasedFusingActorMaterializer#materialize where it has the built in printing.
  2. Add the following to "evaluate and log":
    println("\n\nTraversal:")
    TraversalBuilder.printTraversal(current);
    println("\nWiring:")
    TraversalBuilder.printWiring(current);
@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&gt; 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