Skip to content

Instantly share code, notes, and snippets.

View kylefelipe's full-sized avatar
😀

Kyle Felipe kylefelipe

😀
View GitHub Profile
CREATE SCHEMA IF NOT EXISTS public;
DROP TABLE IF EXISTS public.cep_para_todos_pilotos_sp;
CREATE TABLE public.cep_para_todos_pilotos_sp (
logradouro TEXT,
localidade TEXT,
bairro TEXT,
cep TEXT,
geom geometry(MultiLineString, 4326)
);
INSERT INTO public.cep_para_todos_pilotos_sp VALUES
CREATE SCHEMA IF NOT EXISTS public;
DROP TABLE IF EXISTS public.cep_para_todos_pilotos_sp;
CREATE TABLE public.cep_para_todos_pilotos_sp (
logradouro TEXT,
localidade TEXT,
bairro TEXT,
cep TEXT,
geom geometry(MultiPolygon, 4326)
);
INSERT INTO public.cep_para_todos_pilotos_sp VALUES
@kylefelipe
kylefelipe / Dockerfile
Last active August 15, 2024 14:55
Docker + Coolify
FROM python:3.11
WORKDIR /app
COPY ./requirements.txt /app
RUN apt-get update -y
RUN apt-get install -qqy python3-pip libgdal-dev gdal-bin postgresql-client nano
RUN apt-get clean
@kylefelipe
kylefelipe / script.py
Last active July 9, 2024 13:46
Qgis crash when run script
import os
import sys
from qgis.core import (
QgsApplication,
QgsProject,
QgsCoordinateReferenceSystem,
QgsProcessingContext,
QgsProcessingAlgorithm,
)
@kylefelipe
kylefelipe / Installation.md
Last active February 14, 2024 17:18
Instalando XDEBUG no ubuntu - XAMPP (LAMPP)
@kylefelipe
kylefelipe / README.md
Created May 2, 2023 20:10
Renomeando camadas em um geopackage

Renomear várias camadas em um geopackage

SELECT 
'ALTER TABLE '|| table_name || ' RENAME TO ''' || replace(table_name, '2021', '2020') ||''';'
FROM gpkg_geometry_columns
WHERE table_name like '%2021';

Esse SQL vai buscar os nomes das tabelas em gpkg_geometry_columns e criar o sql de renomeação para cada uma das tabelas que passarem no WHERE.

@kylefelipe
kylefelipe / Expressao_qgis.sql
Created January 26, 2023 21:06
Pega Nome da camada dinamicamente -- QGIS
with_variable('lyr_name', -- variável que vai pegar o nome do estado
aggregate(
layer:='lim_unidade_federacao_a', -- nome da camda do estado
aggregate:='min',
expression:="sigla", -- campo que quer usar para gerar o nome da camada
filter:=contains($geometry, geometry(@parent))
),
with_variable('lyrmaps', -- vai receber o nome de todas as camadas no projeto
array_foreach(@layers, layer_property(@element, 'name')), --pega o nome de todas as camadas do projeto em uma lista
with_variable('lyrpos', array_find(@lyrmaps, upper(@lyr_name)), -- lirpos procura o nome da camada na lista e retorna a posicao, se nao encontrar retorna -1
@kylefelipe
kylefelipe / README.md
Created January 20, 2023 18:41
Script sh não salva os prints do arquivo python quando é executado pelo crontab

O agendamento do crontab está da seguinte forma

*/15 * * * * cd /root/pasta_script;  ./script.sh --cron

o script sh tem permissão para execução.....

Quando executo o arquivo .sh manualmente, o arquivo de log recebe todos os prints que o arquivo python gera, quando o script é executado

@kylefelipe
kylefelipe / validate.js
Last active July 6, 2022 23:01
Valida aberturas e fechamentos de colchetes em uma string
// adaptado de https://github.com/tryber/sd-05-live-lectures/blob/39.1/expressoes.py
const MATCHES = {
'}': '{',
']': '[',
')': '(',
'"': '"',
"'": "'",
"`": "`",
"```": "```"
};
@kylefelipe
kylefelipe / SELECTION.sql
Last active June 14, 2022 19:20
Selecting features from table A using table B
-- Expression to be used at SELECT BY EXPRESSION AT LAYER A
array_contains( -- This will return true if the array contains the value
aggregate( -- will aggregate all values from target in to a string, using semicolons as concatenator
layer:='<table_b>', -- Target table containing the values, replace <table_b> whith your table name
aggregate:='array_agg',
expression:=to_string("<field_from_table_b>"), -- Field from table_b containing the values
),
"<field_table_a>") -- Field from table a with values to compare, replace <field_table_a> with your field name