Skip to content

Instantly share code, notes, and snippets.

View douglas-henrique's full-sized avatar
👽
let's code?

Douglas Henrique douglas-henrique

👽
let's code?
View GitHub Profile
@douglas-henrique
douglas-henrique / transcribe.ts
Created April 17, 2024 13:26
Script to transcribe audio to text using Xenova/whisper-small and transformers.js
import fs from 'fs'
import { pipeline } from '@xenova/transformers'
import { WaveFile } from 'wavefile';
const options = { //Xenova/whisper-small configurations
chunk_length_s: 30,
stride_length_s: 5,
language: 'portuguese',
task: 'transcribe',
}
@douglas-henrique
douglas-henrique / CustomSpinner.tsx
Last active April 3, 2024 17:01
Custom spinner on react native using Reanimated > 2x + Styled components
import React, { useEffect } from 'react';
import styled from 'styled-components/native';
import Animated, {
cancelAnimation,
Easing,
useAnimatedStyle,
useSharedValue,
withRepeat,
withTiming,
} from 'react-native-reanimated';
@douglas-henrique
douglas-henrique / page.ts
Created May 31, 2023 22:41
Next JS generateMetadata function to twitter opengraph
export async function generateMetadata(
{ params }: { params: { slug: string } }): Promise<Metadata> {
const data: PostFullProps = await getData(params.slug);
return {
title: 'title of your page',
metadataBase: new URL("YOUR_BASE_URL"),
description: 'page description',
keywords: [],
authors: [{ name: 'YOUR NAME' }],
@douglas-henrique
douglas-henrique / encrypt_decrypt.ts
Created March 29, 2023 00:48
Code to encrypt and decrypt strings using node crypto
import crypto from "crypto";
const algorithm = "aes-256-cbc"; //Using AES encryption
const Securitykey = crypto.randomBytes(32);
const initVector = crypto.randomBytes(16);
export const encryptMessage = (message: string) => {
const cipher = crypto.createCipheriv(algorithm, Securitykey, initVector);
let encryptedData = cipher.update(message, "utf-8", "hex");
encryptedData += cipher.final("hex");
import React, { useState } from 'react'
type ScrollProps = {
layoutMeasurement: {
height: number
}
contentOffset: {
y: number
}
contentSize: {