WhatsApp Chat Analyzer

pip install pandas matplotlib emoji


import re

import emoji

import pandas as pd

import matplotlib.pyplot as plt

from collections import Counter


# Define anger and happy keywords

anger_keywords = ['angry', 'hate', 'stupid', 'idiot', 'mad', 'annoy', 'fight']

happy_keywords = ['happy', 'love', 'joy', 'awesome', 'great', '😊', '😁', 'šŸ˜']


def extract_chat_data(chat_file):

    with open(chat_file, 'r', encoding='utf-8') as f:

        lines = f.readlines()


    chat_data = []

    for line in lines:

        # Match typical WhatsApp line format

        match = re.match(r'^(\d{1,2}/\d{1,2}/\d{2,4}),\s(\d{1,2}:\d{2})\s[-–]\s(.+?):\s(.+)', line)

        if match:

            date, time, sender, message = match.groups()

            chat_data.append([date, time, sender, message])

    return pd.DataFrame(chat_data, columns=['Date', 'Time', 'Sender', 'Message'])


def count_emojis(text):

    return [char for char in text if char in emoji.EMOJI_DATA]


def analyze_emojis(df):

    emoji_counter = Counter()

    sender_emoji = {}


    for _, row in df.iterrows():

        emojis = count_emojis(row['Message'])

        emoji_counter.update(emojis)

        sender = row['Sender']

        if sender not in sender_emoji:

            sender_emoji[sender] = Counter()

        sender_emoji[sender].update(emojis)

    

    return emoji_counter.most_common(10), sender_emoji


def analyze_mood(df):

    mood_scores = []

    for _, row in df.iterrows():

        message = row['Message'].lower()

        mood = 0

        mood += sum(word in message for word in happy_keywords)

        mood -= sum(word in message for word in anger_keywords)

        mood_scores.append(mood)

    df['MoodScore'] = mood_scores

    return df


def plot_top_emoji_users(sender_emoji):

    emoji_counts = {sender: sum(emojis.values()) for sender, emojis in sender_emoji.items()}

    users = list(emoji_counts.keys())

    counts = list(emoji_counts.values())


    plt.figure(figsize=(8, 4))

    plt.bar(users, counts, color='teal')

    plt.title("Emoji Usage by User")

    plt.ylabel("Total Emojis Used")

    plt.xticks(rotation=45)

    plt.tight_layout()

    plt.show()


def plot_mood_over_time(df):

    mood_by_day = df.groupby("Date")["MoodScore"].sum()

    plt.figure(figsize=(8, 4))

    mood_by_day.plot(kind="line", marker="o", color="purple")

    plt.title("Mood Trend Over Time")

    plt.xlabel("Date")

    plt.ylabel("Mood Score")

    plt.xticks(rotation=45)

    plt.tight_layout()

    plt.show()


if __name__ == "__main__":

    chat_file = "chat.txt"  # exported WhatsApp chat file

    df = extract_chat_data(chat_file)


    df = analyze_mood(df)

    top_emojis, sender_emoji = analyze_emojis(df)


    print("\nšŸ” Top Emojis Used:")

    for emo, count in top_emojis:

        print(f"{emo}: {count}")


    print("\nšŸ™‹‍♂️ Emoji Usage by Users:")

    for sender, emojis in sender_emoji.items():

        print(f"{sender}: {sum(emojis.values())} emojis")


    plot_top_emoji_users(sender_emoji)

    plot_mood_over_time(df)

 

File Compression Tool

pip install pyminizip

import tkinter as tk
from tkinter import filedialog, messagebox
import os
import zipfile
import pyminizip

class FileCompressorApp:
    def __init__(self, root):
        self.root = root
        self.root.title("File Compression Tool šŸ—œ️")
        self.root.geometry("450x300")
        self.files = []

        self.label = tk.Label(root, text="Drag and Drop Files or Use 'Browse'", font=("Helvetica", 12))
        self.label.pack(pady=10)

        self.file_listbox = tk.Listbox(root, width=50, height=8)
        self.file_listbox.pack()

        self.browse_button = tk.Button(root, text="Browse Files", command=self.browse_files)
        self.browse_button.pack(pady=5)

        self.password_label = tk.Label(root, text="Password (optional):")
        self.password_label.pack()
        self.password_entry = tk.Entry(root, show="*")
        self.password_entry.pack(pady=2)

        self.compress_button = tk.Button(root, text="Compress to ZIP", command=self.compress_files)
        self.compress_button.pack(pady=10)

    def browse_files(self):
        paths = filedialog.askopenfilenames()
        for path in paths:
            if path not in self.files:
                self.files.append(path)
                self.file_listbox.insert(tk.END, path)

    def compress_files(self):
        if not self.files:
            messagebox.showerror("No Files", "Please select files to compress.")
            return

        zip_path = filedialog.asksaveasfilename(defaultextension=".zip", filetypes=[("ZIP files", "*.zip")])
        if not zip_path:
            return

        password = self.password_entry.get()

        try:
            if password:
                # Use pyminizip for password protection
                compression_level = 5
                pyminizip.compress_multiple(self.files, [], zip_path, password, compression_level)
            else:
                # Use zipfile for normal compression
                with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
                    for file in self.files:
                        arcname = os.path.basename(file)
                        zipf.write(file, arcname)

            messagebox.showinfo("Success", f"Files compressed successfully to:\n{zip_path}")
        except Exception as e:
            messagebox.showerror("Error", f"Compression failed:\n{str(e)}")

