Skip to content

Instantly share code, notes, and snippets.

@mneedham
mneedham / app.py
Last active Aug 16, 2021
Mapping Strava runs using Leaflet and Open Street Map
View app.py
from flask import Flask
from flask import render_template
import csv
import json
app = Flask(__name__)
@app.route('/')
def my_runs():
runs = []
@mneedham
mneedham / app.py
Last active Jul 20, 2021
Streamlit/Pinot - dynamic selection of metric and time range
View app.py
import streamlit as st
from pinotdb import connect
import pandas as pd
import time
st.title("GitHub Events")
broker_port = 8000
conn = connect(host='localhost', port=broker_port, path='/query/sql', scheme='http')
@mneedham
mneedham / app.py
Last active Jul 20, 2021
Pinot queries rendered in Streamlit
View app.py
import streamlit as st
from pinotdb import connect
import pandas as pd
st.title("GitHub Events")
broker_port = 8000
conn = connect(host='localhost', port=broker_port, path='/query/sql', scheme='http')
query = f"""
@mneedham
mneedham / app.py
Last active Jul 20, 2021
Basic Pinot query rendered in Streamlit
View app.py
import streamlit as st
from pinotdb import connect
import pandas as pd
st.title("GitHub Events")
broker_port = 8000
conn = connect(host='localhost', port=broker_port, path='/query/sql', scheme='http')
query = f"""
@mneedham
mneedham / app.py
Created Jul 20, 2021
Streamlit app
View app.py
import streamlit as st
st.title("GitHub Events")
st.write("Welcome to our first Streamlit app")
@mneedham
mneedham / docker-compose.yml
Created Jul 19, 2021
Apache Pinot GitHubEventsQuickStart
View docker-compose.yml
version: '3'
services:
pinot:
image: apachepinot/pinot:0.7.1
command: "GitHubEventsQuickStart -personalAccessToken ${GITHUB_TOKEN}"
container_name: "pinot-github-events-quick-start"
ports:
- "9000:9000"
- "8000:8000"
@mneedham
mneedham / ppr.py
Created Jul 18, 2018
Personalized PageRank using networkx
View ppr.py
# Dataset from https://blogs.oracle.com/bigdataspatialgraph/intuitive-explanation-of-personalized-page-rank-and-its-application-in-recommendation
import operator
import networkx as nx
G = nx.Graph()
G.add_nodes_from(["John", "Mary", "Jill", "Todd",
"iPhone5", "Kindle Fire", "Fitbit Flex Wireless", "Harry Potter", "Hobbit"])
View bumpme
Mon May 17 14:35:19 UTC 2021
@mneedham
mneedham / import.cql
Last active May 4, 2021
Neo4j Twitter Graph
View import.cql
CREATE CONSTRAINT ON(u:User)
ASSERT u.id IS unique;
:param keysToKeep => ["name", "username", "bio", "following", "followers"];
CALL apoc.load.json("https://gist.github.com/mneedham/3c6a59fb5e7d87e20a2f5f1ae4fa2920/raw/9d7c57997c09b3a105556adb6c6f1819792a4db4/query.json")
YIELD value
MERGE (u:User {id: value.user.id })
SET u += value.user
FOREACH (following IN value.following |
MERGE (f1:User {id: following})
MERGE (u)-[:FOLLOWS]->(f1))
@mneedham
mneedham / VagueRelationshipTypes.java
Last active Feb 28, 2021
All different ways of searching relationships in Neo4j
View VagueRelationshipTypes.java
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.DynamicLabel;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.GraphDatabaseService;