Skip to content

Instantly share code, notes, and snippets.

@giohappy
giohappy / gist:8a30f14678aa7e446f9b694c632d7089
Last active March 7, 2024 15:47
QGIS Python plugin debuggin with VS Code on Windows

A debugpy version inspired by this gist: https://gist.github.com/NicolaiMogensen/acfd8723720c4761aefef3cdfc2aa55a

Debugging QGIS 3.x python plugins on Windows 11 using VS Code

Setting up VS Code

NOTE: I'm using VS Code Python extension version 2022.20.2, which has PyLance as language server. The most recent versions of the extension use debugpy debugger.

Start VS Code

For simplicity I start VS Code directly from the plugin folder.

@giohappy
giohappy / gwc_layer_config.py
Last active July 5, 2022 13:42
Configure GWC caching for all Geoserver layers
import requests
import json
REQ_TEMPLATE = '''<?xml version="1.0" encoding="UTF-8"?>
<GeoServerLayer>
<enabled>true</enabled>
<inMemoryCached>true</inMemoryCached>
<name>{}</name>
<metaWidthHeight>
<int>2</int>
@giohappy
giohappy / deploy-geoserver
Created June 21, 2021 20:05
Install GeoServer on cloud server with Ubuntu 20.04
# Install GeoServer on cloud server
________________
## 1. Install Java JDK
apt install openjdk-11-jdk
You can check the installation using `$ java -version`. Now you can see something like this:
openjdk version "11.0.7" 2020-04-14
@giohappy
giohappy / export_env_file.sh
Last active June 7, 2021 11:23
Export env file bash script
#source ./export_env_file.sh ./.env
set -o allexport
. $1
set +o allexport
@giohappy
giohappy / tmux.cheat
Created April 24, 2018 17:50 — forked from afair/tmux.cheat
Tmux Quick Reference & Cheat sheet - 2 column format for less scrolling!
========================================== ==========================================
TMUX COMMAND WINDOW (TAB)
========================================== ==========================================
List tmux ls List ^b w
New -s <session> Create ^b c
Attach att -t <session> Rename ^b , <name>
Rename rename-session -t <old> <new> Last ^b l (lower-L)
Kill kill-session -t <session> Close ^b &

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

# data test for PostGIS BRIN Indexes
# a small dataset ( ~400K rows for roads)
wget http://download.geofabrik.de/europe/france/bretagne-latest.shp.zip
unzip bretagne-latest.shp.zip
shp2pgsql -s 4326:2154 -I landuse.shp landuse | psql -h localhost -p 32770 -U pggis -d pggis
shp2pgsql -s 4326:2154 -I natural.shp natural | psql -h localhost -p 32770 -U pggis -d pggis
shp2pgsql -s 4326:2154 -I places.shp places | psql -h localhost -p 32770 -U pggis -d pggis
shp2pgsql -s 4326:2154 -I points.shp points | psql -h localhost -p 32770 -U pggis -d pggis
@giohappy
giohappy / mvt.html
Last active October 23, 2017 10:08
Flask + OL MVT vector layer
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>MVT</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/ol.css') }}">
</head>
<body>
<div id="map"class="map"></div>
<script src="{{ url_for('static', filename='js/ol-debug.js') }}"></script>
@giohappy
giohappy / flask_mvt.py
Last active November 18, 2022 12:11
OL + Flask + PostGIS for MVT rendering
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import shutil
import math
import psycopg2
from flask import Flask, render_template, make_response
app = Flask(__name__)
@giohappy
giohappy / mvt.py
Created October 20, 2017 16:11
MVT Django view snippet
import os
import shutil
import logging
import psycopg2
from django.conf import settings
from django.shortcuts import render, render_to_response
from django.http import HttpResponse
import mercantile as mc