Skip to content

Instantly share code, notes, and snippets.

View johnidm's full-sized avatar

Johni Douglas Marangon johnidm

View GitHub Profile
@johnidm
johnidm / readme.md
Last active March 2, 2025 12:26
NeoVim - Steroids
@johnidm
johnidm / readme.md
Last active May 11, 2025 00:33
RH Interview Questions

Interview question

Where are you based?

I'm currently based in São Miguel do Oeste, my hometown, which is located in the south of Brazil. I have been working remotely since the pandemic.

Are you currently employed?

Yes, I am currently employed at Softplan as a Senior Backend Engineer focusing on developing solutions using AI.

@johnidm
johnidm / readme.md
Last active February 5, 2025 13:18
PHP - Using Google Cloud Vision AI

Using Google Cloud Vision AI to perform OCR tasks in PHP

Install the dependence: composer require google/cloud-vision.

You may need to install the OS dependency: sudo apt install php-bcmath.

Using offical PHP Google Cloud Vision library
<?php
@johnidm
johnidm / readme.md
Created January 29, 2025 13:49
PHP - Parsing PDF to Txt

How to parse a PDF file to txt.

Install the dependence: composer require smalot/pdfparser.

Run the following code:

<?php
require __DIR__ . '/vendor/autoload.php';
@johnidm
johnidm / readme.md
Last active January 17, 2025 19:15
Surya and docTR: Powerful OCR Toolkits for Document Processing

Surya and docTR: Powerful OCR Toolkits for Document Processing

Surya is a Python-based document OCR toolkit designed for flexibility and ease of use in processing and extracting text from scanned documents. Developed as a lightweight and customizable solution, it allows developers to work with OCR tasks seamlessly, making it a great choice for building tailored document processing workflows. Surya supports multiple OCR engines and focuses on accessibility for diverse use cases. GitHub

from PIL import Image
from surya.ocr import run_ocr
from surya.model.detection.model import load_model as load_det_model, load_processor as load_det_processor
from surya.model.recognition.model import load_model as load_rec_model
from surya.model.recognition.processor import load_processor as load_rec_processor
@johnidm
johnidm / readme.md
Last active December 11, 2024 13:15
Example How to Use Structured Outputs - OpenAI

This code demonstrates a structured approach to querying OpenAI models and handling the response, making it easier to integrate advanced use cases like math tutoring into applications.

Defining Data Models:

  • Step: Represents an individual step in the solution process. Each step contains:
    • explanation: A description of what is happening in this step.
    • output: The result or equation at this stage.
  • MathResponse: Represents the full structured response. It contains:
    • steps: A list of Step objects, representing the solution's breakdown.
    • final_answer: The final solution to the problem.
@johnidm
johnidm / readme.md
Created November 2, 2024 16:46
Explore OpenAI Assistant in Python - While True to Run a Conversation

A variant of the ongoing conversation employs the while true strategy, utilizing an infinite loop to sustain the dialogue.

def run_conversation(message: str, thread_id, assistant_id):
    message = client.beta.threads.messages.create(
        thread_id=thread_id,
        role="user",
        content=message,
    )
@johnidm
johnidm / readme.md
Created October 5, 2024 18:29
OpenAI - Calculating Token Counts and Estimating Costs

Utilize this code to quickly estimate processing costs for your dataset with OpenAI.

dataset.csv

text
Music is a universal language that connects people across cultures.
Listening to music can improve your mood and reduce stress.
Classical music has a rich history and deeply influences modern genres.
Jazz is known for its improvisational style and complex harmonies.
@johnidm
johnidm / readme.md
Last active July 27, 2025 01:13
Basic Real-Time Applications with WebSockets and FastAPI

Install dependencies - pip install fastapi 'uvicorn[standard]'

Run the example - uvicorn main:app --host 0.0.0.0 --port 8000

Access multiple pages from http://localhost:8000/ and send messages

Source code files

main.py

@johnidm
johnidm / readme.md
Created July 31, 2024 17:24
Securing Application with API Key Authentication
from fastapi.security import APIKeyHeader
from fastapi import Security, HTTPException, status
from fastapi import APIRouter, FastAPI, Depends
import sqlite3


print(sqlite3.sqlite_version)