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
<?php | |
// Todays' date in the format 2022-01-12 | |
echo date( 'Y-m-d' ); | |
// Decode 'encodeURIComponent' encoded string | |
urldecode( ); | |
// Sanitize $_POST array | |
foreach ( $_POST as $key => $value ) | |
{ |
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
let fruits = [ 'apple', 'orange', 'mango' ]; | |
// for / of loop | |
for ( e of fruits ) | |
{ | |
// e is now an element of the array | |
console.log( e ); // Output: apple, orange, mango | |
} | |
// for / in loop |
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
// Reload current page | |
location.reload(); | |
// Ref: https://developer.mozilla.org/en-US/docs/Web/API/Location/reload | |
// Reload page at an interval | |
setTimeout( function(){ location.reload(); }, 30 * 1000 ); // Reload at every 30 seconds | |
// Alternative | |
setTimeout( () => { location.reload(); }, 30 * 1000 ); // Reload at every 30 seconds | |
// Ref: https://developer.mozilla.org/en-US/docs/Web/API/setTimeout |
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
// One time event | |
setTimeout( function(){}, 1000 ); | |
// Repetitive event | |
setInterval( function(){}, 1000 ); | |
// If these need to be canceled, then assign them | |
// to a variable and then clear them like this. | |
clearTimeout( assignedVar ); | |
clearInterval( assignedVar ); |
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
function qs( cls ) | |
{ | |
return document.querySelector( cls ); | |
} | |
function qsa( cls ) | |
{ | |
return document.querySelectorAll( cls ); | |
} |
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
// Create an Element | |
let ele = document.createElement( 'div' ); // Replace 'div' with required element | |
// Insert Text | |
ele.innerText = 'Hello World!'; | |
// or | |
ele.innerHTML = 'Hello World!'; | |
// or, not recommended | |
let textNode = document.createTextNode( 'Hello World!' ); // Create a text node | |
ele.appendChild( textNode ); |
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
[{"quote": "Life isn’t about getting and having, it’s about giving and being.", "author": "Kevin Kruse"}, | |
{"quote": "Whatever the mind of man can conceive and believe, it can achieve.", "author": "Napoleon Hill"}, | |
{"quote": "Strive not to be a success, but rather to be of value.", "author": "Albert Einstein"}, | |
{"quote": "Two roads diverged in a wood, and I—I took the one less traveled by, And that has made all the difference.", "author": "Robert Frost"}, | |
{"quote": "I attribute my success to this: I never gave or took any excuse.", "author": "Florence Nightingale"}, | |
{"quote": "You miss 100% of the shots you don’t take.", "author": "Wayne Gretzky"}, | |
{"quote": "I’ve missed more than 9000 shots in my career. I’ve lost almost 300 games. 26 times I’ve been trusted to take the game winning shot and missed. I’ve failed over and over and over again in my life. And that is why I succeed.", "author": "Michael Jordan"}, | |
{"quote": "The most difficult thing is the decision to act, the rest is merely tenacity.", "author": " |
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
body | |
{ | |
font-family: 'Segoe UI', Verdana, Arial, Helvetica, sans-serif; | |
background-color: whitesmoke; | |
line-height: 26px; | |
} | |
.container | |
{ | |
background: white; | |
border: 1px solid silver; |
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
/* Go Top */ | |
.go-top { | |
position: fixed; | |
bottom: 2em; | |
right: 2em; | |
text-decoration: none; | |
color: white; | |
background-color: #f6f6f6; | |
background-color: rgba(0, 0, 0, 0.3); | |
font-size: 12px; |
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
$('.goto-top').on( | |
'click', | |
function(e){ | |
e.preventDefault(); | |
$('html, body').animate( { scrollTop: 0 } ); | |
} | |
); |
NewerOlder