├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE.txt ├── README.md ├── app.py ├── app.yaml ├── batch.py ├── config.template ├── container.yaml.template ├── libs ├── apiclient │ ├── __init__.py │ ├── channel.py │ ├── discovery.py │ ├── errors.py │ ├── http.py │ ├── mimeparse.py │ ├── model.py │ ├── sample_tools.py │ └── schema.py ├── config.py ├── gnippy │ ├── __init__.py │ ├── config.py │ ├── errors.py │ ├── powertrackclient.py │ ├── rules.py │ └── searchclient.py ├── httplib2 │ ├── __init__.py │ ├── cacerts.txt │ ├── iri2uri.py │ └── socks.py ├── oauth2client │ ├── __init__.py │ ├── anyjson.py │ ├── appengine.py │ ├── client.py │ ├── clientsecrets.py │ ├── crypt.py │ ├── django_orm.py │ ├── file.py │ ├── gce.py │ ├── keyring_storage.py │ ├── locked_file.py │ ├── multistore_file.py │ ├── old_run.py │ ├── tools.py │ ├── util.py │ └── xsrfutil.py ├── requests │ ├── __init__.py │ ├── adapters.py │ ├── api.py │ ├── auth.py │ ├── certs.py │ ├── compat.py │ ├── cookies.py │ ├── exceptions.py │ ├── hooks.py │ ├── models.py │ ├── packages │ │ ├── __init__.py │ │ ├── charade │ │ │ ├── __init__.py │ │ │ ├── big5freq.py │ │ │ ├── big5prober.py │ │ │ ├── chardistribution.py │ │ │ ├── charsetgroupprober.py │ │ │ ├── charsetprober.py │ │ │ ├── codingstatemachine.py │ │ │ ├── compat.py │ │ │ ├── constants.py │ │ │ ├── cp949prober.py │ │ │ ├── escprober.py │ │ │ ├── escsm.py │ │ │ ├── eucjpprober.py │ │ │ ├── euckrfreq.py │ │ │ ├── euckrprober.py │ │ │ ├── euctwfreq.py │ │ │ ├── euctwprober.py │ │ │ ├── gb2312freq.py │ │ │ ├── gb2312prober.py │ │ │ ├── hebrewprober.py │ │ │ ├── jisfreq.py │ │ │ ├── jpcntx.py │ │ │ ├── langbulgarianmodel.py │ │ │ ├── langcyrillicmodel.py │ │ │ ├── langgreekmodel.py │ │ │ ├── langhebrewmodel.py │ │ │ ├── langhungarianmodel.py │ │ │ ├── langthaimodel.py │ │ │ ├── latin1prober.py │ │ │ ├── mbcharsetprober.py │ │ │ ├── mbcsgroupprober.py │ │ │ ├── mbcssm.py │ │ │ ├── sbcharsetprober.py │ │ │ ├── sbcsgroupprober.py │ │ │ ├── sjisprober.py │ │ │ ├── universaldetector.py │ │ │ └── utf8prober.py │ │ └── urllib3 │ │ │ ├── __init__.py │ │ │ ├── _collections.py │ │ │ ├── connectionpool.py │ │ │ ├── contrib │ │ │ ├── __init__.py │ │ │ ├── ntlmpool.py │ │ │ └── pyopenssl.py │ │ │ ├── exceptions.py │ │ │ ├── fields.py │ │ │ ├── filepost.py │ │ │ ├── packages │ │ │ ├── __init__.py │ │ │ ├── ordered_dict.py │ │ │ ├── six.py │ │ │ └── ssl_match_hostname │ │ │ │ └── __init__.py │ │ │ ├── poolmanager.py │ │ │ ├── request.py │ │ │ ├── response.py │ │ │ └── util.py │ ├── sessions.py │ ├── status_codes.py │ ├── structures.py │ └── utils.py └── uritemplate │ └── __init__.py ├── load.py ├── logging.conf ├── queue.yaml ├── requirements.txt ├── schema ├── sample_tweet_gnip.json ├── sample_twet_twitter.json ├── schema_gnip.json └── schema_twitter.json ├── screenshot.png ├── setup.py ├── static ├── css │ ├── c3.css │ ├── c3.min.css │ ├── style.css │ ├── theme │ │ ├── bootstrap.min.css │ │ └── styles.css │ └── tipsy.css ├── img │ ├── bird.ico │ ├── bird_large.png │ ├── config_fields.png │ ├── loading.gif │ ├── screenshot.png │ ├── settings_1.png │ └── settings_2.png └── js │ ├── bootstrap.min.js │ ├── c3.js │ ├── c3.min.js │ ├── d3.js │ ├── jquery.tipsy.js │ ├── mustache.js │ └── script.js ├── templates ├── admin.html ├── base.html ├── chart_partial.html ├── home.html ├── rule_add_partial.html ├── rule_list.html ├── table_detail.html └── table_list.html └── utils.py /.dockerignore: -------------------------------------------------------------------------------- 1 | data/* 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # C extensions 4 | *.so 5 | 6 | # Packages 7 | *.egg 8 | *.egg-info 9 | dist 10 | build 11 | eggs 12 | parts 13 | bin 14 | var 15 | sdist 16 | develop-eggs 17 | .installed.cfg 18 | lib 19 | lib64 20 | __pycache__ 21 | .build 22 | 23 | # Installer logs 24 | pip-log.txt 25 | 26 | # Unit test / coverage reports 27 | .coverage 28 | .tox 29 | nosetests.xml 30 | 31 | # Translations 32 | *.mo 33 | 34 | # Mr Developer 35 | client_secrets.json 36 | .project 37 | .pydevproject 38 | *.p12 39 | *.pem 40 | **/*json 41 | **/*conf 42 | **/*txt 43 | config 44 | container.yaml 45 | schema.json 46 | output.txt 47 | *.sh 48 | data/* 49 | fabfile.py 50 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM google/python 2 | 3 | RUN apt-get install -y libffi-dev 4 | 5 | RUN pip install --upgrade pip 6 | RUN pip install config 7 | RUN pip install tweepy 8 | RUN pip install bigquery-python 9 | RUN pip install --upgrade google-api-python-client 10 | 11 | ADD config /config 12 | ADD schema /schema 13 | ADD key.p12 /key.p12 14 | ADD logging.conf /logging.conf 15 | ADD libs /libs 16 | ADD utils.py /utils.py 17 | ADD load.py /load.py 18 | 19 | CMD python load.py 20 | -------------------------------------------------------------------------------- /app.yaml: -------------------------------------------------------------------------------- 1 | # https://cloud.google.com/appengine/docs/python/modules/ 2 | application: twitter-gnip 3 | version: 1 4 | runtime: python27 5 | api_version: 1 6 | threadsafe: true 7 | 8 | handlers: 9 | - url: /static 10 | static_dir: static 11 | 12 | - url: /.* 13 | script: app.application 14 | 15 | libraries: 16 | - name: jinja2 17 | version: latest 18 | - name: pycrypto 19 | version: latest 20 | - name: ssl 21 | version: latest 22 | 23 | skip_files: 24 | - ^data$ 25 | -------------------------------------------------------------------------------- /batch.py: -------------------------------------------------------------------------------- 1 | import os 2 | from os import walk 3 | import sys 4 | import thread 5 | import gzip 6 | from multiprocessing import Pool, Process, Queue 7 | 8 | PROCESS_COUNT = 8 9 | 10 | # file utilities 11 | class Utils: 12 | 13 | @staticmethod 14 | def rename(file, to): 15 | 16 | call_rename = "mv %s %s" % (file, to) 17 | print call_rename 18 | os.system(call_rename) 19 | 20 | return to 21 | 22 | @staticmethod 23 | def archive(file): 24 | 25 | if ".archive" in file: 26 | return file 27 | 28 | file_archive = "%s.archive" % file 29 | Utils.rename(file, file_archive) 30 | 31 | return file_archive 32 | 33 | @staticmethod 34 | def unarchive(file): 35 | 36 | if ".archive" not in file: 37 | return file 38 | 39 | file2 = file[:-8] 40 | Utils.rename(file, file2) 41 | 42 | return file2 43 | 44 | @staticmethod 45 | def gzip(file): 46 | 47 | if ".gz" in file: 48 | return file 49 | 50 | call_zip = "gzip %s" % (file) 51 | print call_zip 52 | os.system(call_zip) 53 | 54 | return "%s.gz" % file 55 | 56 | @staticmethod 57 | def gunzip(file): 58 | 59 | if ".gz" not in file: 60 | return file 61 | 62 | call_unzip = "gunzip %s" % (file) 63 | print call_unzip 64 | os.system(call_unzip) 65 | 66 | return file[:-3] 67 | 68 | @staticmethod 69 | def cat_all(path, file): 70 | 71 | call_cat = "find %s -type f -exec cat {} + > %s" % (path, file) 72 | print call_cat 73 | os.system(call_cat) 74 | 75 | @staticmethod 76 | def get_files(path): 77 | 78 | files = [] 79 | 80 | # process all files and let async handle archiving 81 | for (dirpath, dirnames, filenames) in walk(path): 82 | for f in filenames: 83 | file = "%s/%s" % (dirpath, f) 84 | files.append(file) 85 | 86 | return files 87 | 88 | # restore file to original gzip 89 | def reset_file(file, table, output=None): 90 | 91 | if ".archive" in file: 92 | file = Utils.unarchive(file) 93 | 94 | # ignore archive files 95 | if file.endswith(".json"): 96 | file = Utils.gzip(file) 97 | 98 | if output: 99 | output.put(file) 100 | 101 | return file 102 | 103 | def process_files(path, table): 104 | 105 | files = Utils.get_files(path) 106 | 107 | # if zipped, unzip for loading 108 | for f in files: 109 | if "json.gz" in f: 110 | file = Utils.gunzip(f) 111 | 112 | # get new list of files 113 | files = Utils.get_files(path) 114 | 115 | file_result = "master.json" 116 | Utils.cat_all(path, file_result) 117 | 118 | file_gz = Utils.gzip(file_result) 119 | 120 | # load to bigquery 121 | call_batch = "bq load --source_format=NEWLINE_DELIMITED_JSON --max_bad_records=500000 %s %s" % (table, file_result) 122 | print call_batch 123 | os.system(call_batch) 124 | 125 | return file_result 126 | 127 | if __name__ == '__main__': 128 | 129 | if len(sys.argv) != 4: 130 | print "Usage: batch.py [reset|process] [file|directory]
22 | | Rule | 23 |Dataset | 24 |HPT JSON
25 |
26 |
27 |
30 |
35 |
36 |
34 | |
37 |
---|
69 | | Rule | 70 |Dataset | 71 |HPT JSON | 72 |
---|
See unique users who have tweeted in this data set, and optionally import their tweets via new Gnip rules.
104 | Show unique users 105 | Add users to data set 106 | 107 |.
110 | 111 |User | 115 |Tweet Count | 116 |
---|
Delete all data from this table.
135 | Delete data 136 | 137 |View and manage BigQuery tables in your project.
13 | 14 |Table | 22 |Project | 23 |Type | 24 |Rules | 25 |Actions | 26 |
---|