Skip to content

Instantly share code, notes, and snippets.

View jsbeaudry's full-sized avatar

Beaudry Jean Sauvenel jsbeaudry

  • Parkour studio
  • Port-au-prince, Haiti
View GitHub Profile
import { useEffect, useState } from "react";
import Haiex from "haiex-sdk";
const GELATO_KEY = "";
const MAGIC_KEY = "";
const INFURA_KEY = "";
let haiex;
@jsbeaudry
jsbeaudry / hawksoft_client_data.json
Last active February 19, 2024 19:12
hawksoft client model
{
"clientNumber":1,
"details":{
"officeId":1,
"clientType":"Customer",
"status":"Active",
"isPersonal":true,
"isCommercial":false,
"isLifeHealth":false,
"allowCrossSell":false,
{
"Form":{
"Id":"3",
"InternalName":"GayaPLInsuranceForm",
"Name":"Gaya PL Insurance Form"
},
"$version":8,
"$etag":"W/\"datetime'2024-03-12T16%3A33%3A07.8291841Z'\"",
"Date":"2024-03-01",
"HowDidYouFindUs":"Google",
@jsbeaudry
jsbeaudry / extractObjects.js
Created July 11, 2023 18:53
How to get validated objects of a streaming text from chatGPT API
const extractObjects = (arrayString) => {
const objectPattern = /{[^{}]*}/g;
const objects = arrayString.match(objectPattern);
if (objects) {
const parsedObjects = objects.map((objString) => {
try {
return JSON.parse(objString);
} catch (error) {
console.error("Error parsing object:", error);
@jsbeaudry
jsbeaudry / stripeSubscription.js
Last active July 8, 2023 17:31
A Checkout Session represents your customer's session as they pay for one-time purchases or subscriptions through Checkout or Payment Links. We recommend creating a new Session each time your customer attempts to pay. Once payment is successful, the Checkout Session will contain a reference to the Customer, and either the successful PaymentInten…
const Stripe = require("stripe");
const { STRIPE_SECRET_KEY } = process.env;
const stripe = Stripe(STRIPE_SECRET_KEY);
const [planA, planB, planC] = [
"price_1Mj4hPI4ImfNjweeB0fXE9xA",
"price_1Mj4hPI4ImfNjweehhxUwzUh",
"price_1Mj4hQI4ImfNjweeP0q6iEuK",
@jsbeaudry
jsbeaudry / api.js
Created July 8, 2023 17:24
Digicel MonCash - MonCash is a mobile wallet that facilitates reliable, safe and convenient financial transactions to reduce the distance between people regardless of their location in Haiti. While providing its services to its customer base of over 1.5 million people, MonCash maintains its goal of expanding its range of available services.
const express = require('express');
const { createPayment, getCaptureById } = require('./moncash-api');
const app = express();
// API route to create payment
app.get('/payment/create', createPayment); // Parameters: amount, orderId
// API route to get capture by ID
app.get('/capture/getById', getCaptureById); // Parameters: orderId
@jsbeaudry
jsbeaudry / ElevenLabsTextToSpeechAPI.js
Last active July 10, 2023 20:15
Generate top-quality spoken audio in any voice, style and language with the most advanced Text to Speech tool ever. Our AI model renders human intonation and inflections with unprecedented fidelity and it adjusts delivery based on context.
const callElevenLabsTextToSpeechAPI = async (text) => {
if (!text) return "Text parameter can't be null";
const [rachel, anntoni] = ["21m00Tcm4TlvDq8ikWAM", "ErXwobaYiN019PkySvjV"];
const url = `https://api.elevenlabs.io/v1/text-to-speech/${rachel}`;
const apiKey = process.env.ELEVENLABS_KEY;
const headers = {
@jsbeaudry
jsbeaudry / OpenAPI-React-Native
Created March 7, 2023 01:47
Server-Sent Events (SSE) is a standard protocol for sending real-time updates from the server to the client. In this article, we will explain how to implement Server-Sent Events for React Native by using the react-native-sse and react-native-url-polyfill/auto.
//1
yarn add react-native-sse
yarn add react-native-url-polyfill
//2
import EventSource from "react-native-sse";
import "react-native-url-polyfill/auto";
//3
const OPENAI_KEY = '<your-openai-api-key>';
@jsbeaudry
jsbeaudry / Fiat.sol
Last active August 21, 2023 16:57
Create a Bank on the blockchain
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract Fiat is ERC20, ERC20Burnable, Ownable {
constructor() ERC20("Fiat", "FIAT") {
_mint(msg.sender, 1000 * 10 ** decimals());