Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Epivalent
Epivalent / d-list-col.ipynb
Last active March 20, 2025 10:52
WiP implementation of Nick Gravin's linear time graph d-list-colouring algorithm.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Epivalent
Epivalent / ngravin-d-list-col-impl-WiP.ipynb
Created March 20, 2025 10:42
WiP implementation of Nick Gravin's linear-time graph d-list colouring algorithm.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Epivalent
Epivalent / gist:7cf7647e8a52d6d8ca58106d276fa648
Last active March 20, 2025 10:38
ngravin-d-list-colouring-WiP.ipynb
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sage.all import Graph, matrix, ZZ
import unittest
# ============================================================
# Data Representation and Helper Functions
# ============================================================

If you are encountering the "error: externally-managed-environment" when trying to install or upgrade packages using pip, it means that your Python environment is being managed externally and you do not have permission to modify it. In this case, you will need to either gain the necessary permissions or use a virtual environment.

Here are two possible solutions:

  1. Gain necessary permissions:
    • Run the pip command with administrative privileges by using sudo:
      sudo pip3 install package_name
      

To make the Python environment not externally managed on Debian 12, you can follow these steps:

  1. Update your system's package list:

    sudo apt update
    
  2. Install pip3 (if not already installed):

sudo apt install python3-pip

To achieve this with socat, you can set up a listener on a local TCP port that forwards incoming connections to another host and port using SSL. Additionally, you can enable forking so that each incoming connection is handled by a separate process.

Here's an example command:

socat -d -d -d TCP-LISTEN:LOCAL_PORT,fork,reuseaddr OPENSSL:REMOTE_HOST:REMOTE_PORT,verify=0

Explanation of the options used:

  • -d -d -d: Enable debug output (optional but useful for troubleshooting).

The following socat command can be used to listen on a local interface on a specific TCP port and tunnel the traffic via SSL to another host:port pair with forking:

socat TCP-LISTEN:<local_port>,bind=<local_interface>,fork SSL:<remote_host>:<remote_port>

Replace <local_port> with the desired local TCP port number, <local_interface> with the local interface IP address or hostname you want to bind to, <remote_host> with the destination host IP address or hostname, and <remote_port> with the destination port number.

For example, if you want to listen on localhost (127.0.0.1) on port 8080 and tunnel the traffic via SSL to example.com on port 443, you can use the following command:

Thu Jul 11 07:33:48 PM UTC 2024 - socat invocation to listen on local interface on some tcp port and tunnel via ssl to another host:port pair with forking