Skip to content

Instantly share code, notes, and snippets.

View UnderlineWords's full-sized avatar

Fatih Kececi UnderlineWords

View GitHub Profile
@UnderlineWords
UnderlineWords / function.php
Created July 26, 2021 07:59 — forked from hlashbrooke/function.php
Simple way to generate a random string/password in PHP
<?php
function random_password( $length = 8 ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_-=+;:,.?";
$password = substr( str_shuffle( $chars ), 0, $length );
return $password;
}
?>
@UnderlineWords
UnderlineWords / copy-to-clipboard.js
Created October 1, 2021 20:08
Copy to clipboard with Pure JS
/**
* @referenced https://stackoverflow.com/a/65996386/3299846
* */
function copyToClipboard(e) {
var copyText = document.getElementById(e);
// navigator clipboard api needs a secure context (https)
if (navigator.clipboard && window.isSecureContext) {
// navigator clipboard api method'
return navigator.clipboard.writeText(copyText.value);
} else {