Skip to content

Instantly share code, notes, and snippets.

View kylefelipe's full-sized avatar
😀

Kyle Felipe kylefelipe

😀
View GitHub Profile
@kylefelipe
kylefelipe / municipiosEstados.js
Last active June 1, 2020 03:07
Populando `selects` com os nomes dos estados, e os municípios conforme o estado
// Preenche dois selects, um com os estados brasileiros e o outro com os municipios daquele estado
// conforme o estado vai mudando
// a `option` do estado tem o valor a sigla do estado, e o texto interno o nome do estado
// a `option'do município tem o valor o geocódgo (IBGE) do município e o texto o nome do município
// geocódigo é o código IBGE para a região demarcada por ele, como estados e municípios.
// Não estou usando geocódigo nos estados...
const estados = document.getElementById('id-do-select-do-estado');
const muncipiosDoEstado = document.getElementById('id-do-select-do-municipio');
function populaSelecao(opcoes, elemento) {
@kylefelipe
kylefelipe / trasnpoe_tabela.py
Created August 22, 2020 22:00
Faz transposição de dados usando como coluna os valores no segundo campo da da camada e o terceiro como valores. A camada a ser transposta precisa estar ativa no painel de camadas.
"""
Faz transposição de dados usando como coluna os valores no segundo campo da
da camada e o terceiro como valores.
A camada a ser transposta precisa estar ativa no painel de camadas.
"""
from copy import copy
from qgis.PyQt.QtCore import QVariant
@kylefelipe
kylefelipe / imporKmz.py
Created September 10, 2020 03:36
Import all KMZ files from a directory to qgis project
import os, sys, shutil
from qgis.PyQt.QtWidgets import QFileDialog
getFolder = QFileDialog().getExistingDirectory()
arquivos = []
def renameFile(filePath, newFileName):
"""Funcao que renomeia o arquivo extraido"""
newName = f"{filePath}{os.sep}{newFileName.split('.')[0]}.kml"
#include <SerialDisplay.h>
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
char ssid[] = "NOME_DA_REDE"; // sua rede wifi
char password[] = "SENHA_DA_REDE"; // sua senha
char channelId[] = "ID_DO_CANAL"; // ID do seu canal
char apiKey[] = "CHAVE_DA_API"; // chave da API
SerialDisplay displays(14, 12, 10); // (data D5, clock D6, qtde de modulos)
WiFiClientSecure client;
@kylefelipe
kylefelipe / a_sequelize_issue.md
Last active May 7, 2021 21:15
Sequelize issue about N:N relations

Here is my issue:
I wish to delete all rows at row-group-view if i delete a group from group or if i delete a view from view.

@kylefelipe
kylefelipe / rename_imgs.py
Last active September 16, 2021 22:18
This script rename files using a csv list that contains img_Id, file_name, new_name, receiving_folder it will create all new folders needed to paste the copies And paste them inside the receiving_folder
# This script rename files using a csv list that contains
# img_Id, file_name, new_name, receiving_folder
# it will create all new folders needed to paste the copies
# And paste them inside the receiving_folder
# Created by Kyle Felipe
# kylefelipe at gmail.com
import os
import csv
from shutil import copy2 as copy
@kylefelipe
kylefelipe / README.md
Last active October 20, 2021 18:28
GeoServer - extension issue - gs-querylayer

This is a issue using cross-layer filter provided by querylayer extension

Layers

LayerA - intersection_geom -> GEOMETRY, layer geometry;
LayerB - cd_bioma -> INTEGER, biome code; geom -> GEOMETRY, layer geometry;

CQL_Filter

intersects(intersection_geom, querySingle(layerB, 'geom', 'cd_bioma=1'))

@kylefelipe
kylefelipe / README.md
Last active October 25, 2021 22:47
Criando uma camada virtual a partir de uma query SQL usando PyQGIS

SQL + Virtual Layers + PyQGIS

# Estados que queremos pegar os municípios
nomes = ['Minas Gerais', 'Paraíba', 'Espírito Santo', 'Goiás', 'Sergipe']
nomes = [f"'{nome}'" for nome in nomes]

# Pegando apenas as feições que precisamos 
estados = QgsProject.instance().mapLayersByName('lim_unidade_federacao_a')[0]
subset_string = f"nome in ({','.join(nomes)})"
@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
@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 = {
'}': '{',
']': '[',
')': '(',
'"': '"',
"'": "'",
"`": "`",
"```": "```"
};