Skip to content

Instantly share code, notes, and snippets.

View peterstorm's full-sized avatar

Peter Storm peterstorm

View GitHub Profile

The following are steps to set up Azure AD as an Identity Provider for an on-prem Kubernetes cluster.

Starting point:

  • Azure Subscription
  • On-prem Kubernetes cluster (in my case RKE2 v1.27.12+rke2r1)

The scenario is pretty straightforward:

I want to connect from my Workstation (Windows/Linux/Mac) to an on-prem Kubernetes cluster and authenticate to is using Azure AD.

@keynmol
keynmol / README.md
Last active February 29, 2024 13:34
Byte pair encoding algorithm in Scala
@piousdeer
piousdeer / example.nix
Last active June 11, 2024 12:31
Create mutable files with home-manager and Nix
{
home.file."test-file" = {
text = "Hello world";
force = true;
mutable = true;
};
}
@viercc
viercc / gadt-filter-with-typeable.hs
Created October 27, 2022 08:08
Generalising / DRYing functions which apply to GADTs
{-# LANGUAGE GADTs, DataKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Main where
import Data.Typeable (cast)
import Type.Reflection
@ftzm
ftzm / Test.hs
Last active May 31, 2022 12:38
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeApplications #-}
module Test where
import Control.Monad.Reader
import Data.Generics.Product.Typed
@quelgar
quelgar / typed_errors.md
Last active January 16, 2024 09:36
Every Argument for Static Typing Applies to Typed Errors

Every Argument for Static Typing Applies to Typed Errors

Think of all the arguments you've heard as to why static typing is desirable — every single one of those arguments applies equally well to using types to represent error conditions.

An odd thing I’ve observed about the Scala community is how many of its members believe that a) a language with a sophisticated static type system is very valuable; and b) that using types for error handling is basically a waste of time. If static types are useful—and if you like Scala, presumably you think they are—then using them to represent error conditions is also useful.

Here's a little secret of functional programming: errors aren't some special thing that operate under a different set of rules to everything else. Yes, there are a set of common patterns we group under the loose heading "error handling", but fundamentally we're just dealing with more values. Values that can have types associated with them. There's absolutely no reason why the benefits of static ty

@jmatsushita
jmatsushita / README
Last active July 16, 2024 10:30
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
###
### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places.
###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of
###. things to watch out for:
### - Check out the `nix-darwin` instructions, as they have changed.
### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026
###
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
@ChristopherDavenport
ChristopherDavenport / Lock.scala
Last active October 11, 2021 13:10
Reentrant Lock
import cats._
import cats.syntax.all._
import cats.data._
import cats.effect._
import cats.effect.syntax.all._
import cats.effect.std.Semaphore
trait Lock[F[_]]{ self =>
def lock: F[Unit]
def unlock: F[Unit]
@ChristopherDavenport
ChristopherDavenport / SetOnceCache.scala
Last active October 11, 2021 13:06
Set Once Cache
import cats._
import cats.implicits._
import cats.effect._
import cats.effect.implicits._
import scala.concurrent.duration._
import io.chrisdavenport.mapref._
trait SetOnceCache[F[_], K, V]{
def get(k: K): F[V]
import com.sksamuel.avro4s.SchemaFor
import com.sksamuel.avro4s.refined._
import io.estatico.newtype.Coercible
import io.chrisdavenport.fuuid.FUUID
import java.util.UUID
import scala.concurrent.duration.FiniteDuration
import io.circe.{Json, JsonObject}
import com.comcast.ip4s.Ipv4Address
object avro extends SchemaForCoercible {