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
[{
"version": "1.0",
"image": {
"name": "/home/videosdownloader/public_html/image/public/uploadt/carregamento 01-giff.gif",
"baseName": "carregamento 01-giff.gif",
"format": "GIF",
"formatDescription": "GIF",
"mimeType": "image/gif",
"class": "PseudoClass",
@lenivene
lenivene / useResentCodeTimer.ts
Created March 8, 2024 14:32
This function, named `useResentCodeTimer`, is a custom React hook that manages a countdown timer for a resend code functionality
import { useState, useEffect } from 'react';
interface ResentCodeTimerProps {
initialValue?: number;
}
export const useResentCodeTimer = ({ initialValue = 60 }: ResentCodeTimerProps) => {
const [resentCodeIn, setResentCodeIn] = useState(initialValue);
let startTime: Date | undefined;
@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 / formatPhoneNumberHelper.ts
Last active August 20, 2023 16:14
The provided function `formatPhoneNumber` takes a phone number as input and returns a formatted version of that phone number.
export const formatPhoneNumberHelper = (number: string): string => {
const cleanedNumber: string = String(number).replace(/\D/g, "");
// Check if the number has at least 10 digits
if (cleanedNumber.length < 10) {
return number;
}
// Extract the DDI (the first digits, can be 2 or 3)
const DDI: string = cleanedNumber.slice(
@lenivene
lenivene / drop-all-database-mongo.js
Created June 28, 2023 18:01
Drop all database in mongo using Robo 3T
const dbRequired = ["admin", "config", "local"];
db.getMongo()
.getDBNames()
.forEach(function (name) {
if (!dbRequired.includes(name)) {
db.getSiblingDB(name).dropDatabase();
print("Dropped database: " + name);
}
});
@lenivene
lenivene / api.vagalume.config.js
Last active February 13, 2023 10:42
Aqui exibe os resultados ;)
if(window.jQuery)
$(document).ready(function(){
/**
* More informations
* URI: http://api.vagalume.com.br/docs/radios/
*/
var radio = "coca-cola-fm", // Your webradio here
api_key = ""; // Get key here http://auth.vagalume.com.br/settings/api/
if(typeof "undefined" != radio
@lenivene
lenivene / functions.php
Last active October 20, 2021 17:31
Add key `thumbnail_url` in WordPress REST API
<?php
add_action('rest_api_init', 'register_rest_images' );
function register_rest_images(){
register_rest_field( array('post'),
'thumbnail_url',
array(
'get_callback' => 'get_rest_featured_image',
'update_callback' => null,
'schema' => null,
)
.inputContainer:focus-within svg {
color: #fff;
}
nano /etc/motd
@lenivene
lenivene / functions.php
Last active September 3, 2021 12:52
Insert thumbnail (attachment) post by url
<?php
/**
* Insert thumbnail by URL
* Is very good to execute wp_insert_post
*
* @author Lenivene Bezerra
* @param string $url Image url external or no
* @param int $post_ID Post id to insert thumbnail
* @return ID Thumbnail | WP_Error
*/