Skip to content

Instantly share code, notes, and snippets.

@ohforest
ohforest / iptables.sh
Created December 1, 2020 06:07 — forked from thomasfr/iptables.sh
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers
#!/bin/bash
set -e
cf_ips() {
echo "# https://www.cloudflare.com/ips"
echo "geo \$realip_remote_addr \$cloudflare_ip {"
echo "default 0;"
for type in v4 v6; do
@ohforest
ohforest / readme.md
Created February 17, 2023 10:46 — forked from fengyuentau/readme.md
Enable X11 forward for ssh to load images from remote server on MacOS Mojave

Enable X11 forward to load images from remote server on MacOS Mojave

Steps

  1. Install Xquartz to get X11 support on MacOS. You can google Xquartz and download it from its official site, or install using HomeBrew.

    brew cask install xquartz
  2. Launch Xquartz. Go to Preference -> Security, click the box Allow connections from clients. NOTE: You have to lauch Xquartz with Allow connections from clients enable everytime you want to ssh to remote server with X11 forwarding support.

@dishwad
dishwad / logger.py
Last active June 19, 2024 04:04
Logging configuration for FastAPI using Gunicorn + Uvicorn workers
import logging
import sys
import time
from typing import Callable
from fastapi import Request, Response
from fastapi.routing import APIRoute
from gunicorn.glogging import Logger
from loguru import logger
from starlette.background import BackgroundTask