Skip to content

Instantly share code, notes, and snippets.

View lxdlam's full-sized avatar
🎯
Focus

lxdlam lxdlam

🎯
Focus
View GitHub Profile
@lxdlam
lxdlam / guide.md
Created January 10, 2025 09:51
golang mTLS + step-ca example
  1. Bootstrap a local smallstep CA following the guide. Remember to start your CA server.
  2. Issue certificates:
    • Download Root ca: step ca root ca.crt
    • Issue server cert: step ca certificate "mtls.internal" server.crt server.key
    • Issue client cert: step ca certificate "mtls.internal" client.crt client.key
  3. Start the server at the same directory or modify the code to locate the cert files. If you issued the certs like my setup, remember to add the domain mtls.internal in your hosts or so on.
  4. Test with TestClient or test with curl: curl -vvvv https://mtls.internal:8080 --cacert ca.crt --cert client.crt --key client.key.
from pydantic import BaseModel, Field, RootModel, Discriminator, Tag
from typing import Literal, TypeVar, Generic, Annotated, Any
_ResponseType = TypeVar("_ResponseType")
def get_discriminator_value(v: Any) -> str:
if isinstance(v, dict):
return "success" if v.get("code") == 0 else "error"
return "success" if getattr(v, "code") == 0 else "error"
from os import walk
from urllib.parse import urlparse
from playwright.sync_api import sync_playwright
from time import sleep
TEMPLATE = "https://drive.usercontent.google.com/download?id={share_id}&export=download"
if __name__ == "__main__":
with sync_playwright() as p:

$argon2id$v=19$m=512,t=256,p=1$n6yvzJe2AxOS6yQBsCPKKA$Ei089XHiQ+u6SDk9DmyzLOzr7qccHmzJ88uK3eKg2dQ

@lxdlam
lxdlam / links.md
Created March 7, 2024 06:02 — forked from Leandros/links.md
Writing a Modern Rendering Engine
from abc import ABC
from copy import deepcopy
from dataclasses import dataclass, fields
from datetime import datetime
from enum import Enum
from typing import Union, get_args, get_origin
from uuid import UUID
nt = type(None)
package http
import (
"bytes"
"context"
"encoding/json"
"io"
"net/http"
)
// You need at least `nom = "7"` to work.
mod protocol {
use std::{fmt, str::FromStr};
use nom::Finish;
use self::parser::parse;
const DELIMITER: &str = "\r\n";
[package]
name = "playground"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
tokio = { version = "1.9", features = ["full"] }
thiserror = "1.0"