Skip to content

Instantly share code, notes, and snippets.

View CEZERT's full-sized avatar

MARC YERANOSYAN CEZERT

View GitHub Profile
@CEZERT
CEZERT / common.py
Last active September 28, 2021 20:12
liste1 = [100, 24, 'toto', '%']
liste2 = [89, 25, 'totol', '%*']
def meme(l1, l2):
for x in l1:
for j in l2:
if x==j:
return True
print(meme(liste1,liste2))
layer = iface.activeLayer()
features = layer.getFeatures()
newFeature = QgsFeature(layer.fields())
newFeature["ID_POINT_D"]=20084
pt = QgsGeometry().fromPointXY(QgsPointXY(2.272507912597,51.020400936747))
newFeature.setGeometry(pt)
layer.startEditing()
layer.addFeature(newFeature)
'''
layer.commitChanges()
3d:tessellate -> Mosaïquer
DataPlotly:build_generic_plot -> Build a generic plot
Networks:auto_connectors -> Auto-connecteurs
Networks:build_connectors -> Créer connecteurs
Networks:build_graph -> Créer graphe
Networks:concatenate_networks -> Concaténer réseaux
Networks:connect_nodes2lines -> Connecter des points à des lignes
Networks:get_link_flows_data -> Importer des données de flux
Networks:gtfs_import -> Import GTFS
Networks:indicators_by_OD -> indicateurs par OD
#with os
import os
os.makedirs('2018/10/05', mode=0o770)
#with pathlib
import pathlib
p = pathlib.Path('2018/10/05')
p.mkdir(parents=True)
import functools
def decorator(func):
@functools.wraps(func)
def wrapper_decorator(*args, **kwargs):
# Do something before
value = func(*args, **kwargs)
# Do something after
return value
return wrapper_decorator
import functools
import time
def timer(func):
"""Print the runtime of the decorated function"""
@functools.wraps(func)
def wrapper_timer(*args, **kwargs):
start_time = time.perf_counter() # 1
value = func(*args, **kwargs)
end_time = time.perf_counter() # 2
import functools
def debug(func):
"""Print the function signature and return value"""
@functools.wraps(func)
def wrapper_debug(*args, **kwargs):
args_repr = [repr(a) for a in args] # 1
kwargs_repr = [f"{k}={v!r}" for k, v in kwargs.items()] # 2
signature = ", ".join(args_repr + kwargs_repr) # 3
print(f"Calling {func.__name__}({signature})")
import functools
import time
def slow_down(func):
"""Sleep 1 second before calling the function"""
@functools.wraps(func)
def wrapper_slow_down(*args, **kwargs):
time.sleep(1)
return func(*args, **kwargs)
return wrapper_slow_down
from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom')
def findreplace(s, feature, value):
chars = [('Â', '')
,('Ê', 'E')
,(' Î', 'I')
,('Ô', 'O')

Notes

-- Table Rules

-- DROP RULE qualification_trace_insert_ignore ON traitement."Qualification_trace";

CREATE RULE qualification_trace_insert_ignore AS ON INSERT TO "Acapulco"."Qualification_trace" WHERE (EXISTS ( SELECT 1 FROM "Acapulco"."Qualification_trace"