Code Snippets Library
A collection of useful, modern, and community-contributed code snippets.
Check if Email is Valid Format in PHP
This snippet validates whether an email address is in the correct format using PHP’s built-in filter_var.
Language: PHP
Published: August 4, 2025
Copy Text to Clipboard with One Click
A clean JavaScript function to copy any text to clipboard, perfect for code-sharing or buttons like “Copy URL”.
Language: javascript
Published: August 4, 2025
Python One-Liner to Flatten a Nested List
Flatten a deeply nested list using a Python one-liner with list comprehension
Language: python
Published: August 4, 2025
TailwindCSS Center Div Horizontally & Vertically
Quickly center any div both horizontally and vertically using Tailwind utility classes
Language: HTML / TailwindCSS
Published: August 4, 2025
🔹Auto Scroll to Bottom on New Message (Chat App)
Automatically scrolls to the bottom of a chat container when a new message is added
Language: javascript
Published: August 4, 2025
Simple PHP Rate Limiter for API Endpoints
A lightweight PHP snippet to limit the number of API requests per IP address to prevent abuse or DDoS attacks.
Language: PHP
Published: August 4, 2025
Detect Dark Mode Preference Using JavaScript
This snippet detects whether the user prefers dark mode using the window.matchMedia API, helping you deliver a customized experience.
Language: JavaScript
Published: August 4, 2025
Gemini Flashcard Generator
This Python script generates flashcards based on user-provided Gemini data. It utilizes a simple text file format for input and outputs a formatted HTML file for easy viewing.
Language: python
Published: August 4, 2025
Genimi: Mood-Based Poem Generator
This chatbot uses a simple rule-based system to generate short poems based on user-inputted moods. The poems are intentionally simplistic for demonstration purposes.
Language: python
Published: August 4, 2025