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
mek@bigbertha:~/7-Projects$ python | |
Python 2.7.2+ (default, Oct 4 2011, 20:06:09) | |
[GCC 4.6.1] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import time | |
>>> def test(): | |
... """Comapring concat. + vs list.extend""" | |
... x = range(10000000) | |
... y = range(10000000) | |
... x0 = time.clock() |
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
mek@apollo:~$ python | |
Python 2.7.3 (default, Apr 20 2012, 22:39:59) | |
[GCC 4.6.3] on linux2 | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> from lazydb.lazydb import Db | |
>>> db = Db('test') | |
>>> db.put('a', '1') | |
'1' | |
>>> db.put('b', '1') | |
'1' |
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
#-*- coding: utf-8 -*- | |
import requests | |
def user(username): | |
""" | |
>>> print(user('mekarpeles')) | |
{u'public_repos': 23, u'public_gists': 2, u'name': u'Michael E. Karpeles', u'created_at': u'2011-08-13T20:01:14Z', u'url': u'https://api.github.com/users/mekarpeles'\ | |
, u'company': u'Hyperink', u'html_url': u'https://github.com/mekarpeles', u'id': 978325, u'blog': None, u'hireable': True, u'avatar_url': u'https://secure.gravatar.com/a\ | |
vatar/7ca82283af0b65b163dde4f5f5e3fb41?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png', u' |
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
#-*- coding: utf-8 -*- | |
""" | |
auth.py | |
~~~~~~~ | |
Sessions and authentication | |
""" | |
def initialize_session(web, app, storage_method, **kwargs): | |
web.config.session_parameters['ignore_expiry'] = 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
#!/usr/bin/env Python | |
import waltz | |
from waltz import track, db, render, session | |
urls = ('/session', 'Session', | |
'/analytics', 'Analytics', | |
'/', 'Index') | |
sessions = {'cart': waltz.Cart()} |
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
def exponential_backoff(exception, err=None, tries=5, debug=False): | |
"""Exponentially backoff on a certain Exception exception. | |
params: | |
tries - num of expn backed off attempts before quitting | |
err - custom error msg to display in addition to 'e' | |
debug - default False, boolean deciding whether to raise | |
error msg e along with Exception instance | |
note: | |
* debug flag used to avoid raising security sensitive exception err msgs |
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
def slurps(f, perms='r'): | |
"""Auxiliary json file open and loading function""" | |
try: | |
with open(f, perms) as fp: | |
return loads(fp.read()) | |
except: | |
raise |
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
#!/bin/bash | |
sudo pip install --upgrade waltz |
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 waltz import render, setup | |
import derp | |
urls = ('/?', 'Index') | |
env = {"derp": derp} | |
app = setup.dancefloor(urls, globals(), env=env) | |
class Index: |
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 -*- | |
import waltz | |
from waltz import track, render | |
from datetime import datetime | |
urls = ('/analytics/?', 'waltz.modules.Analytics', | |
'/rss/?', 'Rss', | |
'/?', 'Index') |
OlderNewer