Skip to content

Instantly share code, notes, and snippets.

@lewisjkl
lewisjkl / SplitUp.scala
Created March 28, 2023 22:21
Smithy4s Preprocessor Split Services
package preprocessors
import software.amazon.smithy.build._
import software.amazon.smithy.model._
import software.amazon.smithy.model.shapes._
import software.amazon.smithy.model.traits._
import scala.collection.JavaConverters._
final class SplitUp extends ProjectionTransformer {
@lewisjkl
lewisjkl / adt-dotty.scala
Created January 23, 2020 05:06
ADTs in Dotty are encoded as Enums instead of a sealed hierarchy.
// Note - these examples are not meant to show how the `Option` type is actually implemented
// Scala 2.13.x
sealed abstract class Option[+A]
case class Some[A](x: A) extends Option[A]
case object None extends Option[Nothing]
Some("test")
// has type Some[String]
@lewisjkl
lewisjkl / future-referential-transparency.scala
Last active January 5, 2020 13:53
Expressions using Future are often not referentially transparent.
val printStuff: Future[Unit] = Future(println("Hello, World!"))
for {
_ <- printStuff
_ <- printStuff
} yield ()
// prints "Hello, World!" once
for {
@lewisjkl
lewisjkl / scriptable-gist-to-carbon.js
Created January 5, 2020 05:38
Shows how to use Scriptable to send Gists to Carbon
let url = args.urls[0]
if (!url) {
let alert = new Alert()
alert.message = "Please provide a gist url as input!"
alert.present()
} else {
let paths = url.split("/")
let gistId = paths[paths.length - 1]
let carbonUrl = "https://carbon.now.sh/" + gistId

Keybase proof

I hereby claim:

  • I am lewisjkl on github.
  • I am lewisjkl (https://keybase.io/lewisjkl) on keybase.
  • I have a public key ASCxJrHu6SWEQagKP3tlJOCp2-WCU6cdu7_17zakPTPqVgo

To claim this, I am signing this object:

@lewisjkl
lewisjkl / URLRequestSigner.swift
Last active January 3, 2024 08:32
aws4 request signing iOS Swift 3
// This is free and unencumbered software released into the public domain.
// Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute this software, either in source code form or as a compiled
// binary, for any purpose, commercial or non-commercial, and by any
// means.
// In jurisdictions that recognize copyright laws, the author or authors
// of this software dedicate any and all copyright interest in the
// software to the public domain. We make this dedication for the benefit