This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$testUsername = "webdevronsocial"; | |
$regEx = '/^@?([a-zA-Z0-9_]{1,15})$/'; | |
if( preg_match( $regEx, $testUsername ) ){ | |
/* This is valid, play your code here */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$testUsername = "https://twitter.com/webdevronsocial"; | |
$regEx = '/(?:https?:\/\/)?(?:www\.)?twitter\.com\/(?:#!\/)?@?([a-zA-Z0-9_]{1,15})/'; | |
if( preg_match( $regEx, $testUsername, $matches ) ){ | |
/** | |
This is valid, play your code here | |
- $matches[0] will returns the profile URl | |
- $matches[1] will returns the Username | |
*/ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var targetElem = document.querySelector("#sidebar"); | |
window.addEventListener('click',function(e){ | |
if( !targetElem.contains(e.target) && (!document.getElementById('navSwitch').contains(e.target))){ | |
$(targetElem).removeClass('open') | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Button/Link: #backToTopBtn | |
document.getElementById('backToTopBtn').addEventListener('click', () => { | |
var start = window.pageYOffset, startTime = null | |
let step = (timestamp) => { | |
if (!startTime) startTime = timestamp | |
var progress = timestamp - startTime, | |
percentage = Math.min(progress / 1000, 1) | |
window.scrollTo(0, start * (1 - percentage)) | |
if (progress < 1000) window.requestAnimationFrame(step) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var warnings = ["First warning!! Do not try to leave or close the window.", "Last warning!! Do not try to leave or close the window.", "Sorry!! Your account locked."]; | |
var i = 0; | |
window.addEventListener("mouseout", function(e) { | |
if (!e.relatedTarget || e.relatedTarget.nodeName == "HTML") { | |
i++; | |
if (i <= 3) { | |
alert(warnings[i - 1]); | |
if (i == 3) { | |
window.location.replace("http://example.com/lock-window"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text" name="inputName" inputmode="numeric" pattern="[0-9]*" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// --- TESTED WITH WordPress 5.3.2 | |
// --- ADD BELLOW CODE TO function.php | |
//** Enable upload for webp image files */ | |
function webp_upload_mimes($existing_mimes) { | |
$existing_mimes['webp'] = 'image/webp'; | |
return $existing_mimes; | |
} | |
//** Enable preview / thumbnail for webp image files */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _memberMenus = document.getElementsByTagName('button'); | |
var _confirmed = false; | |
var _i = 0; | |
var _f = 0; | |
var _resetAttempted = false; | |
function clickMemberMenu() { | |
if (typeof(_memberMenus[_f]) !== 'undefined' && _memberMenus[_f].getAttribute('aria-label') == 'Member Settings') { | |
_resetAttempted = false; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy-column.sql | |
UPDATE `table1` SET | |
`table1`.`col` = (SELECT `table2`.`col` FORM `table2` where `table1`.`ID` = `table2`.`fid`) | |
// REPLACE | |
UPDATE table SET col = REPLACE(col,',','') | |
// TRIM | |
UPDATE table SET col = TRIM(col); |
OlderNewer