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 / 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 / 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 / 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
<span
style="
width: 2rem;
height: 2rem;
position: relative;
overflow: hidden;
display: flex;
border-radius: 50%;
"
>
.blur{
background: rgba(0,0,0,.5);
backdrop-filter: saturate(180%) blur(20px);
}
declare module "react-native-radial-gradient" {
import * as ReactNative from "react-native";
import * as React from "react";
type Props = ReactNative.ViewPropTypes & {
style?: ReactNative.StyleProp<ReactNative.ViewStyle>;
colors: string[];
stops: number[];
center: number[];
radius: number;
@lenivene
lenivene / AttributesWithObjectId.d.ts
Created May 13, 2021 17:47
Extend attributes schema mongoose with _id
import { ObjectId } from "mongoose";
export type AttributesWithObjectId<Attr> = {
_id: ObjectId
} & Attr