Skip to content

Instantly share code, notes, and snippets.

Mark Needham mneedham

Block or report user

Report or block mneedham

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mneedham
mneedham / import.cql
Last active Sep 30, 2019
Importing Fashion MNIST
View import.cql
WITH "https://gist.github.com/mneedham/49aa07b8842718f5101585777e306009/raw/80b9299b26e165acc38ed0d83c9ab44c7137da3b/small_export.csv" AS uri
CALL apoc.load.csv(uri, {header: false, sep: " "})
YIELD lineNo, list
MERGE (item:MNISTItem {id: lineNo})
ON CREATE
SET item.embedding = [item in list | apoc.convert.toFloat(item)]
@mneedham
mneedham / 00_small_export.csv
Last active Sep 30, 2019
Importing Fashion MNIST into Neo4j
View 00_small_export.csv
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.00000
@mneedham
mneedham / SpendingByLeague.graphql
Created Aug 29, 2019
Football Transfers Graph GRANDstack App
View SpendingByLeague.graphql
type SpendingByLeague {
league: String
leagueImage: String
country: String
countryImage: String
moneySpent: Int
moneyReceived: Int
profit: Int
}
@mneedham
mneedham / Query.graphql
Last active Aug 29, 2019
Football Transfers Graph GRANDstack App
View Query.graphql
type Query {
spendingByLeague(countrySubstring: String = ""): [SpendingByLeague]
@cypher(
statement: """MATCH (league:League)-[:IN_COUNTRY]->(country:Country)
WHERE country.name CONTAINS $countrySubstring
WITH country, league,
apoc.coll.sumLongs([(league)<-[:IN_LEAGUE]-(club)<-[:TO_CLUB]-(t) | t.value]) AS moneyOut,
apoc.coll.sumLongs([(league)<-[:IN_LEAGUE]-(club)<-[:FROM_CLUB]-(t) | t.value]) AS moneyIn
RETURN { league: league.name, leagueImage: league.image, country: country.name, countryImage: country.image, moneySpent: moneyOut, moneyReceived: moneyIn, profit: moneyIn - moneyOut}"""
)
@mneedham
mneedham / SpendingByLeague.graphql
Created Aug 29, 2019
Football Transfers Graph GRANDstack App
View SpendingByLeague.graphql
type SpendingByLeague {
league: String
leagueImage: String
country: String
countryImage: String
moneySpent: Int
moneyReceived: Int
profit: Int
}
@mneedham
mneedham / 00_install.sh
Last active May 29, 2019
Getting Neo4j Tweets
View 00_install.sh
pip install --upgrade -e git+https://github.com/twintproject/twint.git@origin/master#egg=twint
pip install confluent-kafka[avro]
@mneedham
mneedham / import.cql
Last active Jun 1, 2019
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 / query.json
Created May 14, 2019
Neo4j Twitter Graph
View query.json
create constraint on (u:User)
ASSERT u.id IS unique
:param keysToKeep => ["name", "username", "bio", "following", "followers"];
CALL apoc.load.json("http://localhost:8000/query.json")
YIELD value
MERGE (u:User {id: value.user.id })
SET u += apoc.map.fromLists($keysToKeep, apoc.map.values(value.user, $keysToKeep))
FOREACH (following IN value.following |
MERGE(f1:User {id: following})
MERGE (u)-[:FOLLOWS]->(f1)
View Followers.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mneedham
mneedham / gh_releases.py
Created Apr 7, 2019
Get the downloads of a GitHub Releases Project
View gh_releases.py
import requests
import json
import os
query = """
query($owner:String!, $name: String!) {
repository(owner: $owner, name: $name) {
nameWithOwner
releases(first: 50, orderBy: {field:CREATED_AT, direction:DESC}) {
totalCount
You can’t perform that action at this time.