Skip to content

Instantly share code, notes, and snippets.

View cowbert's full-sized avatar

PL cowbert

View GitHub Profile
@utkjad
utkjad / connect_to_pyhive_http_mode.py
Created December 18, 2017 20:23
Utility function to connect to Pyhive on HTTP mode.
from pyhive import hive
def connect_to_pyhive():
""" Connects to Pyhive with HTTP mode
"""
conn = hive.connect(thrift_transport=add_http_mode_support())
cursor = conn.cursor()
cursor.execute("show databases")
print cursor.fetchone()
@mminer
mminer / jsonhandler.py
Created April 26, 2013 02:36
A JSON request handler for Tornado.
import json
import tornado.web
class JsonHandler(BaseHandler):
"""Request handler where requests and responses speak JSON."""
def prepare(self):
# Incorporate request JSON into arguments dictionary.
if self.request.body:
try:
@aaronlevin
aaronlevin / gist:3217751
Created July 31, 2012 15:18
(potentially bad) Example of decorator defined as class method
class Density(object):
def __init__(self, data, bw=None):
""" class definitions
"""
self.maxmin['maxima'] = []
self.maxmin['minima'] = []
def new_values_for_maxmin_validator(method):
"""This is the decorator