Skip to content

Instantly share code, notes, and snippets.

Avatar

Guillaume Charbonnier charbonnierg

  • Araymond
  • Grenoble
View GitHub Profile
@charbonnierg
charbonnierg / asgi-with-static-files.py
Last active Jun 22, 2022
Server static files along a FastAPI application using starlette
View asgi-with-static-files.py
import os
from pathlib import Path
from typing import Callable, Optional
from fastapi import FastAPI
from starlette.applications import Starlette
from starlette.routing import Mount
from starlette.staticfiles import StaticFiles
from starlette.types import Scope
@charbonnierg
charbonnierg / downloader.py
Last active Apr 25, 2022
Az Custom Vision file downloader
View downloader.py
from __future__ import annotations
import json
import urllib.request as request
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
from typing import Any, Dict, Iterator, List, Optional, Set, Union
from azure.cognitiveservices.vision.customvision.training import (
CustomVisionTrainingClient,
@charbonnierg
charbonnierg / variant-tree.py
Last active Apr 7, 2022
Text variants generation
View variant-tree.py
"""
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
View to_thread.py
"""
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
View build-python-ubuntu.md

Script

Usage: sudo -E ./build.sh 3.7.13

Note: -E is used to preserve environments variable, which may be useful when using a proxy

#!/usr/bin/env bash

set -euo pipefail
@charbonnierg
charbonnierg / empty.py
Last active Jan 18, 2022
An Empty class to use with Pydantic
View empty.py
"""
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
@charbonnierg
charbonnierg / pydantic_parser.py
Last active Dec 15, 2021
Pydantic models parser
View pydantic_parser.py
"""
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
@charbonnierg
charbonnierg / systemd_service_hardening.md
Created Nov 25, 2021 — forked from ageis/systemd_service_hardening.md
Options for hardening systemd service units
View systemd_service_hardening.md

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@charbonnierg
charbonnierg / Install-natscli.md
Last active Mar 29, 2022
Install natscli from bash
View Install-natscli.md

How to install

Note: The script requires root permissions as it installs nats executable into /usr/local/bin

curl -sSL https://gist.githubusercontent.com/charbonnierg/b68d85e908c90160a1118838f2cceb63/raw/install-natscli.sh | bash
  • Install specific version:
View nebula-default-config.yml
# This is the nebula example configuration file. You must edit, at a minimum, the static_host_map, lighthouse, and firewall sections
# Some options in this file are HUPable, including the pki section. (A HUP will reload credentials from disk without affecting existing tunnels)
# PKI defines the location of credentials for this node. Each of these can also be inlined by using the yaml ": |" syntax.
pki:
# The CAs that are accepted by this node. Must contain one or more certificates created by 'nebula-cert ca'
ca: /etc/nebula/ca.crt
cert: /etc/nebula/node.crt
key: /etc/nebula/node.key
#blocklist is a list of certificate fingerprints that we will refuse to talk to