Skip to content

Instantly share code, notes, and snippets.

View javamo's full-sized avatar

Jairo Vásquez javamo

  • Atlas Health
  • Medellin, Colombia
View GitHub Profile
def get_top10(app_id):
ts = get_all(app_id)
cities_str = ""
cities = {}
for t in ts:
city = t.client_city.lower()
if city != "":
if "@%s@"%city not in cities_str:
cities_str += "@%s@"%city
def get_ds():
ds = {}
for t in ts:
t_date = t.date.date()
app_id = t.application_id
key = "%s_%s" % (app_id,t_date.strftime("%Y_%m_%d"))
if key not in ds.keys():
ds[key] = DaySum.get_or_create(t_date,app_id)
<div id="reg_lan_house_dialog">
<form method="post" id="anunciar_form">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td height="95"><table width="741" cellspacing="0" cellpadding="0" border="0" background="img/w01.png" align="center">
<tbody><tr>
<td width="644" height="95"> </td>
<td width="97"/>
</tr>
ts = ["48F7975726EE4262BDDBD86DA9EBE312",
"7DCAF69EBE914AED971C823D790A29BF",
"8A3D066A798F4AA7BE29603C276F1C7E",
"3207DC8022E64772A8CF1F5CC63A215A",
"1F65E012932C456A852D7898C48D65DF",
"92FC15F5C63B487DA101944B49CE64AB",
"685F15C0533046A0870BF4DA2F3F82E5",
"C849FC9FAEBF4F41932BA2D781303D67",
"E6ACD9CC11734E70AE9AD67538057EC9",
"298A2B1EF2AA4274825DAF9FE95A3982",
ts2 = ["E4B17DFFCBC946C0AFE76015965B0556",
"9D3C345A3DFB41DBBD711A490300E15C",
"719D7A608E3249998B1EFE5DB208611A",
"61B0A02031C642F48D75C9941576964D",
"90A6544D45874A1F96F4677F8899278C",
"9823CEB23C9143498515BB5B297260B6",
"0BDBC1376CB64004A2C12949B111E3C8",
"38BF6FCC65A44BA6B7AFCF0E132C7704",
"5E34DDFE1A3A4DBAA69C0D256920883C",
"5F764F199B7849C9A3EE2E5B08DBF2BD",
start = 0
end = 50
keep = True
while keep:
try:
db.put(trans[start:end])
except:
db.put(trans[start:end])
start = end
start = 0
end = 50
while keep:
try:
db.put(trans[start:end])
except:
db.put(trans[start:end])
start = end
end += 50
def retry_on_timeout(retries=4, secs=1):
"""A decorator to retry a given function performing db operations."""
def _decorator(func):
def _wrapper(*args, **kwds):
tries = 0
while True:
try:
tries += 1
return func(*args, **kwds)
except (db.Timeout,Timeout), e:
self.filters = []
approved_filter = {'property' : 'approved',
'condition' : '=',
'value' : True}
def add_filter(filter):
self.filters.append(filter)
def apply_filters():
def get_infinite_numbers(start):
while True:
yield start
start += 1
# You can use it directly but put a limit
start = 3
limit = 10
for number in get_infinite_numbers(start):
print number