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
| # -*- coding: utf-8 -*- | |
| def indent(elem, level=0): | |
| tab_size = ' ' | |
| i = '\n' + level * tab_size | |
| if len(elem): | |
| if not elem.text or not elem.text.strip(): | |
| elem.text = i + tab_size | |
| if not elem.tail or not elem.tail.strip(): | |
| elem.tail = i | |
| for elem in elem: |
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
| # /home/user | |
| cd ~ | |
| # .eclipse folder | |
| cd .eclipse/org.eclipse.platform_3.8_155965261/configuration/org.eclipse.core.runtime | |
| # remove file .keyring | |
| rm .keyring | |
| # one-line | |
| rm ~/.eclipse/org.eclipse.platform_3.8_155965261/configuration/org.eclipse.core.runtime/.keyring |
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
| #!/usr/bin/python | |
| import math | |
| # [255th decimal of the constant quantity that determines the area of a circle | |
| # by multiplying it by the radius squared] | |
| PI_255_DECIMAL = int((math.pi * 10 ** 255) % 10) # == 8 | |
| def is_prime(num): |
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
| apt-get remove python-pip | |
| curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py" | |
| python get-pip.py | |
| pip --version |
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
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| ecs = [ | |
| "ascii", | |
| "big5", | |
| "big5hkscs", | |
| "cp037", | |
| "cp424", | |
| "cp437", |
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
| u'Garc\xc3\xada'.encode('latin-1').decode('utf-8') |
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 datetime | |
| import pytz | |
| # From local timezone to UTC | |
| pytz.timezone('Europe/Madrid').localize(datetime.datetime.now()).astimezone(pytz.utc) | |
| # Step by step | |
| tz = pytz.timezone('Europe/Madrid') | |
| my_naive_datetime = datetime.datetime.now() | |
| my_local_datetime = tz.localize(my_naive_datetime) |
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
| @api.depends('proyecto_id','proyecto_id.name','tarea_id','tarea_id.name','producto_id','producto_id.name') | |
| def _compute_name(self): | |
| for project_material in self: | |
| name = "" | |
| if project_material.proyecto_id: | |
| name += project_material.proyecto_id.name | |
| if project_material.tarea_id: | |
| if name != '': | |
| name+=' - ' | |
| name += project_material.tarea_id.name |
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
| # -*- coding: utf-8 -*- | |
| import csv | |
| def ustr(s): | |
| return unicode(s, 'cp850', errors='replace') | |
| with open('fichero_traspaso.csv', 'rb') as csvfile: | |
| spamreader = csv.reader(csvfile, delimiter=';', quotechar='"') | |
| for row in spamreader: |
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
| acme-tiny | |
| anybox.buildbot.openerp | |
| appdirs | |
| attrs | |
| autobahn | |
| Babel | |
| beautifulsoup4 | |
| behave | |
| boltons | |
| boto |