Skip to content

Instantly share code, notes, and snippets.

View anselmobattisti's full-sized avatar
🇧🇷
Pátria Amada, Brasil!

Anselmo Luiz Éden Battisti anselmobattisti

🇧🇷
Pátria Amada, Brasil!
View GitHub Profile
# Sutton e Barto
# Example 3.5: Gridworld Figure 3.2 (left) shows a rectangular
# gridworld representation of a simple finite MDP. The cells
# of the grid correspond to the states of the environment.
# At each cell, four actions are possible: north, south,
# east, and west, which deterministically cause the agent to
# move one cell in the respective direction on the grid.
# Actions that would take the agent off the grid leave its
# location unchanged, but also result in a reward of −1.
# Other actions result in a reward of 0, except those that
@anselmobattisti
anselmobattisti / mochila.py
Created December 29, 2020 02:21
Implementação do problema das múltiplas mochilas em Python.
from mip import *
import random
# Constantes
RANDOM_SEED = 1
NUM_PRODUTOS = 10
NUM_MOCHILAS = 2
# Variável que armazena os Dados
produtos = {}
@anselmobattisti
anselmobattisti / extract_pages_from_pdf_and_remove_margim.sh
Created July 30, 2025 13:40
extract_pages_from_pdf_and_remove_margim.sh
#!/bin/bash
# Check if input file is provided
if [ -z "$1" ]; then
echo "Usage: $0 file.pdf [output_directory]"
exit 1
fi
PDF_FILE="$1"
BASENAME=$(basename "$PDF_FILE" .pdf)
@anselmobattisti
anselmobattisti / gstreamer_webcam_to_udp
Created September 7, 2019 16:02
Capture webcam video and stream it using gstreamer
Capture and send video
gst-launch-1.0 v4l2src device=/dev/video0 \
! decodebin \
! x264enc \
! rtph264pay \
! udpsink port=5000
Show the video
gst-launch-1.0 \
#!/usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf, OVSLink
from subprocess import call
@anselmobattisti
anselmobattisti / gstreamer pipeline
Created September 10, 2019 23:37
Grab video from webcam and stream it using udpsink via x264
Pipeline to send video (simulating SRC) get the data from video0
gst-launch-1.0 v4l2src device=/dev/video0 \
! decodebin \
! x264enc \
! rtph264pay \
! udpsink host=localhost port=5000
// if you are running it inside a docker container be aware of the host ip in udpsink
gst-launch-1.0 v4l2src device=/dev/video0 \
! decodebin \
# To run the latexdiff in a Docker environment
# 1 - Download the image
docker pull iphoneintosh/latex-docker:latest
# 2 - Run the latexdiff
docker run --rm -v .:/data iphoneintosh/latex-docker:latest latexdiff original.tex rev.tex > diff.tex
@anselmobattisti
anselmobattisti / side_by_side
Created October 4, 2019 21:37
Combine two videos and place than side by side gstreamer
gst-launch-1.0 \
videomixer name=m sink_1::xpos=50 sink_1::ypos=50 sink_2::xpos=400 sink_2::ypos=50 \
! x264enc \
! rtph264pay \
! udpsink host=localhost port=5000 \
videotestsrc pattern=white \
! video/x-raw, format=I420, framerate=5/1, width=740, height=480 \
! m. \
videotestsrc pattern=red \
! videobox left=100 \
@anselmobattisti
anselmobattisti / base64.sh
Created November 22, 2023 18:30
Send image api curl base64
# --wrap=0 will convert the base64 texto into only one line
curl -X POST -H "Content-Type: application/json" -d '{"image" : "'"$( base64 --wrap=0 ./imgs/knative.png)"'"}' http://127.0.0.1:8080
from collections import OrderedDict
msg = ""
positions = OrderedDict([
("Start_Bit", 2),
("Packet_Length", 1),
("Protocol_Number", 1),
("Location_Source_Type", 1),
("Terminal_ID", 8),