Skip to content

Instantly share code, notes, and snippets.

View ccalabro's full-sized avatar

Cristian Calabro ccalabro

View GitHub Profile
def flatten_lists(integer_list):
list_to_return = []
for element in integer_list:
"""
if element is a list, recursivelly call flatten_lists and extend the list
else, append the element to the list to return
"""
if type(element) == list:
list_to_return.extend(flatten_lists(element))
else:
@ccalabro
ccalabro / lat_requests
Last active August 29, 2015 14:17
Determines if answer a request depending latency average
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# # http://stackoverflow.com/a/15613104/3041998
import random
th_min = 0.8
th_max = 1.6
def request_ok(lat_avg, th_min, th_max):