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 / function.php
Last active April 13, 2018 23:02
Checa se um valor existe em uma string
<?php
function in_string( $needle, $haystack ){
if( !isset( $needle ) || isset( $needle ) && !is_string( $needle ) ){
$error['needle'] = 'Param $needle invalid';
}
if( !isset( $haystack ) || isset( $haystack ) && !is_string( $haystack ) ){
$error['$haystack'] = 'Param $needle invalid';
}
@lenivene
lenivene / readme.md
Last active September 10, 2019 02:03
XAMPP: Import Big File SQL

Do u have a problem?

I'm problems solution (haha, ̶ s̶h̶u̶t̶ ̶u̶p̶ ).

Are u ready?

1 - Terminal

Open your CMD, Power Shell and among others... (admin permission)

2 - The commands

@lenivene
lenivene / appstore.svg
Created April 18, 2018 18:22
Store button SVG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lenivene
lenivene / function.php
Last active September 25, 2019 15:23
Check STRING is JSON
<?php
/**
* Check string is JSON
*
* @param string $json JSON to check
*
* @return boolean|array
*/
function is_json( $json = null, $_return = false ){
if( ! is_string( $json ) ){
@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 ){
/**
@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,
};
}
<?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.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);
@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 / 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'];