Skip to content

Instantly share code, notes, and snippets.

🐉
Watching the chamaeleon.

Michael Hunger jexp

🐉
Watching the chamaeleon.
View GitHub Profile
@jexp
jexp / luanda_leaks.cypher
Created Feb 4, 2020
Luanda Leaks Load Script for Neo4j
View luanda_leaks.cypher
create constraint on (j:Jurisdiction) assert j.name is unique;
create constraint on (i:Industry) assert i.name is unique;
create constraint on (c:Company) assert c.id is unique;
create constraint on (c:Company) assert c.name is unique;
call apoc.load.csv('https://bit.ly/luanda-data') yield map as row
with apoc.map.clean(row,[],['N/A','Still active','?','Unknown']) as row
create (c:Company {id:row.`ICIJ company #`})
set c.name = row.`Company name`,
c.nameChangeDate=row.`Date of Company name change (MM/DD/YYYY)`,
View create-constraints.cypher
create constraint on (u:User) assert u.screen_name is unique;
create constraint on (t:Tweet) assert t.id is unique;
create constraint on (t:Tag) assert t.name is unique;
create constraint on (l:Link) assert l.url is unique;
create constraint on (t:Tag) assert t.name is unique;
@jexp
jexp / rdbms2graph.groovy
Created Nov 13, 2019
Transfer Data from an RDBMS via JDBC to any Neo4j DB
View rdbms2graph.groovy
@GrabConfig( systemClassLoader=true )
@Grapes([
@Grab(group='org.postgresql', module='postgresql', version='42.0.0'),
@Grab(group='org.neo4j.driver', module='neo4j-java-driver', version='1.7.5')
])
import org.neo4j.driver.v1.*;
import java.sql.*;
Class.forName("org.postgresql.Driver");
@jexp
jexp / empty-aura-db.sh
Created Nov 9, 2019
Truncate Neo4j Aura Cloud Database
View empty-aura-db.sh
#!/bin/bash
if [ ! -f bin/neo4j-admin ]; then echo "Please change to the Neo4j Installation directory!!"; exit 1; fi
echo "Have your password and Neo4j Aura Cloud Database Bolt URL ready!"
echo "This will override your cloud database with an empty one!!!"
echo "If you don't want that press <ctrl-c>, otherwise <enter>"
echo
read
if [ ! -f plugins/neo4j-push-to-cloud-3.jar ]; then
echo "Downloading push-to-cloud jar"
@jexp
jexp / import.cypher
Last active Nov 6, 2019
neo4j.com/online-summit schedule
View import.cypher
LOAD CSV WITH HEADERS FROM 'https://gist.githubusercontent.com/jexp/f64f18cf7e88fee77770207bb5ded0f7/raw/2695e44efbead3154c57c0198650bcde540e357a/nodes-2019.csv'
AS row FIELDTERMINATOR ';'
WITH row WHERE NOT row.slug IS NULL
MERGE (t:Talk {slug: row.slug})
SET t += row {.title, start:datetime({epochMillis:apoc.date.parse(row.start,'ms','dd.MM.yyyy hh:mm a')}), end:datetime({epochMillis:apoc.date.parse(row.end,'ms','dd.MM.yyyy hh:mm a')}), .type, .description, .level}
FOREACH (name IN split(row.speakers, ',') |
MERGE (s:Speaker {name: name})
SET s.company = row.company
MERGE (s)-[:PRESENTS]->(t)
)
@jexp
jexp / stackoverflow-schema.graphql
Created Jun 24, 2019
StackOverflow GraphQL Schema
View stackoverflow-schema.graphql
type Tag {
name: String!
questions: [Question] @relation(name: "TAGGED", direction: "IN")
}
type Answer {
createdAt: DateTime
downVotes: Int
id: Int!
link: String
@jexp
jexp / stackoverflow2graph.cypher
Created Jun 24, 2019
Stackoverflow Import for Neo4j
View stackoverflow2graph.cypher
with "graphql" as tagName
unwind range(1,10) as page
CALL apoc.load.json("https://api.stackexchange.com/2.2/questions?page="+page+"&pagesize=100&order=desc&sort=creation&tagged="+tagName+"&site=stackoverflow&filter=!5-i6Zw8Y)4W7vpy91PMYsKM-k9yzEsSC1_Uxlf") YIELD value
call apoc.util.sleep(200)
UNWIND value.items AS q
with * where not q.question_id is null
MERGE (question:Question {id:q.question_id})
SET question.title = q.title, question.link = q.share_link, question.favorites = q.favorite_count, question.upVotes = q.up_vote_count, question.downVotes = q.down_vote_count, question.text = q.body_markdown, question.answered = q.is_answered,
question.createdAt = datetime({epochSeconds:q.creation_date})
@jexp
jexp / .env
Created Jun 17, 2018
grandstack-starter StackOverflow
View .env
NEO4J_URI=bolt://107.170.69.23:7687
NEO4J_USER=graphql
NEO4J_PASSWORD=graphql
GRAPHQL_URI=http://localhost:4000
View index.html
<head>
<style> body { margin: 0; } </style>
<script src="//unpkg.com/3d-force-graph"></script>
<script src="//cdn.rawgit.com/neo4j/neo4j-javascript-driver/1.2/lib/browser/neo4j-web.min.js"></script>
<!--<script src="../../dist/3d-force-graph.js"></script>-->
</head>
<body>
<div id="3d-graph"></div>
@jexp
jexp / mapping-metaphor-neo4j.adoc
Last active Jan 9, 2018
Importing Mapping Metaphor into Neo4j
View mapping-metaphor-neo4j.adoc

Importing Mapping Metaphor into Neo4j

I came across this tweet, which sounded really interesting.

@MappingMetaphor: Metaphor Map now complete! Remaining data now up, and showing nearly 12,000 metaphorical connections: http://mappingmetaphor.arts.gla.ac.uk/

The site is really nice, with a pretty data visualization:

You can’t perform that action at this time.