JavaScript Copy to Clipboard Button (Tested Code)
A copy to clipboard button in plain JavaScript: copy text from a div or input on click, show Copied!, fall back on plain HTTP, and add Copy buttons to code blocks.
Notes
Security notes, SOC lab write-ups and tested code by Mahir Faysal, a SOC Level 1 cybersecurity learner in Bangladesh, plus notes from my Next.js and Gemini projects. Sample posts are marked and drafts stay in the admin area.
A copy to clipboard button in plain JavaScript: copy text from a div or input on click, show Copied!, fall back on plain HTTP, and add Copy buttons to code blocks.
Save a Python dict as a readable JSON file with json.dump(indent=4), keep £ and é as they are, handle datetimes, overwrite safely and append the right way.
Hash passwords in PHP with password_hash(), check them with password_verify(), and build a PDO register and login that upgrades old hashes. Real output.
Stop tracking a file in Git without deleting it: git rm --cached, .gitignore, whole folders, a dry run, undoing it, and the catch for teammates and secrets.
Turn 1234.5 into £1,234.50 with Intl.NumberFormat: commas, no symbol, whole pounds, accounting negatives, other currencies, and why to add money in pence.
Format any JavaScript date as dd/mm/yyyy with a five-line function or toLocaleDateString('en-GB'), plus time zones, parsing UK dates and the month-0 trap.
0%