Skip to content

Instantly share code, notes, and snippets.

View slarosa's full-sized avatar
🏠
Working from home

Salvatore Larosa slarosa

🏠
Working from home
  • Rende, Calabria (Italy)
View GitHub Profile
import eumdac
import time
import fnmatch
import shutil
import datetime
# Authentication
consumer_key = '<consumer_key>'
consumer_secret = '<consumer_secret>'
credentials = (consumer_key, consumer_secret)
@slarosa
slarosa / qgis_is_rock.diff
Last active November 11, 2017 18:54
An audio joke.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3401123e8..fe09479d7f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -303,6 +303,8 @@ IF(WITH_CORE)
FIND_PACKAGE(Qt5UiTools REQUIRED)
FIND_PACKAGE(Qt5Script REQUIRED)
FIND_PACKAGE(Qt5Sql REQUIRED)
+ FIND_PACKAGE(Qt5Multimedia REQUIRED)
+ FIND_PACKAGE(Qt5MultimediaWidgets REQUIRED)
@slarosa
slarosa / ABC.sql
Last active October 24, 2017 10:29
CREATE TABLE A1 AS
SELECT * FROM A WHERE comune = 'Y';
CREATE TABLE B1 AS
SELECT *, ST_Intersection(b.geom,
ST_Buffer(
(SELECT geom FROM A WHERE comune = 'Y'),
X)) as geom1 FROM B as b;
CREATE TABLE C1 AS
@slarosa
slarosa / action_show_blob_image.py
Last active July 10, 2019 17:20
Action for QGIS to show a stored image in a sqlite db
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtGui import QLabel, QImage, QPixmap
from qgis.utils import iface
import sqlite3
UNIQUE_FIELD = "unique_field_name"
BLOB_FIELD = "picture_field_name"
FIELD_VALUE = '[%unique_field_name%]'
vl = iface.activeLayer()
'''
QGIS Action to select and zoom the feature from related table
when one of field pairs is string. Using LIKE in QgsExpression.
Ref: https://lists.osgeo.org/pipermail/qgis-it-user/2017-April/002413.html
'''
from qgis.utils import iface
# inserire qui il nome del layer geometrico
'''
QGIS macro to enable selection on referenced geometry layer from
referencing geometryless table in a Project with Relations.
How it works:
1. Enable macros for the QGIS Project
2. Paste this code in Project->Macro
3. Save the Project.
Note: The QGIS project must have relationship between tables.
#!/usr/bin/env python
# -*- coding:utf-8 -*-
from PyQt4.QtCore import QFileInfo
import dropbox
import tempfile
import glob
import os
import datetime
library(leaflet)
library(rgdal)
# Lo shapefile usato in questo esempio è liberamente scaricabile
# dal link http://bit.ly/2e9dyZf
setwd('/Users/slarosa/dev/r_leaflet')
datadir <- file.path(getwd(),"data")
basename <- "pai_2016_frane_wgs84"
shapefile <- file.path(datadir, paste(basename, ".shp", sep = ""))
protected function _autoCommitNotify ($state){
if (version_compare(pg_parameter_status($this->_connection, "server_version"),'7.4')<0) {
$this->_doExec('SET AUTOCOMMIT TO '.($state ? 'ON' : 'OFF'));
}
}
diff --git a/src/core/qgsvectorlayer.cpp b/src/core/qgsvectorlayer.cpp
index 65596c2..9f7468b 100644
--- a/src/core/qgsvectorlayer.cpp
+++ b/src/core/qgsvectorlayer.cpp
@@ -2965,8 +2965,8 @@ void QgsVectorLayer::removeExpressionField( int index )
{
int oi = mUpdatedFields.fieldOriginIndex( index );
mExpressionFieldBuffer->removeExpression( oi );
- updateFields();
emit attributeDeleted( index );