Skip to content

Instantly share code, notes, and snippets.

@ivanlonel
ivanlonel / Create-Portable-QGIS.ps1
Last active July 27, 2026 16:36
Downloads (or uses a local) QGIS MSI installer and creates a portable QGIS archive.
#Requires -Version 6.0
<#
.SYNOPSIS
Downloads (or uses a local) QGIS MSI installer and creates a portable QGIS archive.
.DESCRIPTION
Two modes of operation:
-QgisVersion (default)
Queries https://download.osgeo.org/qgis/windows/ for the highest matching
@ivanlonel
ivanlonel / pokemon_zone_csv_downloader.user.js
Last active October 10, 2025 20:48
Pokemon Zone Card Collection CSV Downloader
// ==UserScript==
// @name Pokemon Zone Card Collection CSV Downloader
// @namespace http://tampermonkey.net/
// @version 1.1
// @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 1, 2026 06:06
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/m-oWZnKN
-- 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),
@ivanlonel
ivanlonel / geohash12_int8.sql
Last active April 23, 2026 20:32
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/UzF6gQzu
-- 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 1, 2026 06:00
Returns a grid of all rectangles represented by geohashes of a given length that intersect a given geometry
-- https://dbfiddle.uk/n5dn_Rbj
CREATE OR REPLACE FUNCTION geohash_grid(
original_geometry geometry,
geohash_precision 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(polygon))
LANGUAGE SQL
@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())