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 neobase import NeoBase | |
N = NeoBase() | |
for key in N: | |
N.set(key, city_codes=set(N.get(key, "city_code_list"))) | |
for key in sorted(N): | |
if "A" not in N.get(key, "location_type"): | |
continue |
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 -*- | |
""" | |
Code from https://lethain.com/genetic-algorithms-cool-name-damn-simple | |
""" | |
from random import randint, random | |
from operator import add |
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: |
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
#!/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 | |
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/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/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/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 | |
# -*- coding: utf-8 -*- | |
""" | |
Drawing some lines between airports on a map. | |
""" | |
from GeoBases import GeoBase | |
def main(): |
NewerOlder