Skip to content

Instantly share code, notes, and snippets.

@voice1
voice1 / switchvox-clear-blocked-ips.py
Last active November 23, 2021 18:19
Switchvox clear all blocked IP's
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Clear blocked IP addresses in switchvox.
Requires pyswitchvox
Feel free to adjust logger if desired.
"""
from pyswitchvox.client import Client
from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
import os
app = FastAPI()
lable_lang_mapping = {"Plain JS": "JavaScript", "NodeJS": "JavaScript"}
@app.get("/hello")
async def hello():
@lucasgrelaud
lucasgrelaud / pfsense-ldap-freeipa.md
Last active December 2, 2024 09:54
pfSense configuration for FreeIPA 4.8.0

pfSense LDAP configuration for FreeIPA 4.8.0

This is a small guide on how to configure Netgate's pfSense firewall to use the FreeIPA LDAP service.

I. FreeIPA Configuration

I.1. Create a dedicated group

The first step is to create a user group in FreeIPA to manage which user can access the pfSense admin interface. You will be able to create some others groups later if you need to get different profiles on the pfSense admin interface (full admin, vpn admin, etc...).

@stephen-mw
stephen-mw / install_python38_on_pi.sh
Last active August 22, 2023 03:55
Install python3.8 and make the system default on Raspberry Pi
#!/usr/bin/env bash
set -euo pipefail
# This script downloads, compiles, and installs python3.8 as the system default
export VERSION=3.8.5
apt install -y \
build-essential \
libbz2-dev \
@nkhitrov
nkhitrov / logger.py
Last active August 29, 2025 00:11
Configure uvicorn logs with loguru for FastAPI
"""
WARNING: dont use loguru, use structlog
https://gist.github.com/nkhitrov/38adbb314f0d35371eba4ffb8f27078f
Configure handlers and formats for application loggers.
"""
import logging
import sys
from pprint import pformat
@philippegirard
philippegirard / main.py
Created April 18, 2020 20:18
fastapi logging middleware
import logging
from fastapi import FastAPI
from uicheckapp.services import EchoService
logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
logger = logging.getLogger(__name__)
app = FastAPI()
from typing import Optional
import base64
from passlib.context import CryptContext
from datetime import datetime, timedelta
import jwt
from jwt import PyJWTError
from pydantic import BaseModel
assumption:
/etc/openldap/ldap.conf is correct:
SASL_NOCANON on
URI ldaps://ipa.foo.com
BASE dc=foo,dc=com
TLS_CACERT /etc/ipa/ca.crt
check LDAP:
@MatthewVance
MatthewVance / unbound.conf
Last active September 9, 2025 15:34
Config for running Unbound as a caching DNS forwarder (performance settings optimized for Raspberry Pi 2).
server:
###########################################################################
# BASIC SETTINGS
###########################################################################
# Time to live maximum for RRsets and messages in the cache. If the maximum
# kicks in, responses to clients still get decrementing TTLs based on the
# original (larger) values. When the internal TTL expires, the cache item
# has expired. Can be set lower to force the resolver to query for data
# often, and not trust (very large) TTL values.
cache-max-ttl: 86400