Skip to content

Instantly share code, notes, and snippets.

View absolutejam's full-sized avatar

James Booth absolutejam

View GitHub Profile
@absolutejam
absolutejam / generic_loaders.rs
Created November 22, 2023 12:30
Generic loaders
use serde::{de::DeserializeOwned, Deserialize, Deserializer};
//
struct Metadata {
name: &'static str,
provider: &'static str,
}
//
@absolutejam
absolutejam / all_the_traits.rs
Created October 18, 2023 18:34
Not quite Scala, but close enough
use async_trait::async_trait;
use dyn_clone::DynClone;
use serde::{Deserialize, Serialize};
//------------------------------------------------------------------------------
trait SpecLoaderContract<Value, Spec> {
fn load(&self, value: Value) -> Result<Spec, anyhow::Error>;
}
@absolutejam
absolutejam / decision.fsx
Last active February 24, 2023 09:25
ZPure-inspired domain decisions
//
// Inspired by the following talk: https://www.youtube.com/watch?v=TVYhFpqlgZ4
// And example repo: https://github.com/devsisters/ck-domain-logic-example
//
// Domain models
type AccountId = AccountId of string
type AccountNmae = AccountName of string
type AccountState = Opened | Closed
@absolutejam
absolutejam / resize-disk.md
Created September 7, 2022 10:00
Resize a disk

Resizing a disk with LVM

  • Run as sudo

    sudo su
  • Resize the physical disk of the VM

@absolutejam
absolutejam / testing.fs
Created August 25, 2022 15:17
Brain-dumping a ZIO-inspired DI solution for F# (with some Reader monad flavour)
type Dep<'t> =
abstract member Get : 't
// This doesn't work :'(
// type Deps<'a, 'b>(a: Dep<'a>, b: Dep<'b>) =
// member this.GetA = a
// member this.GetB = b
// interface Dep<'a> with member this.Get with get () = this.GetA
// interface Dep<'b> with member this.Get with get () = this.GetB
module RealmWeaver.Core.Config
open System.IO
open Microsoft.Extensions.Configuration
open RealmWeaver.Core.Utils
let buildConfig environment (configBuilder: IConfigurationBuilder) =
let settingsPath =
match EnvVar.tryGet (sprintf "%s_%s" EnvVar.Root "CONFIG_FILE") with
@absolutejam
absolutejam / config
Created June 22, 2018 05:57
Polybar blocks
;=====================================================
;
; To learn more about how to configure Polybar
; go to https://github.com/jaagr/polybar
;
; The README contains alot of information
;
;=====================================================
[global/wm]
@absolutejam
absolutejam / arch setup.md
Last active June 13, 2018 22:01
disk partitions

Next step, Arch

WiFi

  • Unblock WiFi permanently systemctl enable rfkill-unblock@all && systemctl start rfkill-unblock@all
  • Connect to WiFi using wifi-menu as it creates a persistent profile - wifi-menu
    • I always rename them from wlp1s0-<ssid> to wifi-<ssid> (And replace spaces with _)
  • Then start your profile netctl start <profile>
    • netctl list if you've forgotten it already
  • netctl enable for it to autostart

Keybase proof

I hereby claim:

  • I am absolutejam on github.
  • I am absolutejam (https://keybase.io/absolutejam) on keybase.
  • I have a public key whose fingerprint is 7C29 6C3A 9023 158D 42A5 ADB5 2E81 C9C0 9F8C A0AF

To claim this, I am signing this object:

@absolutejam
absolutejam / check-windows-port-listening.rb
Created December 14, 2017 19:08
check-windows-port-listening.rb
#! /usr/bin/env ruby
#
# check-windows-port-listening.rb
#
# DESCRIPTION:
# Check to see which ports are listening, using netstat.
# First draft.
#
# OUTPUT:
# plain text