$ brew install apache-spark
A python shell with a preconfigured SparkContext (available as sc
). It is
import signal | |
class GracefulInterruptHandler(object): | |
def __init__(self, sig=signal.SIGINT): | |
self.sig = sig | |
def __enter__(self): | |
self.interrupted = False |
from MySQLdb.cursors import SSDictCursor | |
def iterate_query(query, connection, arraysize=1): | |
c = connection.cursor(cursorclass=SSDictCursor) | |
c.execute(query) | |
while True: | |
nextrows = c.fetchmany(arraysize) | |
if not nextrows: | |
break |
#!/usr/bin/env python | |
from gevent import monkey | |
monkey.patch_all() # Patch everything | |
import gevent | |
import time | |
class Hub(object): | |
"""A simple reactor hub... In async!""" |
from pyelasticsearch import ElasticSearch, ElasticHttpNotFoundError | |
from pyparsing import * | |
import unittest | |
ELASTICSEARCH_INDEX = 'myindex' | |
ELASTICSEARCH_URL = 'http://localhost:9200/' | |
es = ElasticSearch(ELASTICSEARCH_URL) |
from pyparsing import * | |
import unittest | |
class Node(list): | |
def __eq__(self, other): | |
return list.__eq__(self, other) and self.__class__ == other.__class__ | |
def __repr__(self): | |
return '%s(%s)' % (self.__class__.__name__, list.__repr__(self)) |
import collections | |
import MySQLdb as dbapi | |
__all__ = ['MySql'] | |
class MySql(object): | |
def __init__(self, **kwargs): | |
self.connection = dbapi.connect(**kwargs) | |
self.host_name = kwargs.get('host') |