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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
Map cities to points of reference sorted | |
by pageranks. | |
""" | |
from GeoBases import GeoBase |
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
Webservice over GeoBases using Flask. | |
""" | |
# Flask is a microframework web | |
from flask import Flask, request, jsonify |
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
Drawing some lines between airports on a map. | |
""" | |
from GeoBases import GeoBase | |
def main(): |
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
#!/usr/bin/env python | |
""" | |
Simple converter from pace to reference times | |
for runners. | |
$ ./run_times_from_pace.py 4:15 -d 1.0 | |
1.00km in 0:04:15 gives you: | |
1km: 0:04:15 ( 1.00km) |
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
#!/usr/bin/python | |
""" | |
Some stats functions:: | |
>>> mean([1, 2, 6]) | |
3.0 | |
>>> variance([1, 2, 6], bias=True) | |
4.666666... |
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
#!/usr/bin/python | |
""" | |
Some prettification functions. | |
>>> humanize(1024, is_bytes=True) | |
'1.0 kB' | |
>>> humanize(1000*12342) | |
'12.3 M' | |
>>> pretty_num(1255000) |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from GeoBases import GeoBase | |
import pytz | |
def pors_with_unk_tz(db_oripor): | |
for p in db_oripor: | |
p_tz = db_oripor.get(p, 'timezone') |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
from GeoBases import GeoBase | |
import pytz | |
def load_best_known(filename): | |
with open(filename) as f: |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from GeoBases import GeoBase | |
def main(): | |
g = GeoBase('ori_por', verbose=False) | |
for p in g: |
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 traceback | |
from functools import wraps | |
def log_exceptions(fd): | |
def _wrapped(func): | |
@wraps(func) | |
def _func(*args, **kwargs): | |
try: | |
return func(*args, **kwargs) | |
except Exception: |
OlderNewer