Skip to content

Instantly share code, notes, and snippets.

View kelvin-chappell's full-sized avatar

Kelvin Chappell kelvin-chappell

View GitHub Profile
@kelvin-chappell
kelvin-chappell / SingleSequence.md
Created December 18, 2023 10:13
Future of Legacy Identity Resources in a Single Sequence
flowchart LR
1 --> 2
2 --> 3
3 --> 4
4 --> 5
5 --> 6
6 --> 7
7 --> 8
8 --> 9
@kelvin-chappell
kelvin-chappell / Sequences.md
Last active December 18, 2023 10:21
Future of Legacy Identity Resources Possible Sequences
flowchart LR
9 --> 10
1 --> 12
subgraph A
5 --> 10
10 --> 11
end
subgraph B
6 --> 7
@kelvin-chappell
kelvin-chappell / SequenceA.md
Last active December 8, 2023 16:43
Future of legacy Identity resources: Sequence A
sequenceDiagram

participant 1
participant 2
participant 3
participant 4
participant 5
participant 6
participant 7
@kelvin-chappell
kelvin-chappell / Ec2Python.bash
Created November 23, 2023 15:44
Finds EC2 instances that have Python installed.
#!/bin/bash
# Get a list of instance IDs
instance_ids=$(aws ec2 describe-instances --profile $account --region $region --query 'Reservations[*].Instances[?State.Name==`running`].InstanceId' --output text)
# Loop through the instance IDs and print relevant information
echo "Num instances: $(echo "$instance_ids" | grep -c .)"
for instance_id in $instance_ids; do
echo "Instance ID: $instance_id"
# Run a command to check if Python is installed
@kelvin-chappell
kelvin-chappell / TypedIO.scala
Created November 13, 2023 16:58
Cats effect IO with a failure type
//> using dep org.typelevel::cats-effect::3.5.2
import cats.data.EitherT
import cats.effect.IO
import cats.effect.unsafe.implicits.global
// TODO: implement class
//class TypedIO[E,A](io: IO[Either[E,A]]):
// def unsafeRunSync(): Unit = ???
//end TypedIO
@kelvin-chappell
kelvin-chappell / TypeclassOut.scala
Created June 16, 2023 12:39
Typeclass where type is result rather than argument
trait Maker[A] {
def make(s: String): A
}
object Maker {
implicit val intMaker = new Maker[Int] {
def make(s: String) = s.toInt
}
implicit val doubleMaker = new Maker[Double] {
def make(s: String) = s.toDouble
@kelvin-chappell
kelvin-chappell / Scala3TypeClasses.scala
Created November 24, 2022 15:55
Type classes in Scala 3
// See https://docs.scala-lang.org/scala3/book/ca-type-classes.html
object TypeClassExample extends App:
// 1. Type class
trait Showable[A]:
extension (a: A)
def show: String
def format: String
@kelvin-chappell
kelvin-chappell / PomodoroReadings.js
Created October 28, 2022 15:30
Pomodoro readings apps script
//---------------------------------------------------------------------------------
// Utilities.gs
//---------------------------------------------------------------------------------
const envVar = (name) => {
return PropertiesService.getScriptProperties().getProperty(name);
}
//---------------------------------------------------------------------------------
@kelvin-chappell
kelvin-chappell / OIDCImplicitFlow.md
Last active July 18, 2022 13:59
Open Identity Connect: Implicit Flow

Implicit flow

sequenceDiagram
    autonumber
    actor RO as Resource Owner
    participant Client
    participant IP as Identity Provider
    Client-)IP: Get provider info
 RO->>+Client: Sign in
@kelvin-chappell
kelvin-chappell / EmailToGoogleSheet
Created June 10, 2022 07:49
Append email detail to a sheet
# Credit to Michael Jacobson and John Duffell
function getGmail() {
const query = `from:no-reply@sns.amazonaws.com NOT label:done`;
let threads = GmailApp.search(query);
let label = GmailApp.getUserLabelByName('done');
if (!label) {label = GmailApp.createLabel('done')}
let messages = [];
threads.forEach(thread => {