Retro Arcade Game Emulator Launcher

import tkinter as tk

from tkinter import messagebox, filedialog

import os

import subprocess

import sqlite3


# ===== Emulator Configuration =====

EMULATOR_PATH = "emulator.exe"  # Update with actual emulator exe

ROMS_FOLDER = "roms"


# ===== Database Setup =====

def init_db():

    conn = sqlite3.connect("user_data.db")

    cur = conn.cursor()

    cur.execute('''

        CREATE TABLE IF NOT EXISTS favorites (

            id INTEGER PRIMARY KEY,

            rom TEXT UNIQUE

        )

    ''')

    conn.commit()

    conn.close()


def add_favorite(rom):

    conn = sqlite3.connect("user_data.db")

    cur = conn.cursor()

    try:

        cur.execute("INSERT INTO favorites (rom) VALUES (?)", (rom,))

        conn.commit()

    except sqlite3.IntegrityError:

        pass

    conn.close()


def remove_favorite(rom):

    conn = sqlite3.connect("user_data.db")

    cur = conn.cursor()

    cur.execute("DELETE FROM favorites WHERE rom=?", (rom,))

    conn.commit()

    conn.close()


def get_favorites():

    conn = sqlite3.connect("user_data.db")

    cur = conn.cursor()

    cur.execute("SELECT rom FROM favorites")

    favs = [row[0] for row in cur.fetchall()]

    conn.close()

    return favs


# ===== Launcher GUI =====

class GameLauncher:

    def __init__(self, root):

        self.root = root

        self.root.title("šŸŽ® Retro Arcade Launcher")

        self.root.geometry("500x500")


        self.favorites = get_favorites()


        self.label = tk.Label(root, text="Available Games", font=("Arial", 14, "bold"))

        self.label.pack(pady=10)


        self.listbox = tk.Listbox(root, width=50, height=20)

        self.populate_list()

        self.listbox.pack()


        btn_frame = tk.Frame(root)

        btn_frame.pack(pady=10)


        tk.Button(btn_frame, text="▶️ Play", command=self.launch_game).grid(row=0, column=0, padx=5)

        tk.Button(btn_frame, text="⭐ Add Fav", command=self.add_to_favorites).grid(row=0, column=1, padx=5)

        tk.Button(btn_frame, text="❌ Remove Fav", command=self.remove_from_favorites).grid(row=0, column=2, padx=5)

        tk.Button(btn_frame, text="šŸ” Refresh", command=self.refresh).grid(row=0, column=3, padx=5)


    def populate_list(self):

        self.listbox.delete(0, tk.END)

        if not os.path.exists(ROMS_FOLDER):

            os.makedirs(ROMS_FOLDER)


        files = [f for f in os.listdir(ROMS_FOLDER) if f.endswith((".nes", ".gba"))]

        for f in files:

            label = f + (" ⭐" if f in self.favorites else "")

            self.listbox.insert(tk.END, label)


    def get_selected_rom(self):

        try:

            selected = self.listbox.get(tk.ACTIVE)

            return selected.replace(" ⭐", "")

        except:

            return None


    def launch_game(self):

        rom = self.get_selected_rom()

        if not rom:

            messagebox.showwarning("No Selection", "Please select a game.")

            return


        rom_path = os.path.join(ROMS_FOLDER, rom)

        if not os.path.exists(EMULATOR_PATH):

            messagebox.showerror("Emulator Not Found", "Update the emulator path in the code.")

            return


        subprocess.Popen([EMULATOR_PATH, rom_path])

        print(f"Launching {rom}...")


    def add_to_favorites(self):

        rom = self.get_selected_rom()

        if rom:

            add_favorite(rom)

            self.refresh()


    def remove_from_favorites(self):

        rom = self.get_selected_rom()

        if rom:

            remove_favorite(rom)

            self.refresh()


    def refresh(self):

        self.favorites = get_favorites()

        self.populate_list()


# === Main ===

if __name__ == "__main__":

    init_db()

    root = tk.Tk()

    app = GameLauncher(root)

    root.mainloop()


Secure Diary with Face Unlock

 Install Requirements

pip install face_recognition opencv-python cryptography

Capture Reference Face

# Optional: capture face from webcam and save as known_face.jpg
import cv2
cam = cv2.VideoCapture(0)
ret, frame = cam.read()
cv2.imwrite("known_face.jpg", frame)
cam.release()
print("Reference face saved.")

Secure Diary Code

import face_recognition
import cv2
import os
from cryptography.fernet import Fernet
from getpass import getpass
import base64

KEY_FILE = "secret.key"
ENC_FILE = "diary.enc"
KNOWN_FACE_FILE = "known_face.jpg"

