Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Szieberth Ádám SzieberthAdam

🏠
Working from home
View GitHub Profile
View gist:ee2e7b43ac20e0df903085f1f99b2234
/*******************************************************************************************
*
* raylib [core] example - fullscreen toggle
*
* Welcome to raylib!
*
* To test examples, just press F6 and execute raylib_compile_execute script
* Note that compiled executable is placed in the same folder as .c file
*
* You can find all basic examples on C:\raylib\raylib\examples folder or
@SzieberthAdam
SzieberthAdam / costrua_decompress.py
Created February 25, 2018 06:49
Decompresses a Costrua Resource ZIP file saved by ILSpy
View costrua_decompress.py
import sys
import zlib
if __name__ == '__main__':
if len(sys.argv) != 3:
print('USAGE: python costura_decompress.py '
'<IN_FILE> <OUT_FILE>')
sys.exit()
in_filename = sys.argv[1]
out_filename = sys.argv[2]
@SzieberthAdam
SzieberthAdam / st_extend.sql
Created January 29, 2018 08:37
PostGIS function to extend a linestring
View st_extend.sql
CREATE OR REPLACE FUNCTION st_extend (
geom geometry,
head_rate double precision,
head_constant double precision,
tail_rate double precision,
tail_constant double precision)
RETURNS geometry AS
$BODY$
-- Extends a linestring.
-- First segment get extended by length * head_rate + head_constant.
@SzieberthAdam
SzieberthAdam / vispres.py
Last active May 31, 2021 15:34
Python QGIS (PyQGIS) visibility preset manipulation functions
View vispres.py
def activate_visibility_preset(preset_name, *, project=None, coll=None):
"""Activates a visibility preset by its name.
Return a boolean indicating success."""
# https://github.com/qgis/QGIS/blob/f044c95fd8927d86967ce8af3930bdc7523095fa/src/app/qgsmapthemes.cpp#L138
if project is None:
project = qgis.core.QgsProject.instance()
if coll is None:
coll = project.mapThemeCollection()
if not coll.hasMapTheme(preset_name):
return False
@SzieberthAdam
SzieberthAdam / qgis_custom_label_autocentroid.txt
Created January 19, 2016 14:30
QGIS: Label to centroid when position is not explicitely set
View qgis_custom_label_autocentroid.txt
# It is assumed that the layer has both "labelX" and a "labelY" attributes set as real number fields.
# Labels / Placement / Data Defined / Coordinate / X:
CASE WHEN "labelX" IS NULL THEN toreal(regexp_substr(geom_to_wkt(centroid($geometry)), '(-?\\d+\\.?\\d*) -?\\d+\\.?\\d*')) ELSE "labelX" END
# Labels / Placement / Data Defined / Coordinate / Y:
CASE WHEN "labelY" IS NULL THEN toreal(regexp_substr(geom_to_wkt(centroid($geometry)), '-?\\d+\\.?\\d* (-?\\d+\\.?\\d*)')) ELSE "labelY" END
# Labels / Placement / Data Defined / Alignment / horizontal:
'Center'
@SzieberthAdam
SzieberthAdam / pyqgis_crs.py
Last active January 19, 2016 10:45
PyQGIS: CRS (Coordinate Reference System / Projection)
View pyqgis_crs.py
# project
project_crs = qgis.utils.iface.mapCanvas().mapRenderer().destinationCrs()
qgis.utils.iface.mapCanvas().mapRenderer().setDestinationCrs(new_project_crs)
@SzieberthAdam
SzieberthAdam / pyqgis_layerfields.py
Last active January 19, 2016 10:44
PyQGIS: Get fields of layer
View pyqgis_layerfields.py
# QgsFields() of QgsVectorLayer()
# fields = layer.fields() # from QGIS 1.12+
fields = layer.pendingFields() # and below...
# list QgsField() from QgsFields()
fieldlist = fields.toList()
# list of layer fieldnames
[f.name() for f in fieldlist]
@SzieberthAdam
SzieberthAdam / pyqgis_selectedlayers.py
Last active January 19, 2016 10:44
PyQGIS: Get all selected layers
View pyqgis_selectedlayers.py
iface.legendInterface().selectedLayers()