Monitor and Restart a Systemd Service
Ensure critical web services remain active. This bash script checks if a specified systemd service is running and restarts it if it's found to be inactive or in a failed state.
Hundreds of production-ready scripts and coding solutions.
Brought to you by the experts at DigitalCodeLabs.
Ensure critical web services remain active. This bash script checks if a specified systemd service is running and restarts it if it's found to be inactive or in a failed state.
Perform simple rotation for application log files. This script archives old log files by compressing and renaming them with a timestamp, then truncates the original log file for fresh logging.
Reclaim valuable disk space by automatically locating and removing files older than a specified number of days in a target directory. Useful for cleaning up temporary files or old backups.
Optimize web page performance by batching multiple DOM manipulations into a single reflow using DocumentFragment, significantly reducing browser rendering cycles and improving responsiveness.
Learn to precisely insert new DOM elements relative to an existing element's position (before, inside, or after) using the powerful `insertAdjacentElement` method for fine-grained control over layout.
Implement a robust and user-friendly copy-to-clipboard functionality using the modern JavaScript Clipboard API, providing instant feedback for web applications and improving user experience.
Optimize performance for lazy loading, infinite scrolling, or animations by efficiently detecting when elements enter or exit the viewport using the JavaScript Intersection Observer API.
Enable smooth, programmatic scrolling to bring specific elements into the viewport using `element.scrollIntoView()`, enhancing user navigation and accessibility in web applications.
Learn to fetch data from a REST API using async/await with robust error handling, loading state management, and clear UI feedback. This snippet ensures a smooth user experience.
Securely make API requests with JWT Bearer Token authentication using the Fetch API, demonstrating how to include the Authorization header for authorized access.
Learn how to upload files (e.g., images, documents) to a backend API using JavaScript's FormData object and the Fetch API, handling multipart/form-data.
Improve performance and user experience by learning to cancel unwanted or stale API requests using the AbortController with the Fetch API.