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 / easylog.py
Created December 22, 2022 09:25
easy-logging
import logging
import settings
logger = logging.getLogger(settings.APP_NAME)
formatter = logging.Formatter(
"%(asctime)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s"
)
for item in settings.LOGGERS:
level, filename = item.split(":", 1)
if filename in ("stdout", "stderr"):
@manuelep
manuelep / compose-php.yml
Last active November 21, 2022 14:58
php-image-test
# docker-compose.yml
version: '3.3'
services:
php:
# image: php:7.4-apache
build:
context: .
dockerfile: php.Dockerfile
container_name: pcge
ports:
@manuelep
manuelep / .gitignore
Last active October 26, 2022 06:37
dev grass docker container
notebook-home
@manuelep
manuelep / vue_unboundler_step_by_step.sh
Created September 17, 2021 08:38
Unbbundler + Vue template test
# cd somewhere
git clone https://github.com/ali96343/unbundler.git
cp unbundler/unbun ~/.local/bin/
chmod ug+x ~/.local/bin/unbun
su - $USER # It seams it's necessary to make the unbun command recognized
# cd somewhere
py4web setup apps
cp -a apps/_scaffold apps/vlbd
mkdir apps/vlbd/static/tte
git clone https://github.com/manuelep/vue-light-bootstrap-dashboard.git apps/vlbd/static/tte/vue-light-bootstrap-dashboard
{
"result": [
{
"bg_img": "https://loremflickr.com/560/420/furniture,estate?random=5",
"geometry": {
"coordinates": [
12.3856,
44.2011
],
"type": "Point"
@manuelep
manuelep / validators.py
Last active May 13, 2021 07:56
custom pydal/py4web/web2py validators
# -*- coding: utf-8 -*-
from pydal.validators import Validator, IS_MATCH, ValidationError
class IS_NOT(Validator):
""" A not validatro is like a not joke... NOT! """
def __init__(self, validator, *args, error_message="Invalid expression", **kwargs):
super(IS_NOT, self).__init__()
self.__validator = validator(*args, **kwargs)
@manuelep
manuelep / layer-switcher.js
Last active July 23, 2021 08:14
Leaflet.layerswitcher
var LAYERSWITCHERINPUTNAME = 'overlays'
function getLeafletRadio (value, label, icon, checked) {
let lab = document.createElement('label');
let el = document.createElement('div');
lab.appendChild(el);
let input = document.createElement('input');
input.classList.add('leaflet-control-layers-selector');
input.setAttribute('type', 'radio');
@manuelep
manuelep / incrementer-control.css
Last active July 23, 2021 09:16
Leaflet.incrementerControl
a[disabled], a[disabled]:hover {
pointer-events: none;
cursor: default;
/* display: none; */
}
@manuelep
manuelep / color-legend.css
Last active August 30, 2021 16:08
Leaflet.colorLegend
.legend-item {
/* padding: 6px 8px; */
font: 18px/20px Arial, Helvetica, sans-serif;
/* background: white; */
/* background: rgba(255,255,255,0.5); */
/* box-shadow: 0 0 15px rgba(0,0,0,0.2); */
border-radius: 10px;
margin: .5em .5em .5em .5em;
}
@manuelep
manuelep / pmc.py
Created July 30, 2020 08:27
all permuted multiple combinations af a list of values
import itertools
from more_itertools import powerset
def all_possible_multivalue(*values):
values_ = list(itertools.permutations(values))
values = list(set(sum([list(powerset(vv)) for vv in values_], [])))
return values
print(sorted(all_possible_multivalue(1,2,3,), key=lambda v: (len(v), v,)))
# [(), (1,), (2,), (3,), (1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2), (1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)]