Skip to content

Instantly share code, notes, and snippets.

View patrickelectric's full-sized avatar
🏡
Working from home

Patrick José Pereira patrickelectric

🏡
Working from home
View GitHub Profile
@patrickelectric
patrickelectric / agenda-ney.py
Created February 26, 2023 16:41
Scrap event from ney matogrosso website
import requests
import json
from bs4 import BeautifulSoup
url = 'https://neymatogrosso.com.br/agenda/'
headers = {
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0"
}
@patrickelectric
patrickelectric / multiple-components.py
Last active April 19, 2024 19:17
Example of using asyncio to run multiple mavlink components
import asyncio
from pymavlink import mavutil
PORT = 6666
CONNECTION_STRING = f'udpout:127.0.0.1:{PORT}'
CONNECTIONS = {}
def get_mavlink_connection(system_id: int, component_id: int):
def create(system_id: int, component_id: int):
return mavutil.mavlink_connection(
@patrickelectric
patrickelectric / pub-sub-ros.md
Last active July 25, 2022 21:56
My personal investigation on the pub/sub frameworks around the world!

ROS

Long and love-rate (more rate than love) relationship, take mostly of this review with a grant of salt.

Great tools, libraries and projects

ROS (started in 2010) have some great tools visualize topics, send and debug messages, check frequencies, and much more. It's also possible to use more advanced tools and solutions like: rviz, gmapping, rtabmap, stereo_image_proc and the list goes on. With ROS, it's possible to take advantage of all drivers that exist for different pieces of hardware. Keep in mind that this is possible, but not easy, usually the drivers need specific configuration, custom settings and may give as output really complex data that needs to be processed or analyzed by another program.

Bureaucratic

ROS uses [catkin](https://github.com

@patrickelectric
patrickelectric / temporary_cache.py
Created April 18, 2022 17:29
Decorator that creates a cache for specific inputs with a configured timeout in seconds, useful for REST APIs
import time
from functools import wraps
from typing import Any, Callable, Dict
def temporary_cache(timeout_seconds: float = 10) -> Callable[[Callable[[Any], Any]], Any]:
"""Decorator that creates a cache for specific inputs with a configured timeout in seconds.
Args:
timeout_seconds (float, optional): Timeout to be used for cache invalidation. Defaults to 10.
@patrickelectric
patrickelectric / elefante.vue
Created May 3, 2021 18:43
Vue3 loader example
<template>
<span class="example">{{ msg }} - {{ potatoFunction() }}</span>
</template>
<script>
export default {
data () {
return {
msg: 'elefante!',
color: 'red',
}
@patrickelectric
patrickelectric / rtsp.py
Created April 20, 2021 15:58
rtsp factory python stream
import sys
import gi
sys.path.insert(0, "/usr/local/lib/python3.8/dist-packages")
print(sys.path)
#gi.require_version('Gst', '1.0')
from gi.repository import Gst, GstRtspServer, GObject
loop = GObject.MainLoop()
echo "potato, this's simple.sh!"
echo "Yes, 'it' is!"
{
"vehicles": [
{
"id": 1,
"components": [
{
"id": 1,
"messages": {
"RANGEFINDER": {
"type": "RANGEFINDER",
// https://steamcommunity.com/app/648800/discussions/0/1694922526906474288/
// https://www.saveeditonline.com/
Arrow_Stone - 186 - 0xba
Bow - 185 - 0xb9