Skip to content

Instantly share code, notes, and snippets.

View mneedham's full-sized avatar

Mark Needham mneedham

View GitHub Profile
@mneedham
mneedham / ppr.py
Created July 18, 2018 10:10
Personalized PageRank using networkx
# 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"])
@mneedham
mneedham / blog_domain.py
Last active January 29, 2022 14:40
Altair - Setting a custom date domain for the x axis
# Code for https://markhneedham.com/blog/2020/01/14/altair-range-values-dates-axis/ blog post
import altair as alt
import pandas as pd
import datetime
df = pd.DataFrame( [
{"position": 40, "date": datetime.date(2019,9,5)},
{"position": 31, "date": datetime.date(2019,9,12)},
{"position": 19, "date": datetime.date(2019,9,19)},
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.apache.pinot:pinot-jdbc-client:0.8.0
//DEPS com.github.freva:ascii-table:1.2.0
// jbang Query.java "select * from customers limit 5"
// export JDBC_URL="jdbc:pinot://localhost:9000"
import static java.lang.System.*;
import java.sql.*;
import java.util.*;
@mneedham
mneedham / event.txt
Last active November 5, 2021 14:12
event.txt
event: message
id: [{"topic":"eqiad.mediawiki.recentchange","partition":0,"timestamp":1635935095001},{"topic":"codfw.mediawiki.recentchange","partition":0,"offset":-1}]
data: {"$schema":"/mediawiki/recentchange/1.0.0","meta":{"uri":"https://pl.wikipedia.org/wiki/Kategoria:Infoboksy_%E2%80%93_brakuj%C4%85ce_parametry_%E2%80%93_Jednostka_administracyjna_infobox","request_id":"45eb5803-f73b-410c-a640-c76c5d86d91f","id":"5a7ee8b2-fead-4d54-b6fc-4bb433a08e51","dt":"2021-11-03T10:24:55Z","domain":"pl.wikipedia.org","stream":"mediawiki.recentchange","topic":"eqiad.mediawiki.recentchange","partition":0,"offset":3410637559},"id":119002871,"type":"categorize","namespace":14,"title":"Kategoria:Infoboksy – brakujące parametry – Jednostka administracyjna infobox","comment":"usunięto [[:Sukhaura]] z kategorii","timestamp":1635935095,"user":"MalarzBOT","bot":true,"server_url":"https://pl.wikipedia.org","server_name":"pl.wikipedia.org","server_script_path":"/w","wiki":"plwiki","parsedcomment":"usunięto <a href=\"/wiki/Sukh
@mneedham
mneedham / app.py
Last active July 20, 2021 21:18
Streamlit/Pinot - dynamic selection of metric and time range
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 July 20, 2021 19:55
Pinot queries rendered in Streamlit
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 July 20, 2021 19:52
Basic Pinot query rendered in Streamlit
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 July 20, 2021 16:40
Streamlit app
import streamlit as st
st.title("GitHub Events")
st.write("Welcome to our first Streamlit app")
@mneedham
mneedham / docker-compose.yml
Created July 19, 2021 20:28
Apache Pinot GitHubEventsQuickStart
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"