Snippets Collection
This collection includes snippets for Python, CSS, and HTML to enhance development efficiency. Here's the updated list:
Python Snippets
Property Getter & Setter
- Prefix:
python-propertygettersetter
- Description: Creates a property with customizable name, type, and error message, including optional type checking.
Read JSON Function
- Prefix:
python-readjsonfunction
- Description: Reads a JSON file with configurable encoding, returning a dictionary or None, with error logging.
FastAPI
FastAPI GET All
- Prefix:
fastapi-get-all
- Description: Creates a FastAPI endpoint to retrieve all items of a customizable resource, returning a list with error handling for not found cases.
FastAPI GET One
- Prefix:
fastapi-get-one
- Description: Creates a FastAPI endpoint to retrieve a single item of a customizable resource by ID, with error handling for not found cases.
FastAPI POST Create
- Prefix:
fastapi-post-create
- Description: Creates a FastAPI endpoint to add a new item to a customizable resource, returning the created item with a 201 status code and error handling.
FastAPI PUT Update
- Prefix:
fastapi-put-update
- Description: Creates a FastAPI endpoint to update an existing item of a customizable resource by ID, with validation and error handling for not found or unchanged cases.
FastAPI DELETE
- Prefix:
fastapi-delete
- Description: Creates a FastAPI endpoint to delete an item of a customizable resource by ID, returning a status dictionary with error handling.
MySQL
MySQL Config
- Prefix:
py-mysqlconfig
- Description: Generates a MySQL Connector configuration file in .ini format for Python applications with user, host, port, password, and database settings.
MySQLDB Operations
- Prefix:
py-mysqldboperations
- Description: A class for managing MySQL database operations with connection management, reading data (get_rows, get_one_row), and executing CRUD operations (execute_sql) with error handling and transaction support.
MySQLDB Read All
- Prefix:
py-mysqlreadall
- Description: Reads all records from the database using a static method with a simple SELECT query.
MySQLDB Read by ID
- Prefix:
py-mysqlreadbyid
- Description: Reads a record by ID from the database.
MySQLDB Create
- Prefix:
py-mysqlcreate
- Description: Creates a new record in the database.
MySQLDB Update
- Prefix:
py-mysqlupdate
- Description: Updates two columns in the database based on a specified condition column.
MySQLDB Soft Delete
- Prefix:
py-mysqlsoftdelete
- Description: Soft deletes a record by marking it as inactive instead of removing it from the database.
MySQLDB Delete
- Prefix:
py-mysqldelete
- Description: Deletes a record from the database by ID.
Pandas, NumPy, Matplotlib, Seaborn, and SciPy Statistical Analysis and Visualization Snippets
Statistical Measures
- Prefix:
py-statisticalmeasures
- Description: Calculates and prints basic statistical measures (mean, median, variance, IQR, skewness, kurtosis) for a DataFrame column, returning them as a dictionary.
Statistical Outliers
- Prefix:
py-statisticaloutliers
- Description: Identifies outliers in a DataFrame column using Z-scores and the IQR method, printing them as lists.
Histogram
- Prefix:
py-histogram
- Description: Calculates dynamic bins for a dataset column (without plotting), preparing variables for use with 'NormalDistributionOverlayDynamic' to create a histogram with a normal distribution overlay.
Multi Histogram
- Prefix:
py-multihistogram
- Description: Creates overlapping histograms for two categories within a dataset using sns.histplot(), with dynamic bins and customizable colors and transparency.
NormalDistributionOverlayDynamic
- Prefix:
py-normaldistoverlay-dynamic
- Description: Plots a histogram with dynamically calculated bins (from 'Histogram' snippet) and overlays a normal distribution curve, using a dual y-axis for clarity.
Boxplot
- Prefix:
py-boxplot
- Description: Creates a boxplot with customizable whisker range and category labels for a dataset variable.
Multi Boxplot
- Prefix:
py-multiboxplot
- Description: Creates a boxplot comparing multiple categories with customizable whisker range and labels.
Catplot
- Prefix:
py-catplot
- Description: Creates a categorical plot (e.g., bar, count) with customizable kind and labels for a dataset column.
Linear Regression Direction
- Prefix:
py-linreg-direction
- Description: Fits a linear regression model to the data, prints the intercept and slope coefficient.
Trendline and Residuals
- Prefix:
py-trendline-residuals
- Description: Calculates the trendline and residuals from a linear regression model.
Autocorrelation
- Prefix:
py-autocorrelation
- Description: Generates an autocorrelation function (ACF) plot for the residuals to check for patterns or seasonality.
Exponential Smoothing
- Prefix:
py-exp-smoothing
- Description: Optimizes the alpha parameter for exponential smoothing of residuals and applies the optimal alpha.
Prediction with Exponential Smoothing
- Prefix:
py-pred-exp-smoothing
- Description: Makes predictions by combining the trendline with exponentially smoothed residuals and calculates the MAE.
Prediction with Seasonal Regression
- Prefix:
py-pred-seasonal-reg
- Description: Adjusts the trendline with seasonal averages by day and calculates the MAE.
Prediction with Seasonal Regression
- Prefix:
py-pred-seasonal-reg
- Description: Adjusts the trendline with seasonal averages by day and calculates the MAE.
CSS Snippets
CSS Structure
- Prefix:
css-structure
- Description: Provides a structured CSS file template with organized sections for settings, generic styles, elements, objects, components, and utilities.
Reset
- Prefix:
css-reset
- Description: A modern CSS reset to normalize styles across browsers with improved typography and layout defaults.
Flexbox
- Prefix:
css-flexbox
- Description: Creates a flexible container using CSS Flexbox with customizable alignment, spacing, and wrapping.
Grid
- Prefix:
css-grid
- Description: Creates a responsive CSS Grid layout with customizable columns and spacing.
- Prefix:
css-mediaquery
- Description: Defines a media query for responsive design with a customizable breakpoint.
Pseudo-Elements
- Prefix:
css-pseudoelements
- Description: Adds a pseudo-element (e.g., ::before) with customizable content and styling.
- Prefix:
css-button
- Description: Creates a styled button with hover and focus effects for accessibility and interaction.
Animation Keyframes
- Prefix:
css-animationkeyframes
- Description: Creates a fade-in animation with customizable timing, easing, and movement.
Variables
- Prefix:
css-variables
- Description: Defines reusable CSS custom properties (variables) with an example usage.
HTML Snippets
Navbar
- Prefix:
html-navbar
- Description: Creates a simple, accessible navigation bar with semantic markup.
Table
- Prefix:
html-table
- Description: Creates an accessible HTML table with a caption and semantic structure.
Dropdown List
- Prefix:
html-dropdownlist
- Description: Creates an accessible dropdown list with a label, default option, and wrapping div.
- Prefix:
html-radiobuttongroup
- Description: Creates an accessible group of radio buttons with a legend and optional default selection.
Checkbox Group
- Prefix:
html-checkboxgroup
- Description: Creates an accessible group of checkboxes with a legend and optional default selections.
- Prefix:
html-button
- Description: Inserts an accessible button element with a class and customizable type.
- Prefix:
html-form
- Description: Creates an accessible form with a labeled input field and submit button.
Video
- Prefix:
html-video
- Description: Inserts an accessible video element with a source and fallback text.
Audio
- Prefix:
html-audio
- Description: Inserts an accessible audio element with a source and fallback text.
Card
- Prefix:
html-card
- Description: Creates an accessible card structure with an image and content using semantic markup.
Usage
Creative Commons Attribution-NoDerivatives 4.0 International License (CC BY-ND 4.0)
This work is licensed under the Creative Commons Attribution-NoDerivatives 4.0 International License.
Permissions:
- Use and share this work as is.
- Attribution to the author is required.
Restrictions:
- No modifications or derivative works.
- No distribution of altered versions.
THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. THE AUTHORS OR COPYRIGHT HOLDERS SHALL NOT BE LIABLE FOR ANY CLAIM OR DAMAGES ARISING FROM THE USE OF THIS WORK.
| |