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
| # encoding: utf-8 | |
| import urllib | |
| from lxml.html import fromstring | |
| URL = 'http://eu.battle.net/wow/es/forum/975481/' | |
| def is_blue_post(element): | |
| return len(element.getparent().cssselect('.blizzard_icon')) > 0 | |
| if __name__ == '__main__': |
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
| >>> a = "Ciudad south=Enolmu east=Dixu west=Dodala north=Trololo" | |
| >>> dict([direction.split('=') for direction in a.split()[1:]]) | |
| {'west': 'Dodala', 'east': 'Dixu', 'north': 'Trololo', 'south': 'Enolmu'} |
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 re | |
| OPERADORES = {'^=': lambda x,y: x+y, | |
| '^@': lambda x,y: x-y, | |
| '^#': lambda x,y: x*y} | |
| OP_RE = r'(\^\=|\^\@|\^\#) (\-?\d+)( \-?\d+)?\$' | |
| def componer(op): | |
| return '%s$' % ' '.join(op) |
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
| <snippet> | |
| <content><![CDATA[import ipdb; ipdb.set_trace()]]></content> | |
| <tabTrigger>ipdb</tabTrigger> | |
| <scope>source.python</scope> | |
| <description>ipdb</description> | |
| </snippet> |
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 decimal import Decimal | |
| def distribute(amount, n, decimals=2): | |
| """ | |
| Distribute an amount among n users. | |
| * Returns a list of Decimals. | |
| >>> allocate(0.02, 3) | |
| [Decimal('0.01'), Decimal('0.01'), Decimal('0.0')] |
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
| # My .gitconfig | |
| # C&P from http://cheat.errtheblog.com/s/git | |
| [user] | |
| name = NAME | |
| email = EMAIL | |
| [color] | |
| ui = auto |
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 re | |
| def credit_card_type(number): | |
| """ | |
| Return a string that represents the type of the credit card number. | |
| Criteria: | |
| AMEX: Starts with 34 or 37 and the length 15. | |
| MASTERCARD: Starts with 51-55 and the length is 16. |
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
| #index is like this | |
| index = [ | |
| ('content indexed', object_id), | |
| ('test string', 1), | |
| ... | |
| ] | |
| def _search(q): | |
| if q: | |
| q = q.lower() |
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
| tweets = [ | |
| {'user_name':'jorgebastida', 'message': 'Hello world!', 'timestamp': datetime.now()}, | |
| {'user_name':'jaimeirurzun', 'message': 'I like ponies :D', 'timestamp': datetime.now()}, | |
| {'user_name':'jorgebastida', 'message': 'Django rulezzzzz', 'timestamp': datetime.now()} | |
| ] |
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
| # Project Page: https://github.com/jorgebastida/glue | |
| # command | |
| glue glyphicons/ out --ignore-filename-paddings --namespace= --crop --padding=5 --order=height | |
| # output png | |
| http://dl.dropbox.com/u/567726/glyphicons.png |
OlderNewer