Skip to content

Instantly share code, notes, and snippets.

@jlstanus
jlstanus / sortbygpstag.py
Last active February 29, 2024 21:13
prepare data for 360 photo sharing platforms
import os
import shutil
import sys
import exifread
import gpxpy
import gpxpy.gpx
def has_gps_tags(tags):
"""
Vérifie si les métadonnées contiennent des informations de localisation GPS.
@jlstanus
jlstanus / QGIS Processing - refuges.info API extraction
Last active August 31, 2022 19:29
Import refuges.info into QGIS.
# -*- coding: utf-8 -*-
"""
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
import pandas as pd
file = open('excel.md')
data = []
for line in file.readlines():
filtered = list(filter(lambda attr: attr not in ['','\n'] , line.split('|')))
trimmed = [attr.strip() for attr in filtered]
data.append(trimmed) # provide more general splitter
data.remove(data[1])
df = pd.DataFrame(data=data)
@jlstanus
jlstanus / thermostat.lua
Last active January 20, 2022 12:19
Domoticz - Gestion thermostat Netatmo - Danfoss
-- https://www.domoticz.com/wiki/Thermostat_control
-- commandArray['SetSetPoint:MySetPointIdx']='20.5' more here: https://www.domoticz.com/wiki/LUA_commands
--------------------------------
------ Start of edit section ------
--------------------------------
local hysteresis = 0.5 --Valeur seuil pour éviter que le relai ne cesse de commuter dans les 2 sens
local thermostat = 'Living Thermostat' --Nom de l'interrupteur virtuel du thermostat
local valve_sam_droite = string.format('SetSetPoint:%s', 43) --Nom du radiateur à allumer/éteindre
local valve_sam_gauche = string.format('SetSetPoint:%s', 41)
import time
from network import WLAN
from machine import Pin, PWM
from umqtt.simple import MQTTClient
from ubinascii import hexlify
import sys
CLIENT_ID = "smashing-sub"
MQTT_SERVER = "192.168.1.10"
@jlstanus
jlstanus / system_backup.sh
Last active October 8, 2021 15:13
RPI Backup
#!/bin/bash
#
# Automate Raspberry Pi Backups
# Inspired from https://raw.githubusercontent.com/kallsbo/BASH-RaspberryPI-System-Backup/master/system_backup.sh
# Kristofer Källsbo 2017 www.hackviking.com
#
# Usage: system_backup.sh {path} {days of retention}
#
# Below you can set the default values if no command line args are sent.
# The script will name the backup files {$HOSTNAME}.{YYYYmmdd}.img
-- Classic triggers for geopackages DB files
-- 1. Creation date
CREATE TRIGGER "trigger_add_creation_date" AFTER INSERT
ON "table_name"
BEGIN
UPDATE table_name SET attribute = datetime('now') WHERE fid = NEW.fid;
END
-- 2. Update date
CREATE TRIGGER "trigger_update_date" AFTER UPDATE
@jlstanus
jlstanus / BlenderGIS How-to
Last active May 13, 2020 19:27
add sources
# BlenderGIS
## Requirements
* Download [Blender](https://www.blender.org/download/)
* Download [Blender GIS](https://github.com/domlysz/BlenderGIS)
* Install Blender GIS from *Edit > Preferences > Addon > Install*
* Install Node addon too
## Normal Process (easy)
# Create a line to show the distance between points
# http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.0.html
# 'select EnableGpkgAmphibiousMode()' to enable sql query on geopackage
select
cNewg.address,
MakeLine(cNewg.geometry, cOldg.geometry) as geometry
from
(select Newg.rue_txt || Newg.numero as address, Newg.geometry
from Newg