# === Face Unlock ===
def verify_face():
    if not os.path.exists(KNOWN_FACE_FILE):
        print("Known face image not found.")
        return False

    known_image = face_recognition.load_image_file(KNOWN_FACE_FILE)
    known_encoding = face_recognition.face_encodings(known_image)[0]

    cam = cv2.VideoCapture(0)
    print("Looking for face...")
    ret, frame = cam.read()
    cam.release()

    try:
        unknown_encoding = face_recognition.face_encodings(frame)[0]
        result = face_recognition.compare_faces([known_encoding], unknown_encoding)[0]
        return result
    except IndexError:
        print("No face detected.")
        return False

# === Encryption Helpers ===
def generate_key(password):
    return base64.urlsafe_b64encode(password.encode().ljust(32)[:32])

def encrypt_diary(content, key):
    f = Fernet(key)
    with open(ENC_FILE, "wb") as file:
        file.write(f.encrypt(content.encode()))
    print("Diary encrypted & saved.")

def decrypt_diary(key):
    f = Fernet(key)
    with open(ENC_FILE, "rb") as file:
        data = file.read()
    return f.decrypt(data).decode()

# === Main Diary App ===
def diary_app():
    print("šŸ” Secure Diary Access")

    if not verify_face():
        print("Face verification failed. Access denied.")
        return

    password = getpass("Enter your diary password: ")
    key = generate_key(password)

    if os.path.exists(ENC_FILE):
        try:
            decrypted = decrypt_diary(key)
            print("\nšŸ“– Your Diary:\n", decrypted)
        except:
            print("Failed to decrypt. Wrong password?")
            return
    else:
        print("No diary found. Creating new one...")

    new_entry = input("\n✍️ Write new entry (append to diary):\n> ")
    combined = decrypted + "\n\n" + new_entry if 'decrypted' in locals() else new_entry
    encrypt_diary(combined, key)

if __name__ == "__main__":
    diary_app()

Screen Time Tracker

import time

import pandas as pd

import matplotlib.pyplot as plt

from datetime import datetime

import win32gui  # Windows-only; use AppKit for Mac


LOG_FILE = "screen_time_log.csv"

TRACK_DURATION_MINUTES = 1  # Change as needed

INTERVAL_SECONDS = 5


def get_active_window_title():

    try:

        return win32gui.GetWindowText(win32gui.GetForegroundWindow())

    except:

        return "Unknown"


def track_screen_time(duration_minutes=1, interval=5):

    end_time = time.time() + (duration_minutes * 60)

    usage_log = []


    print("Tracking started... Press Ctrl+C to stop early.")

    while time.time() < end_time:

        window = get_active_window_title()

        timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

        usage_log.append((timestamp, window))

        time.sleep(interval)


    # Save to CSV

    df = pd.DataFrame(usage_log, columns=["Timestamp", "Window"])

    df.to_csv(LOG_FILE, index=False)

    print(f"Tracking complete. Data saved to {LOG_FILE}")

    return df


def generate_report(csv_file):

    df = pd.read_csv(csv_file)

    df["Window"] = df["Window"].fillna("Unknown")


    # Count frequency of window usage

    summary = df["Window"].value_counts().head(10)  # Top 10 apps/windows


    # Plot

    plt.figure(figsize=(10, 6))

    summary.plot(kind="bar", color="skyblue")

    plt.title("Most Used Windows/Apps")

    plt.xlabel("Window Title")

    plt.ylabel("Active Window Count")

    plt.xticks(rotation=45, ha="right")

    plt.tight_layout()

    plt.show()


if __name__ == "__main__":

    df = track_screen_time(TRACK_DURATION_MINUTES, INTERVAL_SECONDS)

    generate_report(LOG_FILE)


News Authenticity Checker

import tkinter as tk

from tkinter import messagebox

from newspaper import Article

from sklearn.feature_extraction.text import TfidfVectorizer

import requests


NEWS_API_KEY = 'your_newsapi_key_here'  # Replace with your NewsAPI key


# ---------- News Verifier Logic ----------

def extract_keywords(text, top_n=10):

    vectorizer = TfidfVectorizer(stop_words='english')

    X = vectorizer.fit_transform([text])

    keywords = sorted(zip(vectorizer.get_feature_names_out(), X.toarray()[0]), key=lambda x: -x[1])

    return [k[0] for k in keywords[:top_n]]


def fetch_related_news(keywords):

    query = ' OR '.join(keywords[:3])  # Limit to top 3

    url = f'https://newsapi.org/v2/everything?q={query}&language=en&apiKey={NEWS_API_KEY}'

    res = requests.get(url)

    if res.status_code != 200:

        return []

    return [a['title'] + ' ' + a['description'] for a in res.json().get('articles', [])]


def calculate_authenticity(article_keywords, related_news):

    related_text = ' '.join(related_news)

    matches = [kw for kw in article_keywords if kw.lower() in related_text.lower()]

    return int((len(matches) / len(article_keywords)) * 100) if article_keywords else 0


