Tutorials for Developers & Sysadmins

Step-by-step guides for the work we actually do — Laravel, PHP, WordPress, MySQL, Linux servers, and the occasional rabbit hole. Every command has been run on a real machine; nothing is theoretical.

How to Run Code on URL Hash Change in JavaScript

Run JavaScript when the URL hash changes by listening for the hashchange event on window. Includes initial-load handler, oldURL/newURL access,…

how7o

How to Redirect www to non-www (or vice versa) in Nginx

Redirect non-www to www or www to non-www in Nginx with a dedicated server block and return 301 $scheme://canonical$request_uri. Includes…

how7o

How to Skip a Link When Pressing Tab (tabindex=-1)

Prevent the Tab key from focusing on a specific tag by adding tabindex="-1". Keeps it mouse-clickable but skipped in keyboard…

how7o

How to Open a File Dialog When Clicking a Button

Open the file-selection dialog when a button is clicked: use a for the hidden file input, or call input.click() from…

how7o

How to Make the First Option Selected in a with jQuery

Make the first option selected in a with jQuery: $('#sel').prop('selectedIndex', 0). Includes Select2 variant and how to fire the change…

how7o

How to Make ApexCharts.js Take the Full Width of Its Parent

Make ApexCharts.js fill its parent's width with chart.width: '100%'. Includes the 300px-default fix, ResizeObserver for container resizes, and Bootstrap modal…

how7o

How to Load Data in DataTables Using Ajax

Load DataTables data via Ajax with $('#table').DataTable({ ajax: '...', columns: [{data: ...}] }). Includes JSON response shape, dataSrc, custom render…

how7o

How to Keep Only Numbers in a String with JavaScript

Keep only the digits in a JavaScript string with str.replace(/\D/g, '') or /[^0-9]/g. Includes decimal-point, signed-number, and parseInt conversion variants.

how7o

How to Keep Only the First N Characters of a String in JavaScript

Keep only the first N characters of a JavaScript string with str.slice(0, n) (or substring). Includes ellipsis-truncate, word-boundary, and emoji-safe…

how7o

How to Install the Apache Web Server on Ubuntu

Install Apache on Ubuntu: apt install apache2, allow it through UFW, verify with systemctl, and set up a virtual host.…

how7o