This file contains 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 falcon #webframework | |
import json #json duh! | |
import requests #sane http get/post/etc. | |
from bs4 import BeautifulSoup #sane htmlparser | |
def get_soup(): | |
#Link u guys provided.... get me the .json !!!! | |
html_doc = requests.get("http://www.jmarcano.com/mipais/geografia/province/municipios/").text | |
if not html_doc: | |
#lame sanity check. TODO: make proper |
This file contains 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 falcon #webframework | |
import json #json duh! | |
import requests #sane http get/post/etc. | |
from bs4 import BeautifulSoup #sane htmlparser | |
def get_soup(): | |
#Link u guys provided.... get me the .json !!!! | |
html_doc = requests.get("http://www.jmarcano.com/mipais/geografia/province/municipios/").text | |
if not html_doc: | |
#lame sanity check. TODO: make proper |
This file contains 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 operator | |
# Estas cedulas fueron emitidas por la JCE, pero no cumplen con el | |
# digito verificador, por lo cual deben ser verificadas por separado. | |
excepcionesCedulas = ['00000000018', '11111111123', '00100759932', '00105606543', '00114272360', '00200123640', | |
'00200409772', '00800106971', '01200004166', '01400074875', '01400000282', '03103749672', | |
'03200066940', '03800032522', '03900192284', '04900026260', '05900072869', '07700009346', | |
'00114532330', '03121982479', '40200700675', '40200639953', '00121581750', '00119161853', | |
'22321581834', '00121581800', '09421581768', '22721581818', '90001200901', '00301200901', | |
'40200452735', '40200401324', '10621581792']; |
This file contains 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
- si el post original dice "mejor" skip it. | |
- si dice offtopic you should read it. | |
- si dije java y .net en la misma oracion skip it. | |
- Si melvyn arranco el post skip it. | |
- If it has more than 50 replies skip it. | |
- if marmolejos answered first skip it. | |
- if Orly quotes the rules skip it. | |
- if it contains php next, probably not worth it. | |
- si dice morrison, dodo o software libre skip it. |
This file contains 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 django.http import HttpResponse | |
from django.utils import simplejson as json | |
from django.views.generic.list import BaseListView | |
def json_render_to_response(context): | |
"Returns a JSON response containing 'context' as payload" | |
payload = json.dumps(context) | |
json_response = HttpResponse(payload,content_type="application/json") | |
return json_response |
This file contains 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
debug | |
print/pprint | |
logging | |
import pdb;pdb.set_trace() | |
import ipdb;ipdb.set_trace() | |
import code;code.interact(local=locals()) | |
https://nose.readthedocs.org/en/latest/testing_tools.html#nose.tools.set_trace | |
nose --pdb or --pdb-failures | |
other functions in pdb/ipdb |
This file contains 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
>>> range(0) == True | |
False | |
>>> range(1) == True | |
False | |
>>> if range(1): | |
... print True | |
... | |
True | |
>>> if not range(0): | |
... print False |
This file contains 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 forbiddenfruit import curse | |
from datetime import timedelta,datetime | |
curse(int,'days',property(lambda s:timedelta(s))) | |
(12).days | |
curse(timedelta,'ago',property(lambda s:datetime.now()-s)) | |
print (12).days.ago |
This file contains 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
class Player | |
def initialize() | |
@health = 21 | |
@forward = :forward | |
@backward = :backward | |
@direction = @forward | |
end | |
def play_turn(warrior) | |
spaces = warrior.look(:forward) |
This file contains 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
class Signal(object): | |
def __init__(self,providing_args): | |
pass | |
signals = {'hook': [Signal(providing_args=a) for a in ['change','...']]} | |
#output is | |
# {'hook': [<__main__.Signal object at 0x10334dcd0>, <__main__.Signal object at 0x10334dd10>]} |
OlderNewer