if __name__ == "__main__":
    root = tk.Tk()
    app = FileCompressorApp(root)
    root.mainloop()

Live Webcam Effects App

pip install opencv-python dlib numpy imutils


live_webcam_filters.py


import cv2
import dlib
import numpy as np

# Load face detector and landmark predictor
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")

# Load overlay images (with transparency)
glasses = cv2.imread("filters/glasses.png", cv2.IMREAD_UNCHANGED)
mustache = cv2.imread("filters/mustache.png", cv2.IMREAD_UNCHANGED)
dog_ears = cv2.imread("filters/dog_ears.png", cv2.IMREAD_UNCHANGED)

def overlay_transparent(background, overlay, x, y, scale=1):
    """Overlay PNG with alpha channel"""
    overlay = cv2.resize(overlay, (0, 0), fx=scale, fy=scale)
    h, w, _ = overlay.shape

    if x + w > background.shape[1] or y + h > background.shape[0]:
        return background

    alpha_overlay = overlay[:, :, 3] / 255.0
    for c in range(0, 3):
        background[y:y+h, x:x+w, c] = background[y:y+h, x:x+w, c] * (1 - alpha_overlay) + overlay[:, :, c] * alpha_overlay
    return background

cap = cv2.VideoCapture(0)

while True:
    ret, frame = cap.read()
    if not ret:
        break

    # Flip frame for mirror effect
    frame = cv2.flip(frame, 1)
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    faces = detector(gray)

    for face in faces:
        landmarks = predictor(gray, face)

        # Coordinates for glasses
        left_eye = (landmarks.part(36).x, landmarks.part(36).y)
        right_eye = (landmarks.part(45).x, landmarks.part(45).y)
        eye_center = ((left_eye[0] + right_eye[0]) // 2, (left_eye[1] + right_eye[1]) // 2)
        eye_width = int(1.5 * abs(right_eye[0] - left_eye[0]))
        glasses_resized = cv2.resize(glasses, (eye_width, int(glasses.shape[0] * eye_width / glasses.shape[1])))
        frame = overlay_transparent(frame, glasses_resized, eye_center[0] - eye_width // 2, eye_center[1] - 25)

        # Coordinates for mustache
        nose = (landmarks.part(33).x, landmarks.part(33).y)
        mustache_resized = cv2.resize(mustache, (eye_width, int(mustache.shape[0] * eye_width / mustache.shape[1])))
        frame = overlay_transparent(frame, mustache_resized, nose[0] - eye_width // 2, nose[1] + 10)

        # Dog ears
        top_head = (landmarks.part(27).x, landmarks.part(27).y - 100)
        ears_resized = cv2.resize(dog_ears, (eye_width * 2, int(dog_ears.shape[0] * (eye_width * 2) / dog_ears.shape[1])))
        frame = overlay_transparent(frame, ears_resized, top_head[0] - eye_width, top_head[1])

    cv2.imshow("Live Webcam Filters šŸ§‘‍šŸŽ¤", frame)
    if cv2.waitKey(1) == 27:
        break  # ESC to quit

cap.release()
cv2.destroyAllWindows()

Puzzle Image Generator

 pip install pillow

puzzle.py

import tkinter as tk
from PIL import Image, ImageTk
import random

GRID_SIZE = 3  # 3x3 puzzle
TILE_SIZE = 100  # Pixel size for each tile
IMAGE_PATH = "sample.jpg"  # Replace with your image path


class PuzzleGame:
    def __init__(self, root):
        self.root = root
        self.root.title("🧩 Image Puzzle Game")

        self.image = Image.open(IMAGE_PATH)
        self.image = self.image.resize((TILE_SIZE * GRID_SIZE, TILE_SIZE * GRID_SIZE))
        self.tiles = []
        self.tile_images = []
        self.buttons = []

        self.empty_pos = (GRID_SIZE - 1, GRID_SIZE - 1)

        self.create_tiles()
        self.shuffle_tiles()
        self.draw_tiles()

    def create_tiles(self):
        for row in range(GRID_SIZE):
            row_tiles = []
            for col in range(GRID_SIZE):
                if (row, col) == self.empty_pos:
                    row_tiles.append(None)
                    continue
                left = col * TILE_SIZE
                upper = row * TILE_SIZE
                right = left + TILE_SIZE
                lower = upper + TILE_SIZE
                tile = self.image.crop((left, upper, right, lower))
                tk_img = ImageTk.PhotoImage(tile)
                self.tile_images.append(tk_img)
                row_tiles.append(tk_img)
            self.tiles.append(row_tiles)

    def shuffle_tiles(self):
        # Flatten and shuffle the tiles
        flat_tiles = [tile for row in self.tiles for tile in row if tile is not None]
        random.shuffle(flat_tiles)

        idx = 0
        for row in range(GRID_SIZE):
            for col in range(GRID_SIZE):
                if (row, col) == self.empty_pos:
                    continue
                self.tiles[row][col] = flat_tiles[idx]
                idx += 1

    def draw_tiles(self):
        for row in range(GRID_SIZE):
            for col in range(GRID_SIZE):
                btn = tk.Button(self.root, image=self.tiles[row][col],
                                command=lambda r=row, c=col: self.move_tile(r, c))
                btn.grid(row=row, column=col)
                self.buttons.append(btn)

    def move_tile(self, r, c):
        er, ec = self.empty_pos
        if abs(er - r) + abs(ec - c) == 1:  # Must be adjacent
            # Swap tiles
            self.tiles[er][ec], self.tiles[r][c] = self.tiles[r][c], self.tiles[er][ec]
            self.empty_pos = (r, c)
            self.update_tiles()

    def update_tiles(self):
        for row in range(GRID_SIZE):
            for col in range(GRID_SIZE):
                btn = self.root.grid_slaves(row=row, column=col)[0]
                img = self.tiles[row][col]
                if img:
                    btn.config(image=img)
                else:
                    btn.config(image='', text='')


if __name__ == "__main__":
    root = tk.Tk()
    game = PuzzleGame(root)
    root.mainloop()



Command Palette GUI app

pip install fuzzywuzzy python-Levenshtein

import tkinter as tk
from tkinter import messagebox
import subprocess
import os
from fuzzywuzzy import process

# Sample commands/apps to match
COMMANDS = {
    "Open Notepad": "notepad",
    "Open Calculator": "calc",
    "Command Prompt": "cmd",
    "Open Task Manager": "taskmgr",
    "Open Paint": "mspaint",
    "Open Explorer": "explorer",
    "Shutdown": "shutdown /s /t 1",
    "Restart": "shutdown /r /t 1",
    "Open Downloads": os.path.expanduser("~/Downloads"),
    "Open VSCode": r"C:\Users\ASUS\AppData\Local\Programs\Microsoft VS Code\Code.exe",  # Modify as needed
}

class CommandPaletteApp:
    def __init__(self, root):
        self.root = root
        self.root.title("Command Palette")
        self.root.geometry("500x300")
        self.root.configure(bg="#1e1e1e")

        self.entry = tk.Entry(self.root, font=("Segoe UI", 16), bg="#252526", fg="white", insertbackground="white")
        self.entry.pack(pady=20, padx=20, fill="x")
        self.entry.bind("<KeyRelease>", self.update_suggestions)
        self.entry.bind("<Return>", self.execute_selection)

        self.listbox = tk.Listbox(self.root, font=("Segoe UI", 14), bg="#1e1e1e", fg="white", selectbackground="#007acc")
        self.listbox.pack(padx=20, fill="both", expand=True)
        self.listbox.bind("<Double-Button-1>", self.execute_selection)

        self.commands = list(COMMANDS.keys())
        self.update_list(self.commands)

    def update_suggestions(self, event=None):
        typed = self.entry.get()
        if typed == "":
            self.update_list(self.commands)
        else:
            results = process.extract(typed, self.commands, limit=8)
            self.update_list([r[0] for r in results if r[1] > 40])

    def update_list(self, data):
        self.listbox.delete(0, tk.END)
        for item in data:
            self.listbox.insert(tk.END, item)

    def execute_selection(self, event=None):
        selection = self.listbox.get(tk.ACTIVE)
        if selection in COMMANDS:
            command = COMMANDS[selection]
            try:
                if os.path.isfile(command):
                    subprocess.Popen(command)
                elif os.path.isdir(command):
                    os.startfile(command)
                else:
                    subprocess.Popen(command, shell=True)
            except Exception as e:
                messagebox.showerror("Error", f"Failed to execute: {e}")
        else:
            messagebox.showinfo("Not Found", "No matching command to run.")

if __name__ == "__main__":
    root = tk.Tk()
    app = CommandPaletteApp(root)
    root.mainloop()