Skip to content

Instantly share code, notes, and snippets.

View deistermatheus's full-sized avatar

Matheus Deister deistermatheus

  • Vinta Software
  • Remote, Brazil
View GitHub Profile
@deistermatheus
deistermatheus / parser_snippet.py
Last active February 17, 2025 14:47
GS Parse
client = openai.OpenAI(api_key=token)
# Define a Pydantic model for the extracted data part (the inner dictionary)
class ExtractedData(BaseModel):
root: Dict[str, str]
@field_validator('root')
def validate_keys(cls, field):
for k in field.keys():
if not (len(k) <= 2 and k.isdigit()):
@deistermatheus
deistermatheus / edit.py
Created January 24, 2025 17:54
batch edit files with openai
import os
import glob
import openai
# Configure your OpenAI API key
openai.api_key = OPENAI_API_KEY
# Define your prompt for editing
PROMPT_TEMPLATE = """
TASK: Edit the following Python Django models.py file by adding Meta class configurations for sensitive fields.
@deistermatheus
deistermatheus / diffwriter.sh
Created August 12, 2024 22:35
ChatGPT Diff description for PRs
#!/bin/bash
MAIN_BRANCH="master"
changed_files=$(git diff --name-only $MAIN_BRANCH)
markdown_summary="# Diff Summary\n\n"
for file in $changed_files; do
file_diff=$(git diff $MAIN_BRANCH -- "$file")
@deistermatheus
deistermatheus / s3fs_wrapper.py
Created October 5, 2023 18:43
Wrap Local Functions to Read from S3 as a File System
import s3fs
import os
AWS_ACCESS_KEY_ID=os.getenv('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY=os.getenv('AWS_SECRET_ACCESS_KEY')
BUCKET_ROOT = os.getenv('BUCKET_ROOT')
fs = s3fs.S3FileSystem(key=AWS_ACCESS_KEY_ID, secret=AWS_SECRET_ACCESS_KEY)
def load_from_s3(target_function, s3_path, *args, **kwargs):
@deistermatheus
deistermatheus / balanca.js
Created May 5, 2021 21:50
Mock de integração balanças
const fs = require('fs');
const ANSI_OUTPUT = fs.readFileSync('./data/Saidaimpressora_ansi_01.txt');
const LINE_DELIMITER = "\r\n";
const READING_DELIMITER = '\x00--------------------';
const REGEXP_TIMESTAMP = /[0-9]{2}\/[0-9]{2}\/[0-9]{4}\s{1,}[0-9]{2}\:[0-9]{2}\:[0-9]{2}/gi
const REGEXP_WEIGHT = /p\.liq/gi
const REGEXP_WEIGHT_MEASUREMENT = /[0-9]{1,}\.[0-9]{1,}.[a-z]{1}/gi
const REGEXP_MODEL = /modelo/gi
const fs = require('fs');
const ANSI_OUTPUT = fs.readFileSync('./data/Saidaimpressora_ansi_01.txt');
const LINE_DELIMITER = "\r\n";
const READING_DELIMITER = '\x00--------------------';
const REGEXP_TIMESTAMP = /[0-9]{2}\/[0-9]{2}\/[0-9]{4}\s{1,}[0-9]{2}\:[0-9]{2}\:[0-9]{2}/gi
const REGEXP_WEIGHT = /p\.liq/gi
const REGEXP_WEIGHT_MEASUREMENT = /[0-9]{1,}\.[0-9]{1,}.[a-z]{1}/gi
const REGEXP_MODEL = /modelo/gi
[user]
name = Matheus Deister
email = deistermatheus@gmail.com
[alias]
# checkouts
co = checkout
cb = checkout -b # to new named branch
cm = checkout master
cmp = !git checkout master && git pull
@deistermatheus
deistermatheus / mongodb-facet-combine.js
Created August 13, 2020 20:28 — forked from cthurston/mongodb-facet-combine.js
MongoDb combine $facet results into a single result set.
db.getCollection('list').aggregate([
{
$facet: {
"events":[{
$match: {
'type': 'Event'
}
}],
"tasks": [{
$match: {
/**
* Função de renderização condicional que envolve um elemento JSX e retorna
* um AlertDialog informando que não é possível realizar a ação. Se for passado
* um elemento composto (ex: ConfirmationDialog(Button)), retorna o elemento interno
* envolvido por um AlertDialog.
* @param {JSX.Element} renderedComponent - Elemento JSX renderizado que deve ser desabilitado pelo Dialog.
* @param {Object} AlertDialogProps - {@link https://github.com/assisrafael/react-bootstrap-utils/blob/master/src/dialog/AlertDialog.jsx react-bootstrap-utils/AlertDialog }
* @returns {JSX.Element} - componente envolvido por um Alert Dialog
*/
const somenteLeitura = function(Component, AlertDialogProps = {
@deistermatheus
deistermatheus / spiralWalkMatrix.js
Last active July 23, 2020 21:21
Overengineered ES6+ practice for spiral matrix problem
/**
* Spiral Walk over a matrix.
* @param {Array[] | Array} matrix
* @param {Boolean} values - defaults to false. Returns an ordered array of {x,y} coordinates or the values in the matrix.
*/
function spiralMatrix(matrix, values = false) {
const { rows, columns } = getMatrixDimensions(matrix);
if (!columns) {
return matrix;