Skip to content

Instantly share code, notes, and snippets.

Implementare una classe Spritz che modelli un bicchiere di Spritz.
Uno spritz può essere normale (200 ml) o grande (350 ml).
Implementare un metodo "sip()" che riduca la quantità nel bicchiere di spritz di 30ml e ritorni la quantità bevuta. Se il bicchiere è vuoto, solleva un'eccezione.
Implementare un metodo "boia_se_l_era_bon(size)" che ritorni una nuova istanza della classe Spritz. Anche in questo caso lo spritz può essere normale o grande.
Implementare un metodo "can_i_drive(kg)" che ritorni un valore booleano. La funzione ritorna True se la quantità di alcool ingerita ad inizio serata è inferiore ai limiti di legge. La tabella è riportata in versione semplificata qui di seguito: se kg<65 allora il limite è di 350ml, se 65<kg<75 il limite è di 450ml, se kg>75 il limite è di 550ml. (NdA: i conti li ho fatti a cazzo di cane, non usate questo esercizio come riferimento per decidere se mettervi alla guida dopo un aperitivo).
var clContactForm = function () {
/* local validation */
$('#contactForm').validate({
/* submit via ajax */
submitHandler: function (form) {
var sLoader = $('.submit-loader');
import faust
app = faust.App("debug", broker="localhost:9092")
def a(mess):
print("I'm a")
print(mess)
def b(mess):
print("I'm b")
[run]
branch = True
source = */my_module/*
# omit = bad_file.py
[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
@chobeat
chobeat / functional_error_handling.py
Last active May 23, 2018 14:24
Naive functional error collection in Python
def execute_with_error_collection(execution_spec, exception, args=None, kwargs=None):
"""
Allows to functionally collect errors in a given set of operations by specifying lazily the operations to execute
with the relative arguments
:param execution_spec: lazy specification of the operations to execute. Expected fields: function, args, kwargs.
:param exception: the type of exception to collect. Use Exception to capture everything.
:param args: overrides the args field in the spec if specified. Used to apply all the functions on the same argument
set without repetition in the spec.
:param kwargs: overrides the kwargs field in the spec if specified. Used to apply all the functions on the same
@chobeat
chobeat / place_italy_flag.py
Created April 2, 2017 14:56 — forked from fgaz/place_italy_flag.py
Mantain italy's flag in /r/place
# needs python 2
import urllib
import urllib2
import time
import json
import random
# italy flag position:
xmin = 107
class JPMMLEvaluationMapOperator(pmmlSource: String,
inputPreparationErrorHandlingStrategy: InputPreparationErrorHandlingStrategy,
missingValueStrategy: MissingValueStrategy,
resultExtractionStrategy: ResultExtractionStrategy)
extends RichMapFunction[Map[String, Any], Map[String, Serializable]] {
//The evaluator is transient and built in the open() function to allow proper serializability of the operator.
@transient
private var evaluator: Evaluator = null
2016-03-17 11:16:16,053 INFO org.apache.flink.yarn.YarnTaskManagerRunner - --------------------------------------------------------------------------------
2016-03-17 11:16:16,054 INFO org.apache.flink.yarn.YarnTaskManagerRunner - Starting YARN TaskManager (Version: 1.0.0, Rev:94cd554, Date:03.03.2016 @ 09:34:27 CET)
2016-03-17 11:16:16,054 INFO org.apache.flink.yarn.YarnTaskManagerRunner - Current user: hadoop
2016-03-17 11:16:16,054 INFO org.apache.flink.yarn.YarnTaskManagerRunner - JVM: Java HotSpot(TM) 64-Bit Server VM - Oracle Corporation - 1.8/25.60-b23
2016-03-17 11:16:16,054 INFO org.apache.flink.yarn.YarnTaskManagerRunner - Maximum heap size: 1388 MiBytes
2016-03-17 11:16:16,054 INFO org.apache.flink.yarn.YarnTaskManagerRunner - JAVA_HOME: /usr/java/jdk1.8.0_60/
2016-03-17 11:16:16,055 INFO org.apache.flink.yarn.YarnTaskManagerRunner - Hadoop version: 2.7.1.2.3.4.
2016-03-16 14:32:52,255 INFO org.apache.flink.runtime.checkpoint.ZooKeeperCompletedCheckpointStore - Initialized in '/checkpoints/124f29322f9026ac1b35435d5de9f625'.
2016-03-16 14:32:52,265 INFO org.apache.flink.runtime.checkpoint.ZooKeeperCompletedCheckpointStore - Recovering checkpoints from ZooKeeper.
2016-03-16 14:32:52,287 INFO org.apache.flink.runtime.checkpoint.ZooKeeperCompletedCheckpointStore - Found 1 checkpoints in ZooKeeper.
2016-03-16 14:32:52,300 INFO org.apache.flink.runtime.checkpoint.ZooKeeperCompletedCheckpointStore - Initialized with Checkpoint 138 @ 1458135120309 for 124f29322f9026ac1b35435d5de9f625. Removing all older checkpoints.
2016-03-16 14:32:52,451 INFO org.apache.flink.runtime.checkpoint.ZooKeeperCompletedCheckpointStore - Initialized in '/checkpoints/7f280b38065eaa6335f5c3de4fc82547'.
2016-03-16 14:32:52,454 INFO org.apache.flink.runtime.checkpoint.ZooKeeperCompletedCheckpointStore - Recovering checkpoints from ZooKeeper.
2016-03-16 14:32:52,465 INFO org.apache.flink.r