Skip to content

Instantly share code, notes, and snippets.

@keis
keis / coro.py
Created April 14, 2014 08:27
asyncio examples
import asyncio
@asyncio.coroutine
def waiting(r):
print("hello from waiting -", r)
yield from asyncio.sleep(2)
print("bye from waiting -", r)
return r
@andrequeiroz
andrequeiroz / holtwinters.py
Last active July 5, 2023 07:50
Implementation of Holt-Winters algorithms in Python 2
#The MIT License (MIT)
#
#Copyright (c) 2015 Andre Queiroz
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
#in the Software without restriction, including without limitation the rights
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#copies of the Software, and to permit persons to whom the Software is
#furnished to do so, subject to the following conditions:
@alexprengere
alexprengere / geobases_custom_map.py
Last active December 12, 2015 01:28
GeoBases visualize method used to display custom markers and lines on a map, *development version*.
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Drawing some lines between airports on a map.
"""
from GeoBases import GeoBase
def main():
@alexprengere
alexprengere / flask_over_geobases.py
Last active December 12, 2015 01:28
Webservices over GeoBases with Flask
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Webservice over GeoBases using Flask.
"""
# Flask is a microframework web
from flask import Flask, request, jsonify
@alexprengere
alexprengere / geobases_cities_to_por.py
Last active December 12, 2015 00:18
Map cities to points of reference using GeoBases ori_por data source
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Map cities to points of reference sorted
by pageranks.
"""
from GeoBases import GeoBase
@babakness
babakness / caselessDictionary.py
Created October 16, 2012 18:46 — forked from bloomonkey/caselessDictionary.py
A Python dictionary sub-class that is case-insensitive when searching, but also preserves the keys as inserted.
class CaselessDictionary(dict):
"""Dictionary that enables case insensitive searching while preserving case sensitivity
when keys are listed, ie, via keys() or items() methods.
Works by storing a lowercase version of the key as the new key and stores the original key-value
pair as the key's value (values become dictionaries)."""
def __init__(self, initval={}):
if isinstance(initval, dict):
for key, value in initval.iteritems():