This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import time | |
from TwitterAPI import TwitterAPI | |
# This is the object that we will use to send the request to Twitter | |
# A request is a HTTP request, just like your browser does when it goes to a website! | |
api = TwitterAPI(consumer_key, consumer_secret, access_token_key, | |
access_token_secret) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Simple benchmark based on aiohttp benchmark client. | |
https://github.com/KeepSafe/aiohttp/blob/master/benchmark/async.py | |
""" | |
import argparse | |
import asyncio | |
import collections | |
import random | |
import aiogremlin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
host: localhost | |
port: 8182 | |
threadPoolWorker: 4 | |
gremlinPool: 16 | |
scriptEvaluationTimeout: 30000 | |
serializedResponseTimeout: 30000 | |
channelizer: com.tinkerpop.gremlin.server.channel.WebSocketChannelizer | |
graphs: { | |
g: conf/titan-berkeleydb.properties} | |
plugins: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@csrf_exempt | |
def pdf_gen_view(request, graph_slug, template_slug): | |
def render(request, graph_slug, template_slug): | |
graph = get_object_or_404(Graph, slug=graph_slug) | |
template = get_object_or_404(ReportTemplate, slug=template_slug) | |
queries = template.queries.all() | |
queries = [{'series': query.execute(headers=True), 'name': query.name, | |
'id': query.id, 'results': query.query_dict['results']} | |
for query in queries] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import json | |
from tornado import escape, gen | |
from tornado.web import RequestHandler, Application, url | |
from tornado.platform.asyncio import AsyncIOMainLoop | |
from gizmo import AsyncGremlinClient | |
class GremlinHandler(RequestHandler): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE INDEX ON :Author(id); | |
CREATE INDEX ON :Paper(id); | |
USING PERIODIC COMMIT | |
LOAD CSV FROM "file:///home/davebshow/git/projx/data/opsahl-collaboration/out.opsahl-collaboration" | |
AS line FIELDTERMINATOR " " | |
MERGE (author:Author {id: line[0]}) | |
MERGE (paper:Paper {id: line[1]}) | |
MERGE (author)-[:WROTE]-(paper); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import pickle | |
import random | |
def write_schema(graph, filename): | |
s = NX2SylvaSchemaConverter(graph) | |
s.build_schemas(filename) | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Recursive | |
%timeit parser.parseString('MATCH (c:City)-[l:lives_in]-(p:Person) TRANSFER ATTRS (c)-(p)') | |
1000 loops, best of 3: 1.7 ms per loop | |
%timeit parser.parseString('MATCH (p1:Person)-[l1:lives_in]-(c:City)-[l:lives_in]-(p:Person) TRANSFER ATTRS (c)-(p1) PROJECT (p1)-(c)-(p2)') | |
100 loops, best of 3: 3.22 ms per loop | |
# Recursive pattern. | |
%timeit parser.parseString('MATCH (c:City)-[l:lives_in]-(p:Person) TRANSFER ATTRS (c)-(p)')1000 loops, best of 3: 1.58 ms per loop |