# ---------- GUI ----------

class NewsCheckerApp:

    def __init__(self, root):

        self.root = root

        self.root.title("šŸ•µ️ News Authenticity Checker")


        tk.Label(root, text="Paste News Article URL:").pack()

        self.url_entry = tk.Entry(root, width=60)

        self.url_entry.pack(pady=5)


        tk.Button(root, text="šŸ” Check Authenticity", command=self.check_news).pack(pady=10)


        self.result_label = tk.Label(root, text="", font=("Arial", 12, "bold"))

        self.result_label.pack(pady=20)


    def check_news(self):

        url = self.url_entry.get().strip()

        if not url:

            messagebox.showerror("Error", "Please enter a news URL.")

            return


        try:

            article = Article(url)

            article.download()

            article.parse()

            content = article.text


            article_keywords = extract_keywords(content)

            related_news = fetch_related_news(article_keywords)

            score = calculate_authenticity(article_keywords, related_news)


            result = f"✅ Authenticity Score: {score}%"

            if score < 40:

                result += "\n⚠️ This article may not be widely reported."

            else:

                result += "\nšŸ‘ Seems consistent with other sources."


            self.result_label.config(text=result)


        except Exception as e:

            messagebox.showerror("Error", str(e))


# ---------- Run App ----------

if __name__ == "__main__":

    root = tk.Tk()

    app = NewsCheckerApp(root)

    root.mainloop()


PDF Bill Splitter App

 import tkinter as tk

from tkinter import filedialog, messagebox

import fitz  # PyMuPDF

import re

import sqlite3

import os


# ---------- Database Setup ----------

conn = sqlite3.connect('bill_splitter.db')

cursor = conn.cursor()

cursor.execute('''

CREATE TABLE IF NOT EXISTS bills (

    id INTEGER PRIMARY KEY AUTOINCREMENT,

    filename TEXT,

    total_amount REAL,

    per_person REAL,

    roommates TEXT

)

''')

conn.commit()


# ---------- PDF Total Extractor ----------

def extract_total_from_pdf(file_path):

    try:

        doc = fitz.open(file_path)

        text = ""

        for page in doc:

            text += page.get_text()

        doc.close()


        # Try finding the largest ₹/$/Rs. number

        amounts = re.findall(r'[\₹\$\₹Rs\. ]?(\d+[,.]?\d*)', text)

        float_amounts = [float(a.replace(',', '')) for a in amounts]

        return max(float_amounts) if float_amounts else 0.0


    except Exception as e:

        messagebox.showerror("Error", f"Failed to extract total: {str(e)}")

        return 0.0


# ---------- GUI ----------

class BillSplitterApp:

    def __init__(self, root):

        self.root = root

        self.root.title("šŸ“„ PDF Bill Splitter")

        self.filename = None


        # UI Layout

        tk.Button(root, text="šŸ“‚ Upload PDF Bill", command=self.upload_pdf).pack(pady=10)


        self.total_var = tk.StringVar()

        tk.Label(root, text="šŸ’° Total Amount:").pack()

        tk.Entry(root, textvariable=self.total_var, state="readonly").pack(pady=5)


        self.roommates_entry = tk.Entry(root)

        self.roommates_entry.pack(pady=5)

        self.roommates_entry.insert(0, "Enter emails/names comma-separated")


        tk.Button(root, text="➗ Split Bill", command=self.split_bill).pack(pady=10)


    def upload_pdf(self):

        file_path = filedialog.askopenfilename(filetypes=[("PDF Files", "*.pdf")])

        if file_path:

            self.filename = os.path.basename(file_path)

            total = extract_total_from_pdf(file_path)

            self.total_var.set(f"{total:.2f}")


    def split_bill(self):

        total = self.total_var.get()

        roommates = self.roommates_entry.get().split(',')


        if not total or not roommates or len(roommates) < 1:

            messagebox.showerror("Error", "Please upload a PDF and enter roommates.")

            return


        try:

            total = float(total)

            per_person = total / len(roommates)

            roommates_clean = [r.strip() for r in roommates]


            # Save to DB

            cursor.execute('''

                INSERT INTO bills (filename, total_amount, per_person, roommates)

                VALUES (?, ?, ?, ?)

            ''', (self.filename, total, per_person, ", ".join(roommates_clean)))

            conn.commit()


            messagebox.showinfo("Success", f"Each roommate pays: ₹{per_person:.2f}")

            self.email_roommates(roommates_clean, per_person)


        except Exception as e:

            messagebox.showerror("Error", str(e))


    def email_roommates(self, roommates, amount):

        # Mock email reminder

        for r in roommates:

            print(f"[Email to {r}] Your share: ₹{amount:.2f}")


# ---------- Run ----------

if __name__ == "__main__":

    root = tk.Tk()

    app = BillSplitterApp(root)

    root.mainloop()