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 / wooapitest.py
Created February 26, 2018 16:34
wooapitest
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests, urlparse
import json
import argparse
import logging
parser = argparse.ArgumentParser(
description = """DOC""",
@manuelep
manuelep / proxy.py
Last active February 13, 2018 14:34
web2py proxy
# -*- coding: utf-8 -*-
# coding: utf8
import requests
#from requests.auth import HTTPBasicAuth
from storage import Storage
@auth.requires_login()
def index():
@manuelep
manuelep / divide_by_voronoi.py
Last active October 9, 2017 12:19
How to divide poolygon into voronoi sub-polygons
from shapely.geometry import MultiPoint, Point, Polygon
from scipy.spatial import Voronoi
import numpy as np
import matplotlib.pyplot as plt
"""
1. buffer di max 20 m intorno al poligono building
2. selezione dei punti contenuti nel buffer
3. suddivizione del poligono originario in aree di voronoi come qui di seguito
4. assegnazione per ogni poligono di voronoi delle caratteristiche del punto
@manuelep
manuelep / osm_model.py
Created October 7, 2017 22:08
osm model
# -*- coding: utf-8 -*-
osm = DAL(myconf.get('osm.uri'),
pool_size = myconf.get('osm.pool_size'),
migrate_enabled = False,
check_reserved = ['all'],
lazy_tables = True
)
commons = osm.Table(osm, "commons",
@manuelep
manuelep / conf.py
Last active June 27, 2017 21:15 — forked from giuserpe/conf.py
class conf:
def __init__(self, path):
self.config = configparser.SafeConfigParser()
self.config.read(path)
self.path = path
def write(self, section, option, value):
"""
http://www.programcreek.com/python/example/1033/ConfigParser.SafeConfigParser
@manuelep
manuelep / squeue.py
Last active June 16, 2017 14:39
Sorted queue management
# -*- coding: utf-8 -*-
import bisect
from itertools import izip
class Squeue(object):
""" """
def __init__(self, _iter, key=None):
super(Squeue, self).__init__()
@manuelep
manuelep / map_service.py
Last active June 24, 2017 06:22
A web service that draw a map to be called using LOAD web2py helper
@service.run
def getmap(conn, tablename, the_geom="geom", bbox=''):
""" """
session.forget(response)
js = """
var url = "%(url)s";
var gargs = "%(bbox)s" && '?bbox='+"%(bbox)s";
var dynSource = new ol.source.Vector({
url: url + gargs,
format: new ol.format.GeoJSON(),
@manuelep
manuelep / geom_service.py
Created September 7, 2016 07:25
A web service for collecting geometries in geojson format for populating maps
# -*- coding: utf-8 -*-
from dal import Table
import geojson, json, pyproj
import shapely.wkt
from dal import Expression
# from gluon.dal import geoPolygon
from dal import geoPoint, geoLine, geoPolygon
# [...]
@manuelep
manuelep / test_validate_and_update_or_insert_with_json_field.py
Created August 21, 2015 13:21
Unittest for testing strange behaviour of json fields with method validate_and_update_or_insert
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
from gluon.serializers import json as json_dumper
class UsingJsonFieldWithValidateAndUpdateOrInsertTestCase(unittest.TestCase):
def setUp(self):
db.define_table('tt', Field('aa', 'json', default={}))
@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