(…)
The driver supports two diff modes:
- non-contextual diff (default behavior)
- contextual diff (as proposed in PR #23)
(…)
The driver supports two diff modes:
from fastapi import Request, Response, HTTPException | |
from fastapi.exceptions import RequestValidationError | |
from fastapi.routing import APIRoute | |
from http.client import responses | |
from json import JSONDecodeError | |
from starlette.exceptions import HTTPException as StarletteHTTPException | |
from traceback import format_exc | |
from typing import Callable | |
import logging |
from json import JSONEncoder | |
# | |
# Node class: it just consists of a name and a list of children. | |
# | |
class Node: | |
def __init__(self, name: str): | |
self.name = name | |
self.children = [] |
# | |
# As required by HSTS, two redirects: | |
# 1) http2https (MUST be first) | |
# 2) nonwww2www | |
# | |
# https://webmasters.stackexchange.com/questions/84757/htaccess-redirect-non-www-to-www-with-ssl-https | |
# | |
RewriteCond %{HTTPS} off | |
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] | |
RewriteCond %{HTTP_HOST} !^www\. |
#!/usr/bin/env bash | |
get_ssh_known_hosts() { | |
known_hosts=$(cat ~/.ssh/known_hosts | cut -d' ' -f1) | |
starts_with=$2 | |
COMPREPLY=( $(compgen -W "$known_hosts" -- "$starts_with") ) | |
return 0 | |
} | |
complete -F get_ssh_known_hosts ssh scp ping nslookup my-custom-command |
# | |
# /etc/freeradius/policy.d/cisco2huawei | |
# | |
# Attributes adaptation from Cisco to Huawei. | |
# | |
cisco2huawei { | |
foreach &reply:Cisco-AVPair { | |
if ("%{Foreach-Variable-0}" =~ /ip:vrf-id=(.*)/) { | |
# | |
# Adapt the VRF attribute. |
# | |
# /etc/freeradius/policy.d/lns_load_balancing | |
# | |
# Random load balancing between two LNS. | |
# Note: the same LNS can be returned twice in a row. | |
# If it's an issue, feel free to use a non-binary rand interval (e.g., rand:9 instead of rand:2) | |
# and adapt below conditions (e.g., 0..4 is first LNS, 5..9 is second LNS). | |
# | |
lns_load_balancing { | |
# |
# | |
# /etc/freeradius/policy.d/force_accept | |
# | |
# Force accept a user. | |
# | |
# Two scenarios: | |
# - the user does NOT exist in the database => trigger FORCE-ACCEPT-USERNAME-NOT-FOUND | |
# - the user does exist but password is incorrect => trigger FORCE-ACCEPT-PASSWORD-INCORRECT | |
# | |
# This can be implemented with two modules, called at different sections in the FreeRADIUS sequence. |
import logging | |
import logging.handlers | |
import sys | |
# | |
# The logger and the logging level | |
# | |
logger = logging.getLogger('mylogger') | |
logger.setLevel(logging.DEBUG) |
import coloredlogs # OPTIONAL (see end of the file) | |
import getpass | |
import logging | |
import logging.handlers | |
# | |
# The logger and the logging level | |
# | |
logger = logging.getLogger('mylogger') | |
logger.setLevel(logging.DEBUG) |