This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| import itertools | |
| import collections | |
| def sum_column(data): | |
| return sum(zip(*data)[1], 0.0) | |
| def split_groups(sensors): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import baker | |
| import slumber | |
| import pathlib | |
| import colorama | |
| API_URL = 'https://api.github.com/' | |
| def get_api(auth=None): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ ls hammock/dist/ | |
| hammock-0.1.0-py27-none-any.whl | |
| $ pip install hammock --no-index --find-links file:///home/miki/exp/hammock/dist | |
| Ignoring indexes: http://pypi.python.org/simple/ | |
| Downloading/unpacking hammock | |
| Requirement already satisfied (use --upgrade to upgrade): requests>=0.13.6 in ./lib/python2.7/site-packages/requests-0.13.6-py2.7.egg (from hammock) | |
| Installing collected packages: hammock | |
| Successfully installed hammock | |
| Cleaning up... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| from paramunittest import * | |
| @parametrized( | |
| ('1', '2'), | |
| ) | |
| class TestFoo(ParametrizedTestCase): | |
| def setParameters(self, a, b): | |
| self.a = a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from paramunittest import * | |
| @parametrized((1, 2)) | |
| class TestLess(ParametrizedTestCase): | |
| def setParameters(self, a, b): | |
| self.a = a | |
| self.b = b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| Problem solution | |
| ---------------- | |
| The area of a circular ring is: | |
| pi * (R^2 - r^2) | |
| where R is the radius of the bigger circle and r | |
| the radius of the other one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import collections | |
| # From | |
| # http://stackoverflow.com/questions/1653970/does-python-have-an-ordered-set | |
| class OrderedSet(collections.OrderedDict, collections.MutableSet): | |
| def update(self, *args, **kwargs): | |
| if kwargs: | |
| raise TypeError("update() takes no keyword arguments") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Configuration | |
| root=/dev/sda3 | |
| boot=/dev/sda1 | |
| home=/dev/sda4 | |
| lang=en_US-UTF-8 | |
| keyboard=it | |
| zone=Europe | |
| subzone=Rome |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| f=lambda w=4:(lambda j,o,i:(lambda s,g:list(i.takewhile(lambda _:len(o)<w+1, | |
| (((4*g(0)+g(1)-g(2)<g(4)*g(2)and(o.append(int(g(4))),s(6,10*(g(1)-g(4)*g(2))), | |
| s(4,((10*(3*g(0)+g(1)))//g(2))-10*g(4)),s(0,g(0)*10),s(1,g(6))))or(s(6,(2*g(0) | |
| +g(1))*g(5)),s(7,(g(0)*(7*g(3))+2+(g(1)*g(5)))//(g(2)*g(5))),s(0,g(0)*g(3)), | |
| s(2,g(2)*g(5)),s(5,g(5)+2),s(3,g(3)+1),s(4,g(7)),s(1,g(6))))for _ in iter(int,1) | |
| )))and o)(lambda v,y:j.__setitem__(v,y),lambda v:j[v]))([1,0,1,1,3,3,-1,-1],[], | |
| __import__('itertools')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''Definire una classe PColor e una classe PImage secondo le seguenti specifiche. | |
| La classe PColor rappresenta un pixel che puo' avere un colore RGB o essere | |
| trasparente e deve implementare i seguenti metodi: | |
| - Costruttore, senza argomenti, che inizializza l'oggetto come pixel trasparente. | |
| - set_RGB(r, g, b) imposta il colore RGB dell'oggetto con i valori r,g,b e | |
| ritorna l'oggetto. | |
| - to_RGB() ritorna una tripla (r,g,b) che sono i valori dei canali RGB |