This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Platform } from 'react-native'; | |
import { | |
check, | |
request, | |
PERMISSIONS, | |
RESULTS, | |
openSettings, | |
} from 'react-native-permissions'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for line in (cat .env) do | |
export $line | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-I | |
../include | |
-I | |
../vendor/include | |
-std=c++14 | |
-stdlib=libc++ | |
-fPIC | |
-isystem | |
/usr/local/include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder