Skip to content

Instantly share code, notes, and snippets.

View manuelep's full-sized avatar

Manuele Pesenti manuelep

  • Gter (https://www.gter.it/)
  • Genova (GE)
View GitHub Profile
@manuelep
manuelep / README.md
Last active September 15, 2025 13:20
Reorder and Orient MULTILINESTRING Components in PostGIS

Reorder and Orient MULTILINESTRING Components in PostGIS

This PostgreSQL/PostGIS function, reorder_multilinestring, takes a MULTILINESTRING geometry and returns a new MULTILINESTRING with components reordered and oriented based on geometric criteria. It is particularly useful for GIS applications where the order and orientation of line segments matter, such as routing, network analysis, or pipeline management.

Features

  1. Component extraction: Splits the input multilinestring into individual lines using ST_Dump.
  2. Sequence ordering: Orders line components by minimum distance between consecutive endpoints, creating a coherent path.
  3. Orientation of components: Ensures each line is oriented correctly to connect smoothly to the previous line.
  4. Merging of close components: Optionally merges consecutive components into a single LINESTRING if the distance between them is below a configurable threshold.
@fdrcslv
fdrcslv / test_map.py
Last active January 10, 2019 09:50
test_map.py
import plotly.graph_objs as go
import plotly.io as pio
#orca serve
if __name__ == '__main__':
pio.orca.config.port = 8005
data = [
@manuelep
manuelep / test.py
Last active March 15, 2018 16:56
woocommerce webhook authemtication
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest, json
from woohook import *
class TestWoo(unittest.TestCase):
def test_authenticate(self):
@bekarice
bekarice / wc-free-checkout-fields.php
Last active October 31, 2021 19:10
Simplify WooCommerce checkout fields for free checkouts
<?php // only copy if needed
/**
* Removes coupon form, order notes, and several billing fields if the checkout doesn't require payment.
*
* REQUIRES PHP 5.3+
*
* Tutorial: http://skyver.ge/c
*/
function sv_free_checkout_fields() {
@manuelep
manuelep / w2p-bb-install.sh
Last active June 23, 2017 14:45
get a brand new minimalist version of web2py
#!/bin/bash
git clone --recursive https://github.com/web2py/web2py.git web2py_temp
cd web2py_temp
git checkout tags/R-2.11.2
git submodule update --init --recursive
python scripts/make_min_web2py.py ../web2py
mv applications/admin ../web2py/applications/
cd ../
rm -rf web2py_temp
@alexcouper
alexcouper / help.md
Last active December 23, 2020 07:18
My pre commit hook. No more pdb please!
@floer32
floer32 / centos_cx_Oracle
Last active January 6, 2020 23:29
CentOS 6: Set up Oracle Instant Client and Python package cx_Oracle
#!/bin/bash
# INSTALL ORACLE INSTANT CLIENT #
#################################
# NOTE: Oracle requires at least 1176 MB of swap (or something around there).
# If you are using CentOS in a VMWare VM, there's a good chance that you don't have enough by default.
# If this describes you and you need to add more swap, see the
# "Adding a Swap File to a CentOS System" section, here:
# http://www.techotopia.com/index.php/Adding_and_Managing_CentOS_Swap_Space
@lg0
lg0 / markdown.xml
Created April 10, 2012 19:58
Markdown Syntax Highlighting for Sublime text 2
<!-- copy this to YOUR_THEME.tmTheme-->
<dict>
<key>name</key>
<string>diff: deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#EAE3CA</string>
@timdream
timdream / VBoxReloadKext.sh
Created February 10, 2012 07:33
reload VirtualBox kernel extension in Mac OS X - good for USB problem on Lino
#!/bin/bash
sudo kextunload -b org.virtualbox.kext.VBoxUSB
sudo kextunload -b org.virtualbox.kext.VBoxNetFlt
sudo kextunload -b org.virtualbox.kext.VBoxNetAdp
sudo kextunload -b org.virtualbox.kext.VBoxDrv
sudo kextload /Library/Extensions/VBoxDrv.kext -r /Library/Extensions/
sudo kextload /Library/Extensions/VBoxNetFlt.kext -r /Library/Extensions/
sudo kextload /Library/Extensions/VBoxNetAdp.kext -r /Library/Extensions/
@jatorre
jatorre / readshp.py
Created April 24, 2011 19:53
A python script to detect encoding and SRID of a shapefile GUESSING its best
from chardet.universaldetector import UniversalDetector
import os.path
import sys
import dbfUtils
import sys
from osgeo import osr
from urllib import urlencode
from urllib2 import urlopen
import json