Skip to content

Instantly share code, notes, and snippets.

View bleso-a's full-sized avatar

Blessing Adetoye Adesiji bleso-a

  • Ibadan, Nigeria
View GitHub Profile
import re
CURRENCY_LIST = {"£": "pounds", "$": "dollars", "€": "euros"}
CURRENCY_PATTERN = fr"((?:[{''.join(CURRENCY_LIST.keys())}]+\d*)(?:\,*\d+)(?:\.\d+)?(?i:[km])*)|(\d+(?:\,*\d+)(?:\.\d+)?(?i:[km])*(?:[{''.join(CURRENCY_LIST.keys())}]+))|((?:[{''.join(CURRENCY_LIST.keys())}]+))"
def _currency_to_text(text: str) -> str:
clean = (
lambda x: x.lower()
.replace(",", "")
@bleso-a
bleso-a / app.py
Created December 18, 2021 13:16
Tutorial snippet
from mantiumapi import prompt
from mantiumapi import client
from dotenv import load_dotenv
# load Mantium credentials
load_dotenv()
mantium_user = os.getenv("MANTIUM_USER")
mantium_password = os.getenv("MANTIUM_PASSWORD")
@bleso-a
bleso-a / app.py
Last active December 18, 2021 13:25
Tutorial Snippet 2
from flask import Flask, request
# Init Flask App
app = Flask(__name__)
@app.route('/')
def hello():
return "Welcome to Mantium WhatsApp Bot"
@bleso-a
bleso-a / app.py
Last active July 19, 2022 16:06
Tutorial Snippet 3
from flask import Flask, request
SLEEP_TIME = 5
PROMPT_ID = "98b58a5d-12ff-4e64-868e-4dabf986eac7"
# Init Flask App
app = Flask(__name__)
@app.route('/')
def hello():
@bleso-a
bleso-a / app.py
Last active July 19, 2022 16:07
Full code
import os
import time
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
from dotenv import load_dotenv
import threading, time, random
# load Mantium credentials
load_dotenv()
@bleso-a
bleso-a / app.py
Last active August 26, 2022 16:16
Import Libraries
import json
import boto3
import sagemaker
from sagemaker import get_execution_role
from sagemaker.s3 import S3Uploader, S3Downloader
region = boto3.Session().region_name
role = get_execution_role()
bucket = sagemaker.Session().default_bucket()
prefix = "phi-masking"
bucket_path = "https://s3-{}.amazonaws.com/{}".format(region, bucket)
endpoint_url = "https://textract.{}.amazonaws.com".format(region)
textract_client = boto3.client(service_name = 'textract', region_name = region,
endpoint_url = endpoint_url)
@bleso-a
bleso-a / app_image.py
Last active September 12, 2022 17:16
documentName = "health_notes.png"
with open(documentName, 'rb') as file:
img_file = file.read()
bytes_arr = bytearray(img_file)
print('Image file is loaded', documentName)
file.close()
response = textract_client.detect_document_text(Document={'Bytes': bytes_arr})
print(response)