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
@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
-I
../include
-I
../vendor/include
-std=c++14
-stdlib=libc++
-fPIC
-isystem
/usr/local/include
export const abbreviationNumber = number => {
const qtdMulti = number / 1000;
if (qtdMulti >= 1 && qtdMulti < Math.pow(10, 3)) {
return number / Math.pow(10, 3) + 'K';
}
if (qtdMulti >= Math.pow(10, 3) && qtdMulti < Math.pow(10, 6)) {
return number / Math.pow(10, 6) + 'M';
}
if (qtdMulti >= Math.pow(10, 6) && qtdMulti < Math.pow(10, 9)) {
export function getDiffTimeBetweenCurrentDate (dateString = '', now = new Date()) {
const dayInMilliseconds = 86400000
if ([null, undefined, false, true].includes(dateString)) {
return dateString
}
const date = new Date(dateString)
const isInvalidDate = isNaN(date.getTime())
if (isInvalidDate) {
return dateString
function create () {
const events = {}
function off (n, callback) {
if (!events[n]) {
return
}
events[n] = events[n].filter(fn => fn !== callback)
}