Free code snippets
Free code snippets
Small, self-contained patterns from real DEV3 products, each explained, with a live preview where it makes sense. Copy them into your project; commercial use is fine.
- 200
- snippets
- 7
- stacks
- 1
- copies (top 6)
Browse by stack
Most copied
All snippets
Laravel · DatabaseYearly invoice numbering sequenceGap-free invoice numbers such as INV-2026-000042 using one locked counter row per year and prefix, safe under concurrent requests.invoicesequencetransactions WordPress · InternationalisationPOT generation script with WP-CLIA shell script that extracts translatable strings to a .pot file, merges them into .po files and compiles .mo and JSON files.i18npotwp-cli WordPress · DatabaseCustom post type with a linked taxonomyRegister a bookable-room post type with a hierarchical amenity taxonomy, REST support and a safe rewrite flush on theme switch.cpttaxonomyrewrite WordPress · ThemingDark and light mode toggle without flashA theme-level colour mode switch that respects the visitor's system setting, remembers a choice and avoids a flash of the wrong theme.dark-modetoggleaccessibility WooCommerce · HooksWooCommerce custom product tab with admin fieldAdd a custom tab on the single product page and a matching admin field, saved and escaped through WooCommerce hooks.woocommerceproduct-tabsmeta React / Next.js · UtilitiesWCAG contrast ratio functionCalculate the WCAG 2 contrast ratio between two hex colours, grade it AA or AAA and find the nearest passing shade.wcagcontrastaccessibility Laravel · DatabaseVendor payout ledgerAn append-only ledger where sales, commissions and payouts are signed entries, so a vendor's balance is always a sum and never a stored guess.ledgerpayoutsmarketplace Laravel · UtilitiesvCard download responseBuild an RFC 6350 compliant contact card with escaping and line folding, and return it as a downloadable .vcf file.vcardcontactsdownload Tailwind CSS · Feedback and empty statesUpvote button with live countA toggle upvote button that updates the count instantly, confirms with the server and rolls back on failure, styled by aria-pressed.upvotebuttonoptimistic-ui Laravel · Queue jobsUptime check job with alert debouncingA queued HTTP monitor check that only raises an alert after several consecutive failures and sends one recovery notice when the site returns.monitoringqueuehttp Tailwind CSS · NotificationsToast stackA stacked toast notification system with variants, auto-dismiss timers, pause on hover and a polite live region.toastnotificationslive-region Tailwind CSS · FormsTime-slot pickerA booking picker with a row of days and a grid of half-hour slots, disabling taken times and writing the choice to a hidden field.bookingtime-slotspicker Laravel · Queue jobsThrottled campaign batch senderSplit a mailing list into chunked queued jobs that respect a per-minute sending cap using Laravel's rate limiter and job batching.emailbatchthrottle WordPress · Themingtheme.json colour, type and spacing presetsA compact theme.json that defines a palette, fluid font sizes, a spacing scale and element styles for the block editor.theme-jsonblock-themedesign-tokens Laravel · DatabaseTeam-scoped global scope traitA BelongsToTeam trait that filters every query by the current team and stamps new rows automatically, failing closed when no team is set.multi-tenantglobal-scopeeloquent React / Next.js · ThemingTailwind shade scale generatorTurn one base colour into a 50 to 950 shade scale by mixing toward white and black in HSL, ready for Tailwind theme tokens.tailwindcolorpalette Laravel · PaymentsStripe Checkout session and verified webhookCreate a hosted Stripe Checkout session over plain HTTP and handle the signed webhook that confirms the payment, with replay protection.stripecheckoutwebhook Laravel · WebhooksSTOP keyword opt-out handling for inbound SMSDetect STOP, UNSUBSCRIBE and START keywords in inbound text messages, update consent atomically and answer with the required confirmation.smsopt-outconsent Tailwind CSS · NavigationSticky navbar with mobile drawerA sticky top navigation that collapses into a slide-in drawer on small screens, with Escape to close and a backdrop.navbardrawerresponsive WordPress · UtilitiesSticky mini audio player dockA fixed bottom audio dock that plays any link marked with data-audio and keeps playing while the visitor browses the page.audioplayerpodcast Tailwind CSS · Dashboard widgetsStatus components with uptime barsA status page component list with a state badge and a 45-day bar strip per service, coloured by daily availability.status-pageuptimebars Laravel · UtilitiesSSL certificate expiry checkerOpen a TLS connection to a host, read the peer certificate and return days remaining, issuer and subject without any extra packages.ssltlsmonitoring Laravel · DatabaseSplit an order per vendorGroup cart lines by vendor, create one sub-order each and share the order discount across them using integer largest-remainder allocation.marketplaceordersdiscount Tailwind CSS · TablesSortable table with sticky headerA data table with click-to-sort column headers, a sticky header inside a scroll box and correct aria-sort state.tablesortingsticky