Skip to content

Instantly share code, notes, and snippets.

View manuelep's full-sized avatar

Manuele manuelep

  • Gter (https://www.gter.it/)
  • Genova (GE)
View GitHub Profile
@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)]
@manuelep
manuelep / scaffhold.sh
Last active April 9, 2020 21:47
web2py new scaffhold setup
#!/usr/bin/env bash
: s'
1. Clone a web2py repository
2. Checkout to the desidered version
3. Extract the scaffholding welcome application
4. Rename application (-)
5. Substitute some file:
@manuelep
manuelep / osmtaginfo.py
Last active November 27, 2019 21:27
OSM Tag info download
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
import requests, re
from builtins import str
def is_secondary(key, value):
if key in {'amenity'}:
@manuelep
manuelep / wc-free-checkout-fields.php
Last active March 18, 2019 15:25 — forked from bekarice/wc-free-checkout-fields.php
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.
*
* Tutorial: http://skyver.ge/c
*/
//function sv_free_checkout_fields() {
// first, bail if the cart needs payment, we don't want to do anything
if ( WC()->cart && WC()->cart->needs_payment() ) {
@manuelep
manuelep / .gitignore
Last active March 6, 2019 08:15
Progressive dump
*.ini
*.txt
*.log
@manuelep
manuelep / CASSAVA_INTEGRATION.md
Last active January 15, 2019 10:59
web2py patch to use WordPress with Cassava as CAS provider