Skip to content

Instantly share code, notes, and snippets.

@Xowap
Xowap / graph_utils.py
Created April 18, 2025 14:09
LLM NetworkX
from collections import defaultdict
from typing import Generic, TypeVar
T = TypeVar("T")
class SimpleGraph(Generic[T]):
"""
Lightweight graph implementation, only for the needs of the health module.
"""
@Xowap
Xowap / day1.cpp
Created December 2, 2024 01:45
Advent of Code - Day 1 - v4
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <stdexcept>
#include <sstream>
@Xowap
Xowap / day1.py
Created December 2, 2024 01:44
Advent of Code - Day 1 - v3
import argparse
import sys
from collections import defaultdict
from io import StringIO
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument(
@Xowap
Xowap / day1.cpp
Created December 2, 2024 01:42
Advent of Code - Day 1 - v2
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <cmath>
#include <stdexcept>
#include <sstream>
@Xowap
Xowap / day1.py
Created December 2, 2024 01:40
Advent of Code - Day 1 - v1
import argparse
import sys
import re
from collections import defaultdict
from io import StringIO
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
@Xowap
Xowap / xxx.service
Created November 10, 2024 00:19
Django with systemd
[Unit]
Description=xxx gunicorn server
Requires=xxx.socket
After=network.target
[Service]
User=www-data
Group=www-data
EnvironmentFile=/var/apps/xxx/env
WorkingDirectory=/var/apps/xxx/
@Xowap
Xowap / pyproject.toml
Created July 28, 2024 21:31
Rémy's Ruff Rules
[tool.ruff.lint]
select = [
# -- Core --
"E", # pycodestyle (errors)
"W", # pycodestyle (warnings)
"F", # Pyflakes
"I", # isort
"C90", # McCabe Complexity
"D1", # Mandatory docstrings
"S", # Bandit
[
{
"title": "Dawn or dusk?",
"answers": [
{
"title": "Dawn",
"scores": {
"g": 100,
"r": 100,
"h": 0,
@Xowap
Xowap / keybase.md
Last active November 17, 2019 10:03
Keybase verification

Keybase proof

I hereby claim:

  • I am xowap on github.
  • I am xowap (https://keybase.io/xowap) on keybase.
  • I have a public key ASC37lc_Cup93wSKmGt4SSwNZ-tAAQ6bTbyNbOXbUpZRUwo

To claim this, I am signing this object:

from pydantic import BaseModel, ValidationError
from typing import Union
class A(BaseModel):
a: Union["A", "B"]
class B(BaseModel):
a: Union["A", "B"]