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 get_client_ip() { | |
$ipaddress = 'UNKNOWN'; | |
$trusted_ranges = [ | |
'192.0.2.0/24', // Example trusted range | |
// Add more trusted ranges here | |
]; | |
foreach ($trusted_ranges as $range) { | |
if (ip_in_range(get_ip_address(), $range)) { | |
$ipaddress = get_ip_address(); | |
break; |
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
const buffer = 20; // scroll bar buffer | |
const iframe = document.getElementById('ifm'); | |
const pageY = elem => elem.offsetParent ? (elem.offsetTop + pageY(elem.offsetParent)) : elem.offsetTop; | |
const resizeIframe = () => { | |
window.requestAnimationFrame(() => { | |
const height = document.documentElement.clientHeight; | |
const iframeTop = pageY(document.getElementById('ifm')); | |
const heightDiff = height - iframeTop + buffer; |
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
//Pick a color | |
$first-color: hsl(10, 100%, 50%); | |
// Find the complement | |
$second-color: complement($first-color); | |
//Check if you have a cool color on your hands. Cool colors will overpower warm colors when mixing. |
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
window.addEventListener('DOMContentLoaded', function() { | |
var elements = document.querySelectorAll('.changing'); | |
var numOfElements = elements.length; | |
var numOfElementsToShow = 5; | |
if (numOfElements <= numOfElementsToShow) { | |
for (var i = 0; i < numOfElements; i++) { | |
elements[i].style.display = 'block'; | |
} | |
return; |
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="submit"]').attr("disabled", true); |
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
$('.class').hover(function(){ | |
$(this).addClass('hover'); | |
}, function(){ | |
$(this).removeClass('hover'); | |
}); |
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
document.querySelectorAll('img').forEach(img => { | |
img.addEventListener('error', () => { | |
img.src = 'img/broken.png'; | |
}); | |
}); |
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
const highlightsBox = document.querySelectorAll('.highlights-box')[0]; | |
const highlightsLinks = document.querySelectorAll('.highlights-link[id^="s"]'); | |
if (highlightsBox && highlightsLinks) { | |
highlightsLinks.forEach(link => { | |
link.addEventListener('click', event => { | |
event.preventDefault(); | |
const id = link.getAttribute('id'); | |
const srcBox = document.querySelectorAll(`.swap-box.${id}`)[0]; |
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 debounce(func, wait) { | |
let timeout; | |
return function() { | |
const context = this, args = arguments; | |
clearTimeout(timeout); | |
timeout = setTimeout(() => { | |
func.apply(context, args); | |
}, wait); | |
}; | |
} |