Skip to content

Instantly share code, notes, and snippets.

@pmav99
pmav99 / qgis_processing_api_example.py
Last active June 19, 2019 10:49
QGIS 3 + Processing + Python API example
import os
import pathlib
import sys
import typing
# The exact values of these paths depend on your QGIS installation
QGIS_ROOT = pathlib.Path("/opt/qgis-git")
QGIS_PATH = QGIS_ROOT / "share/qgis/python"
QGIS_PLUGIN_PATH = QGIS_PATH / "plugins"
@pmav99
pmav99 / timer.py
Created April 3, 2019 11:01
Python timer
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Just some classes that help benchmark execution speed.
Timer : A context manager
AutoTimer: A self-adjusting timer. It replicates the behavior of the timeit module.
"""
@pmav99
pmav99 / shell_script_tests.sh
Created March 29, 2019 11:55
GRASS GIS tests written as shell scripts
# https://github.com/sjl/friendly-find
$ ffind 'test.*sh\b'
./raster/r.timestamp/test_suite/test.r.timestamp.sh
./raster/r.series/test_suite/test.r.series.sh
./raster/r.to.rast3elev/test.r.to.rast3elev.sh
./raster/r.in.lidar/testsuite/test_base_resolution.sh
./raster/r.in.lidar/test/sample_test.sh
./raster/r.to.rast3/test_suite/test.r.to.rast3.sh
./raster/r.drain/tests/test.r.drain.sh
@pmav99
pmav99 / pytest_collect_only.txt
Created March 12, 2019 16:53
pytest grass collect only
pytest --collect-only
=============================================================================================== test session starts ===============================================================================================
platform linux -- Python 3.7.2, pytest-4.3.0, py-1.8.0, pluggy-0.9.0
rootdir: /home/feanor/Prog/svn/grass, inifile:
collected 1429 items
<Module db/db.columns/testsuite/test_dbcolumns.py>
<UnitTestCase TestDbColumns>
<TestCaseFunction test_dbcols>
<Function test>
<Module db/db.copy/testsuite/test_dbcopy.py>
@pmav99
pmav99 / geo_interface.rst
Last active March 8, 2019 00:32 — forked from sgillies/geo_interface.rst
A Python Protocol for Geospatial Data

Author: Sean Gillies Version: 1.0

Abstract

This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data.

Introduction

import argparse
def my_func(arg1, arg2, arg3=None):
print(arg1, type(arg1))
print(arg2, type(arg2))
print(arg3, type(arg3))
if arg3:
print("The boolean value of arg3 is <True>")
@pmav99
pmav99 / popen.md
Created January 29, 2019 23:27 — forked from achillesrasquinha/popen.md
A Python Popen that does not suck.

A Python Popen that does not suck.

Function

import os
import subprocess

def popen(*args, **kwargs):
    output      = kwargs.get('output', False)
    directory   = kwargs.get('dir')
@pmav99
pmav99 / python27.py
Last active November 19, 2018 13:41
Get the first unique character of a string. Python - single traversal solution
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from collections import OrderedDict
def find_index_of_first_unique_char(string):
seen_once = OrderedDict() # LinkedHashMap
seen_many = set() # HashSet
for index, char in enumerate(string): # O(N)
@pmav99
pmav99 / split_keyboards.md
Created November 3, 2018 11:38 — forked from itod/split_keyboards.md
Every "split" mechanical keyboard currently being sold that I know of