Skip to content

Instantly share code, notes, and snippets.

@deusebio
deusebio / tcpdump_parser.py
Created September 19, 2023 08:46
Parse tcpdump output
import pandas as pd
import re
space_splitter = re.compile("\s+")
regex = re.compile("\s*(.*)\s*>\s*(.*?):\s.*")
def parse_line(line):
try:
elements = space_splitter.split(line)
source_dest = regex.match(" ".join(elements[4:])).groups()
@deusebio
deusebio / parse_ini_bash.sh
Created January 14, 2022 22:46
Bash function to parse ini configuration files
#!/bin/bash
function iniget() {
if [[ $# -lt 2 || ! -f $1 ]]; then
echo "usage: iniget <file> [--list|<section> [key]]"
return 1
fi
local inifile=$1
if [[ "$2" == "--list" ]]; then
@deusebio
deusebio / networkXmas.py
Last active December 14, 2021 13:37
Wishing a merry Christmas with networkx
from typing import Any, Tuple, Dict
import networkx as nx
import numpy as np
def generate_Xmas_tree(depth: int) -> nx.Graph:
nodes = set(range(sum(i for i in range(depth+1))))
# Create the tree