Skip to content

Instantly share code, notes, and snippets.

View IgorHalfeld's full-sized avatar
🍀
Making my own luck every day.

Igor Luiz Halfeld IgorHalfeld

🍀
Making my own luck every day.
View GitHub Profile
import { useEffect, useState } from 'react'
export const useCurrentUser () {
const [user, setCurrentUser] = useState()
const [error, setError] = useState<Error>()
const [loading, setLoading] = useState<boolean>(false)
const fetchLoggedUser = async () => {
setLoading(true)
interface Props {
onStateHover?: (state: string) => void
}
export const BrazilCountyMap = ({ onStateHover }: Props) => {
return (
<svg version="1.1" id="svg-map" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="450px" height="460px" viewBox="0 0 450 460" enable-background="new 0 0 450 460" xml:space="preserve">
<g>
<a href="javascript:void(0)" class="estado" onMouseMove={() => onStateHover?.('Tocantins')} name="Tocantins" code="17" uf="to">
@IgorHalfeld
IgorHalfeld / updateUrlToIndexGSC.ts
Last active September 20, 2024 20:52
Update, publish or delete an URL from Google Search Console - more details 👉🏻 https://notes.igorhalfeld.com/note/automatically-request-gsc-to-index-website-routes
import { google } from 'googleapis';
const createAuth = () => {
const { GOOGLE_GSC_CREDENTIALS } = process.env;
if (!GOOGLE_GSC_CREDENTIALS) {
throw new Error('GOOGLE_GSC_CREDENTIALS env var is not set');
}
const credentials = JSON.parse(GOOGLE_GSC_CREDENTIALS);
/**
* This is really a _best guess_ promise checking. You
* should probably use Promise.resolve(value) to be 100%
* sure you're handling it correctly.
*/
export const isPromise = (value: any): value is Promise<any> => {
if (!value) return false
if (!value.then) return false
if (!isFunction(value.then)) return false
return true
@IgorHalfeld
IgorHalfeld / addSibs.js
Last active April 25, 2024 14:24
add sibelius to any website
function addSibs () {
const div = document.createElement('div')
const img = document.createElement('img')
div.style.position = 'fixed'
div.style.zIndex = '99999999'
div.style.right = '100px'
div.style.bottom = '0px'
div.appendChild(img)
import twilio from 'twilio'
import { MessageListInstanceCreateOptions } from 'twilio/lib/rest/api/v2010/account/message'
interface SendWhatsappMessageOptions {
to: string
from: string
body?: string
contentSid?: string
contentVariables?: Record<string, string>
@IgorHalfeld
IgorHalfeld / auth.ts
Last active February 4, 2024 18:02
nuxt server methods auth middleware
// server/middleware/auth.ts
import { DecodedIdToken } from 'firebase-admin/lib/auth/token-verifier'
import { createAuth } from '@/libs/firebase/firebaseAdmin'
export interface AuthContext {
isAuthenticated: boolean
user: DecodedIdToken | null
}
export async function processPromisesBatch(
items: Array<any>,
limit: number,
fn: (item: any) => Promise<any>,
): Promise<any> {
let results = [];
for (let start = 0; start < items.length; start += limit) {
const end = start + limit > items.length ? items.length : start + limit;
const slicedResults = await Promise.all(items.slice(start, end).map(fn));
import { Platform } from 'react-native';
import {
check,
request,
PERMISSIONS,
RESULTS,
openSettings,
} from 'react-native-permissions';
for line in (cat .env) do
export $line
done