This document provides guidelines for maintaining high-quality Python code. These rules MUST be followed by all AI coding agents and contributors.
All code you write MUST be fully optimized.
"Fully optimized" includes:
| # Simple linux tun/tap device example tunnel over udp | |
| # create tap device with ip tuntap add device0 tap | |
| # set ip address on it and run tap-linux on that device and set desitation ip | |
| # run same on another node, changing dst ip to first node | |
| import fcntl | |
| import struct | |
| import os | |
| import socket | |
| import threading |
These are notes from my efforts to get Ubuntu 20.04 installed on my older MacBook Pro. I'm making this gist public in the hopes that it's helpful to others.
I did a Minimal install, but selected the option to install additional 3rd-party drivers.
Wifi doesn't work during the install (because it requires a 3rd-party driver), so you won't be able to choose to download updates while installing. No big deal, run a software update after the install.
The installer takes about 25 minutes to complete. Post-install, most things work. The only driver I had to manually install was for the FaceTime camera. More on that below.
I set up my linters for use with VS Code, so I only use the linting tools that can be integrated into the Problems tab, but these can be used from the command line. I have attempted to avoid having different tools give duplicate warnings, but this is a work in progress. The VS code settings.json is at https://gist.github.com/jlmelville/74d8fe778b0d89574e82ffe47c1e49ae.
Create a linting-requirements.txt file:
# this also installs pylint and pycodestyle
bandit
prospector[with_pyroma]
flake8
black| from threading import Timer | |
| from functools import partial | |
| class Interval(object): | |
| def __init__(self, interval, function, args=[], kwargs={}): | |
| """ | |
| Runs the function at a specified interval with given arguments. | |
| """ | |
| self.interval = interval |
| Decoding the data in /proc/net/tcp: | |
| Linux 5.x /proc/net/tcp | |
| Linux 6.x /proc/PID/net/tcp | |
| Given a socket: | |
| $ ls -l /proc/24784/fd/11 | |
| lrwx------ 1 jkstill dba 64 Dec 4 16:22 /proc/24784/fd/11 -> socket:[15907701] |
This gist illustrates how two processes can exchange information via subprocess.Popen.
Integrate an externally running user interface, potentially written in another language. For example, a GUI written in PyQt5 and Python 3 running inside of Autodesk Maya (Python 2.7, PySide).
This gist illustrates how two processes can exchange information via subprocess.Popen.
Integrate an externally running user interface, potentially written in another language. For example, a GUI written in PyQt5 and Python 3 running inside of Autodesk Maya (Python 2.7, PySide).
| from scapy.all import * | |
| import time | |
| ip = IP(dst='127.0.0.127', src='10.99.99.99') | |
| udp = UDP(sport=321,dport=123) | |
| payload = '\x01\x0f' | |
| packet = ip/udp/payload | |
| send(packet) | |
| while(True): |