Skip to content

Instantly share code, notes, and snippets.

View raphox's full-sized avatar

Raphael Araújo raphox

View GitHub Profile
@raphox
raphox / documents.ts
Created August 2, 2023 11:32
frontend/src/services/index.ts
import { api } from "@/services";
import { useQuery } from "@tanstack/react-query";
export type Document = {
id: string;
title: string;
description: string;
link: string;
created_at: Date;
updated_at: Date;
@raphox
raphox / documents_controller.rb
Created July 28, 2023 14:38
documents_controller.rb
class DocumentsController < ApplicationController
before_action :set_document, only: %i[ show update destroy ]
# GET /documents
def index
@documents = Document.all
render json: @documents
end
import os
import time
import threading
import firebase_admin
from dotenv import load_dotenv
from firebase_admin import firestore, credentials
from langchain.schema import AIMessage
from flask import Flask, request
const functions = require("firebase-functions");
require("dotenv").config();
exports.answerQuestion = functions.firestore
.document("/questions/{questionId}")
.onCreate((snap, context) => {
const data = snap.data();
functions.logger.log(
#include <Arduino.h>
#include <SPI.h>
#include <SD.h>
#include "AutoAnalogAudio.h"
/******** User Config ************************************/
#define SD_CS_PIN 5
#define AUDIO_DEBUG
@raphox
raphox / SD_test.ino
Created February 11, 2023 12:28
SD_test - Read & Wirte
#include "SD.h"
#include "utils.h"
void setup(){
Serial.begin(115200);
if(!SD.begin()){
Serial.println("Card Mount Failed");
return;
}
uint8_t cardType = SD.cardType();
@raphox
raphox / spy-recorder.ino
Created January 18, 2023 16:30
Simple Arduino Voice Recorder for Spy Bug Voice Recording
/*
File Name: spy-recorder.ino
Created on: 7-Jan-2021
Author: Noyel Seth ([email protected])
https://circuitdigest.com/microcontroller-projects/simple-arduino-voice-recorder-for-spy-bug-voice-recording
*/
/*
Hardware Pinout Connection
Arduino Nano SD Pin
5v ------------ VCC
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createCompletion({
model: "text-davinci-003",
prompt: "escreva um texto sucinto sobre a Microsoft e seu CEO, informando dados de localização atual e telefone.\n\nA Microsoft é uma empresa americana com sede em Redmond, Washington, fundada em 1975 por Bill Gates e Paul Allen. É a maior empresa de software do mundo, oferecendo produtos e serviços como Windows, Office, Skype, Xbox, Bing e muito mais. O CEO da Microsoft é Satya Nadella, que assumiu o cargo em 2014. Ele tem uma forte visão de liderança para ajudar a empresa a crescer e ganhar mercado. A Microsoft possui escritórios em todo o mundo, incluindo em São Francisco, CA, EUA, e em Londres, Reino Unido. O número de telefone da Microsoft é: +1 425 882 8080.\n\nNome: Microsoft\nCEO:",
@raphox
raphox / jsonb_to_table_row.sql
Created August 3, 2022 19:06
copy jsonb data to table row
select agreement_uuid, term->'uuid' from new_agreements
CROSS JOIN LATERAL jsonb_array_elements(royalties_terms) term
where id = 26
create type royalties_terms as (uuid text);
select term.*, agreement_uuid as new_agreement_uuid from new_agreements
CROSS JOIN LATERAL jsonb_populate_recordset(null::agreements_royalty_terms, royalties_terms) term
where id = 26
@raphox
raphox / obfuscate-phone-number.js
Created June 8, 2021 11:34
obfuscate phone number
'+5533991998109'.replace(/[\S](?=[\w]{4})/g, 'X');