Skip to content

Instantly share code, notes, and snippets.

@radupotop
radupotop / eml-rename.py
Created March 3, 2025 19:44
Rename email files to timestamp-subject-sender
#!/usr/bin/env python3
import argparse
from email import policy
from email.parser import BytesParser
from email.utils import parsedate_to_datetime
from pathlib import Path
from typing import Iterable
from zoneinfo import ZoneInfo
import pandas as pd
# Create sample data
data = {
'Name': ['John', 'Emma', 'Alex', 'Sarah', 'Mike'],
'Age': [28, 24, 32, 27, 30],
'City': ['New York', 'London', 'Paris', 'Tokyo', 'Berlin'],
'Salary': [75000, 65000, 85000, 70000, 80000],
'Department': ['IT', 'HR', 'Finance', 'Marketing', 'IT'],
'Date_Joined': ['2020-01-15', '2019-08-22', '2021-03-10', '2020-11-30', '2018-05-14'],
@radupotop
radupotop / runmap.py
Created November 18, 2024 18:31
Folium map plot
import folium
import pandas as pd
from folium.plugins import MarkerCluster
# Load the CSV file into a Pandas DataFrame
csv_file = 'sl4.csv' # Replace with your CSV file path
data = pd.read_csv(csv_file)
# Initialize a Folium map centered on the average latitude and longitude
average_latitude = data['latitude'].mean()
import json
from operator import attrgetter
import pyalpm
handle = pyalpm.Handle("/", "/var/lib/pacman")
db = handle.get_localdb()
getpkgdata = attrgetter("name", "version")
#!/bin/bash
WINDOW_SIZE="2560x1440"
CWD="$*"
Xephyr -br -ac -noreset -screen $WINDOW_SIZE :9 &
DISPLAY=:9 xfwm4 &
sleep 1
DISPLAY=:9 lxpanel &
DISPLAY=:9 pcmanfm --desktop &
import csv
import sys
def print_dict_as_csv(dict_data):
if not dict_data:
print("The dictionary is empty.")
return
# Get the fieldnames from the keys of the first dictionary
fieldnames = dict_data[0].keys()
@radupotop
radupotop / robots.txt
Created December 10, 2023 20:40
Disallow GPTBot in robots.txt
User-agent: *
Disallow: /action
Disallow: /help
Disallow: /search
Allow: /action/showJournal
Allow: /action/showPublications
User-agent: facebookexternalhit
User-agent: LinkedInBot
User-agent: Twitterbot
from dataclasses import dataclass
from typing import Tuple, Type, Dict
VertexType = Type['Vertex']
@dataclass
class Vertex:
name: str
value: int
@radupotop
radupotop / gocryptmount.sh
Created July 21, 2023 11:03
A basic Gocryptfs mount helper.
#!/bin/bash
#
# A basic Gocryptfs mount helper.
MOUNT_NAME=$(realpath "$1")
BASE_NAME=$(basename "$MOUNT_NAME")
MOUNT_DIR="$HOME/mnt/$BASE_NAME"
logger "Mounting $MOUNT_NAME to $MOUNT_DIR"
from Crypto.PublicKey import RSA
from Crypto.Signature.pkcs1_15 import PKCS115_SigScheme
from Crypto.Hash import SHA256
import binascii
# Generate 1024-bit RSA key pair (private + public key)
keyPair = RSA.generate(bits=1024)
pubKey = keyPair.publickey()
# Sign the message using the PKCS#1 v1.5 signature scheme (RSASP1)