Code snippets
Copy-paste ready code for common programming tasks.
779 snippets found
Sort Dictionary by Value
Sort a Python dictionary by its values in descending order.
Array Map Filter Reduce
Chain map, filter, reduce, find, some, and every on arrays.
Struct with Methods
Define a Rust struct and implement methods with self and Self.
String Operations and StringBuilder
Manipulate strings with split, join, substring, and StringBuilder in Java.
SELECT with WHERE and ORDER BY
Filter, sort, and limit rows with SELECT, WHERE, and ORDER BY in SQL.
Accessible Form with Inputs
Build an accessible HTML form with labels, inputs, select, and checkbox.
Table with Thead Tbody Tfoot
Structure tabular data with thead, tbody, tfoot, and caption in HTML.
Responsive Images and Video
Embed responsive images with srcset, video, audio, and figure in HTML.
Links Anchors and Download
Create internal, external, anchor, email, phone, and download links in HTML.
Center a Div with Flexbox and Grid
Center elements horizontally and vertically using Flexbox, Grid, and absolute positioning.
CSS Selectors and Pseudo-classes
Target elements with pseudo-classes, pseudo-elements, and attribute selectors.
Controlled Form with Validation
Build a controlled React form with inline validation and error messages.
Event Handling and List Rendering
Handle events and render dynamic lists with keys in React.
Manage Remotes and Push Pull
Add, change, and interact with remote repositories in Git.
View Commit History with git log
Browse, filter, and format commit history with git log options.
Variables and Arrays in Bash
Assign variables, use command substitution, and work with arrays in Bash.
Arrays and Array Functions in PHP
Create indexed, associative, and multidimensional arrays with map and filter.
String Functions in PHP
Manipulate strings with substr, replace, explode, and sprintf in PHP.
Read and Write Files in PHP
Read, write, append, and iterate files with PHP filesystem functions.
PDO Database Queries in PHP
Connect and run prepared statements safely with PDO in PHP.
Sessions and Cookies in PHP
Store user data across requests with sessions and cookies in PHP.
Classes and Inheritance in PHP
Define classes with constructors, visibility, and inheritance in PHP.
Array Deduplication
Deduplicate an array using Set.
Deep Clone
Deep clone objects, supporting common data types.