Skip to content

Instantly share code, notes, and snippets.

View V0idk's full-sized avatar

V0idk

View GitHub Profile
@V0idk
V0idk / tcpdump.py
Created July 11, 2024 08:17 — forked from gteissier/tcpdump.py
Pythonic tcpdump: copy, paste, and enjoy
#!/usr/bin/env python
'''
It has been tested with either py2 or py3.
Beware ancient versions of Linux kernel which may not support SOCK_NONBLOCK
or the memory mapped ring buffer.
BPF filter listed below is compiled form of "not port 22"
if you want to change it, do something like
@V0idk
V0idk / myeval.py
Created October 26, 2021 02:04 — forked from iafisher/myeval.py
A simple implementation of a recursive-descent parser for a language of boolean expressions.
"""A simple implementation of a recursive-descent parser for a language of boolean expressions."""
import readline
def eval_str(expr):
"""Evaluate a boolean expression with the symbols '0', '1', '|', '&', '(' and ')'. All binary
operators must be wrapped in parentheses, even when it would be unambiguous to omit them.
"""
tokens = tokenize(expr)
ast = match_expr(tokens)