Skip to content

Instantly share code, notes, and snippets.

@ivanlonel
ivanlonel / pokemon_zone_csv_downloader.user.js
Created June 27, 2025 22:46
Pokemon Zone Card Collection CSV Downloader
// ==UserScript==
// @name Pokemon Zone Card Collection CSV Downloader
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Download Pokemon card collection data as CSV from Pokemon Zone
// @author Ivan Donisete Lonel
// @match https://www.pokemon-zone.com/players/*/cards/
// @grant none
// ==/UserScript==
@ivanlonel
ivanlonel / pyqgis_standalone_processing.py
Created June 8, 2024 00:33
How to run Processing algorithms in standalone PyQGIS applications
import sys
from pathlib import Path
from qgis.core import QgsApplication
from qgis.core.contextmanagers import qgisapp
with qgisapp(guienabled=False, sysexit=False):
# Required before importing processing:
sys.path.append(str(Path(QgsApplication.prefixPath()) / "python/plugins"))
@ivanlonel
ivanlonel / pluscode_grid.sql
Last active May 22, 2025 00:20
Given a geometry and a plus code length (2, 4, 6, 8, 10, 11, 12, 13, 14, or 15), returns a grid of all rectangles represented by plus codes of that length that intersect the geometry.
-- https://dbfiddle.uk/3CgLervE
-- This uses function pluscode_decode, implemented here:
-- https://github.com/google/open-location-code/blob/main/plpgsql/pluscode_functions.sql
CREATE OR REPLACE FUNCTION pluscode_grid(original_geometry geometry, pluscode_length integer)
-- Given a geometry and a plus code length (2, 4, 6, 8, 10, 11, 12, 13, 14, or 15), returns a
-- grid of all rectangles represented by plus codes of that length that intersect the geometry.
RETURNS TABLE (pluscode text, geom geometry)
LANGUAGE SQL
@ivanlonel
ivanlonel / geohash12_int8.sql
Last active June 26, 2025 21:00
Converts geohash between text and integer formats in Postgres
-- Converts geohash (up to 12 characters) between text and bigint formats in Postgres
-- https://dbfiddle.uk/YNXSfa3r
-- The geohash length is stored in the 4 least significant bits,
-- so that the relative order of the resulting int8 is the same
-- as that of the the original text string:
-- gzzzzzzzzzzz < h < h0 < h00 < h01 < h1
-- -4 < 1 < 2 < 3 < 562949953421315 < 18014398509481986
@ivanlonel
ivanlonel / geohash_grid.sql
Last active May 22, 2025 00:15
Returns a grid of all rectangles represented by geohashes of a given length that intersect a given geometry
-- https://dbfiddle.uk/3tf4mT2H
CREATE OR REPLACE FUNCTION geohash_grid(original_geometry geometry, geohash_length integer)
-- Given a geometry and a geohash length, returns a grid of all rectangles
-- represented by geohashes of that length that intersect the geometry.
RETURNS TABLE (geohash text, geom geometry)
LANGUAGE SQL
IMMUTABLE
STRICT
PARALLEL SAFE
@ivanlonel
ivanlonel / decrypt_dbeaver.py
Last active April 20, 2023 17:23 — forked from felipou/decrypt_dbeaver.py
DBeaver password decryption script - for newer versions of DBeaver
# https://stackoverflow.com/questions/39928401/recover-db-password-stored-in-my-dbeaver-connection
# requires pycryptodome lib (pip install pycryptodome)
import argparse
import contextlib
import os
import json
from Crypto.Cipher import AES
@ivanlonel
ivanlonel / pgd.user.js
Last active April 11, 2023 21:51
Preencher Acompanhamento das Atividades - PGD
// ==UserScript==
// @name Preencher Acompanhamento das Atividades - PGD
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Preenche automaticamente os campos "Status", "Início", "Fim" e "Tempo gasto para realizar a atividade" da página de acompanhamento das atividades do PGD
// @author ChatGPT
// @match http://w3.programagestao.sda.ibge.gov.br/SDA-ProgramaGestao/planoTrabalho.jsf
// @icon https://www.google.com/s2/favicons?sz=64&domain=gov.br
// @grant none
// ==/UserScript==
@ivanlonel
ivanlonel / Tutorial_LabelImg.md
Last active March 14, 2022 13:00
Como utilizar LabelImg para criar anotações de imagens no formato YOLO

Utilizando LabelImg para criar anotações de imagens no formato Darknet/YOLO

LabelImg é uma ferramenta de anotação de imagens desenvolvida em Python com interface gráfica baseada em Qt.

As anotações podem ser salvas em três diferentes formatos:

Demonstração

@ivanlonel
ivanlonel / shortest_common_supersequence.py
Created March 24, 2021 02:14
Shortest Common Supersequence and Longest Common Subsequence generator functions
from __future__ import annotations
from typing import Any
from collections.abc import Iterable, Iterator
import difflib
import itertools
def longest_common_subsequence(seq1: Iterable[Any], seq2: Iterable[Any]) -> Iterator[Any]:
a = list(seq1)
b = list(seq2)
lcs = (a[block.a:(block.a + block.size)] for block in difflib.SequenceMatcher(None, a, b).get_matching_blocks())
@ivanlonel
ivanlonel / logging_queue.py
Last active April 1, 2021 02:24
Configure a QueueHandler and a QueueListener for logging withoug blocking asyncio coroutines. Based on Martijn Pieters' blog post: https://www.zopatista.com/python/2019/05/11/asyncio-logging/
import queue
import asyncio
import logging
from logging.handlers import QueueHandler, QueueListener
from contextlib import contextmanager
class LocalQueueHandler(QueueHandler):
def emit(self, record: logging.LogRecord) -> None:
# There is no need to self.prepare() records that go into a local, in-process queue.