Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в Python в модуле re.
Чтобы указать флаг для компилятора нам надо указать его после передаваемой строки. Например, добавляем флаг для игнорирования переноса строки.
pattern = re.compile(r"(\w+)+")
words = pattern.search(text, re.DOTALL)
А как указать несколько флагов? Ведь явно будут ситуации когда нам потребуется больше одного. Кто читал посты по битовые операторы уже понял как.
pattern.search(text, re.DOTALL | re.VERBOSE)
А теперь смотрим исходники, что находится в этих атрибутах?
Не удивительно, степени двойки. Почему? Потому что каждое следующее значение это сдвиг единицы влево.
>>> for n in [1, 2, 4, 8, 16, 32, 64, 128, 256]:
>>>
print(bin(n))
0b1
0b10
0b100
0b1000
0b10000
0b100000
0b1000000
0b10000000
0b100000000
Чтобы было понятней, давайте напишем тоже самое но иначе, добавим ведущие нули:
000000001
000000010
000000100
000001000
000010000
000100000
001000000
010000000
100000000
Не понятно что тут происходит? Читай три поста про битовые операторы начиная с этого ➡️https://t.me/pythonotes/45
В общем, это пример применения побитовых операций в самом Python.
Теперь вы знаете Python еще немного лучше)
#tricks#regex#libs
📰 Nginx 1.31 Released with HTTP Forward Proxy Support
Nginx 1.31 introduces HTTP forward proxy support and addresses security vulnerabilities in HTTP/2, HTTP/3, OCSP, and core modules.
🔗 Source: https://linuxiac.com/nginx-1-31-released-with-http-forward-proxy-support/
#nginx
📰 Kubernetes sets a new standard for release notes, also kills Ingress NGINX
Release team explains links between Version 1.36 and classic print The Great Wave off Kanagawa Kubernetes issued a new release called “Haru” on Wednesday, and the release notes and logo might be more interesting than the software.…
🔗 Source: https://go.theregister.com/feed/www.theregister.com/2026/04/23/kubernetes_1_36_haru/
#nginx
📰 I don't use Tailscale or Nginx to access my home lab remotely, here's what I use instead
One of the most useful services to any home labber is a VPN, so that you can access your home network from anywhere and browse as if you're at home. That not only lets you use any self-hosted services you have on your NAS without having to open ports to the wider internet, but it also circumvents any geo-blocked services and nicely encrypts your data, so nobody can snoop in.
🔗 Source: https://www.xda-developers.com/i-dont-use-tailscale-or-nginx-to-access-my-home-lab-remotely-heres-what-i-use-instead/
#nginx
📰 Nginx 1.30 Released With Multipath TCP, ECH & More
Nginx 1.30 was just released as the newest stable version of this popular web server. Nginx 1.30 incorporates all of the changes from the Nginx 1.29.x mainline branch to provide a lot of new functionality like Multipath TCP (MPTCP)...
🔗 Source: https://www.phoronix.com/news/Nginx-1.30-Released
#nginx
📰 Nginx 1.29.7 Delivers Multipath TCP Support
Released this week was Nginx 1.29.7 as the newest mainline version of this HTTP(S) web server. Releasing alongside Nginx 1.28.3 stable, it fixed buffer overflow vulnerabilities and some other vulnerabilities. Making Nginx 1.29.7 more exciting though is that it landed Multipath TCP support...
🔗 Source: https://www.phoronix.com/news/Nginx-1.29.7-Multipath-TCP
#nginx
http://blog.povilasb.com/posts/python-asyncio-vs-nginx-performance/
While I was playing with Python #asyncio I got interested in how well it performs serving data over TLS compared to #Nginx. So I implemented a small HTTPS server with asyncio:
👩💻 Nginx Path Configuration Pitfalls.
• Nginx — это веб-сервер, на котором работает треть всех сайтов в мире. Но если забыть или проигнорировать некоторые ошибки в настройках, можно стать отличной мишенью для атакующих. Благодаря этому материалу, можно понять какие ошибки в конфигурациях встречаются чаще всего и как их исправить.
Attacks:
• Nginx Configuration Vulnerability;
• Exploiting Trailing Slash Misconfiguration;
• Exploiting Parent Directory Access;
• Impact Without Trailing Slash on Alias;
• Combined Impact.
Defend Against Attacks:
• Update Nginx;
• Configuration Check;
• Use Configuration Management;
• Security Headers;
• Access Control;
• Directory Listing;
• Alias Traversal Protection;
• HTTP to HTTPS Redirect;
• SSL Configuration;
• Rate Limiting;
• Connection Limits;
• Custom Error Pages;
• Gzip Compression;
• Client-Side Caching;
• HTTP2 Protocol;
• Secure File Permissions;
• Web Application Firewall (WAF);
• Monitoring and Logging;
• SSH Hardening;
• Firewall Configuration;
• Two-Factor Authentication;
• Regular Backups;
• Deny Hidden Files;
• IP Whitelisting;
• Disable Unused Modules;
• Use Trailing Slash in Alias Directives;
• Regular Expression Matching;
• Implement Strict Location Paths.
#Nginx#devsecops