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 / 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
#include <cstdint>
#include <cstdio>
namespace version_helper {
/**
* @brief Create the header sequence with checksum based in a string
*
* @tparam Type: Desired type of header
* @tparam N: Size of string
* @return Type: Header sequence created with checksum
@patrickelectric
patrickelectric / camera.xml
Created September 16, 2020 16:28
mavlink camera description file for QGC
<?xml version="1.0" encoding="UTF-8" ?>
<mavlinkcamera>
<definition version="1">
<model>HD Pro Webcam C920</model>
<vendor>HD Pro Webcam C920</vendor>
</definition>
<parameters>
<parameter name="camera-mode" type="uint32" default="1" control="0">
<description>Camera Mode</description>
<options>
@patrickelectric
patrickelectric / hunter_pylinter.sh
Created September 2, 2020 17:49
Find all pylint checks that are failing and print human friendly name for pylintrc
#!/usr/bin/env bash
keys=( $(pylint $(git ls-files '*.py') | rg '.*py:\d+:\d+: (.*):.*' -r '$1' | sort | uniq) )
msgs=( $(pylint --list-msgs | rg ":(.*) \(([A-Z]\d+)\).*" -r '$1,$2' | sort) )
for msg in "${msgs[@]}"; do
for key in "${keys[@]}"; do
if [[ $msg == *"$key" ]]; then
echo "${msg::-5}"
fi
done

+++ title = 'How to rock: Doing the right thing' date = 2020-08-31T13:55:39z draft = true [taxonomies] tags = [ "kde", "development", "tutorial", "how-to-rock" ] [extra] header = "/assets/how_to_rock/maintain.jpg" +++