Skip to content

Instantly share code, notes, and snippets.

View thruflo's full-sized avatar

James Arthur thruflo

View GitHub Profile
class Flickr(RequestHandler):
def post(self, action):
self.get(action)
def get(self, action):
client = flickrapi.FlickrAPI(
config.FLICKR_API_KEY,
config.FLICKR_API_SECRET,
store_token = False
)
import gevent
from gevent import monkey
# patches stdlib (including socket and ssl modules) to cooperate with other greenlets
monkey.patch_all()
from sqlalchemy import create_engine
engine = create_engine('postgresql+pg8000://postgres:%s@localhost/mydb' % password)
connection = engine.connect()
<p><object width="512" height="308">
<param name="movie"
value="http://www.youtube.com/v/21pE9VtWZlc&amp;fs=1"
/>
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always" />
<embed width="512" height="308"
allowfullscreen="true"
allowscriptaccess="always"
type="application/x-shockwave-flash"
<p><object width="512" height="308">
<param name="movie"
value="http://www.youtube.com/v/nsRMCBDeUY8&amp;fs=1"
/>
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always" />
<embed width="512" height="308"
allowfullscreen="true"
allowscriptaccess="always"
type="application/x-shockwave-flash"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Abstract base classes for a gevent_ based Streaming API consumer:
#. a long running streaming API ``Consumer``
#. a ``BaseManager`` which looks after ``Consumer`` instances
running in their own ``gevent.Greenlet`` thread
#. an ultra-simple WSGI app to recieve ``/stop``, ``/start`` and
``/restart`` instructions
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""A specific implementation, using redis_ for persistence.
.. _redis: http://code.google.com/p/redis/
"""
from base import BaseConsumer, BaseManager, BaseWSGIApp
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""`Twitter Streaming API`_ consumer based on tweepy_.
Consumer runs asynronously in a thread. Exposes a Tornado_
web server with two request handlers:
* ``/update`` either starts or restarts the consumer
* ``/stop`` stops the consumer
SHARETHIS.addEntry({}, {button: false}).attachButton(document.getElementById('share-this-button'));
class MultiDBModel(Document):
"""Overwrites methods of the base ``Document`` class that
prescribe a fixed mapping between class and database.
Can be used like normal but can also pass ``db=...``
to methods as necessary.
"""
def save(self, db=None, **params):
""" Save document in database.
/*
for(id key in searchControlsDict) {
[[searchControlsDict objectForKey:key] setObject:[NSMutableArray [[[searchControlsDict objectForKey:key] objectForKey:VALUES]] forKey:VALUES] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
}
*/
for(id key in searchControlsDict) {
NSMutableArray *tempValues = [[NSMutableArray alloc] initWithCapacity:0];
tempValues = [[searchControlsDict objectForKey:key] objectForKey:VALUES];