Skip to content

Instantly share code, notes, and snippets.

View Giancarlos's full-sized avatar
:shipit:

Giancarlos Giancarlos

:shipit:
  • Winter Garden, FL
View GitHub Profile
@jaraco
jaraco / foo.py
Last active November 15, 2018 12:29
import functools
import collections
import cherrypy
class SelectedMethod:
"""
Descriptor allowing a series of handler methods to satisfy
a variety of behaviors based on the request method.
@jaychoo
jaychoo / gist:1246146
Created September 27, 2011 20:29
Use MongoDB connection in singleton style
from pymongo import Connection
class MongoCon(object):
__db = None
@classmethod
def get_connection(cls):
if cls.__db is None:
cls.__db = Connection()
return cls.__db