Skip to content

Instantly share code, notes, and snippets.

View lenivene's full-sized avatar
🖖
Full-stack dev

Lenivene Bezerra lenivene

🖖
Full-stack dev
View GitHub Profile
@lenivene
lenivene / array_keys_exist-function.php
Last active March 16, 2019 15:47
Checks if multiple keys exist in an array
<?php
/**
* Checks if multiple keys exist in an array
*
* @param array $array
* @param array|string $keys
*
* @author Lenivene Bezerra
* @return bool
@lenivene
lenivene / function.php
Last active March 16, 2019 15:38
Função para verificar se é servidor de teste (localhost)
<?php
/**
* Verificar servidor
* @return null Retorna se tiver erro, se preferir troque para class Exception.
* @return true | false Retorna true para localhost e false para servidor
*
* @version 1.0
* @author Lenivene Bezerra
*/
function isServerLocal(){
@lenivene
lenivene / no-js.js
Created October 26, 2018 12:40
Remove class no-js
(function() {
var docElement = document.documentElement;
var classRE = new RegExp('(^|\\s)no-js(\\s|$)');
var className = docElement.className;
docElement.className = className.replace(classRE, '$1js$2');
})();
@lenivene
lenivene / code.html
Created July 20, 2018 04:06
Arrow code html
A. Left: &larr;
A. Right: &rarr;
@lenivene
lenivene / get_real_ip_cloudflare.php
Last active October 24, 2023 21:10
Get REAL IP in CloudFlare by PHP
<?php
function get_ip(){
if( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ){
$ip = $_SERVER['HTTP_CLIENT_IP'];
}
elseif( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else{
$ip = $_SERVER['REMOTE_ADDR'];
@lenivene
lenivene / screen.lockOrientation.js
Last active July 10, 2018 16:28
Cross browser screen lock orientation
var win = window,
lockOrientation = win.screen.lockOrientation || win.screen.mozLockOrientation || win.screen.msLockOrientation || function(){
return null;
}
if( lockOrientation ){
/**
* Parameters
* [ portrait-primary, portrait-secondary, landscape-primary, landscape-secondary, portrait, landscape, default ]
*/
@lenivene
lenivene / function.php
Created May 17, 2018 13:07
Get all URLS by PHP
<?php
preg_match_all("/\b(?:(?:https?|ftp|mailto|tel):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/m", $urls, $callback);
<?php
function dias_feriados( $year = null ){
if( $year === null ){
$year = intval( date( 'Y' ) );
}
/**
* easter_date() will generate a warning
* if the year is outside of the range
* for Unix timestamps (i.e. before 1970 or after 2037).
@lenivene
lenivene / function.js
Last active May 11, 2018 03:13
Identical jQuery offset() Method
function getOffset( element ){
var rect = element.getBoundingClientRect();
return {
top: rect.top + window.pageYOffset,
left: rect.left + window.pageXOffset,
};
}
@lenivene
lenivene / function.js
Created May 10, 2018 16:25
Function Scroll Animation Y (vertical) JavaScript | Cross-browser
window.requestAnimFrame = function(){
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||
function( callback ){
window.setTimeout( callback, 1000 / 60 );
};
};
// main function
function scrollToY( scrollTargetY, speed, easing ){
/**