Skip to content

Instantly share code, notes, and snippets.

Avatar
🐉
Watching the chamaeleon.

Michael Hunger jexp

🐉
Watching the chamaeleon.
View GitHub Profile
@jexp
jexp / 01-load.cypher
Last active Jul 6, 2021
Wahlomat Daten Sachsen Anhalt 2021
View 01-load.cypher
create index on :Partei(name);
create index on :These(name);
create constraint if not exists on (p:Partei) assert p.id is unique;
create constraint if not exists on (t:These) assert t.id is unique;
load csv with headers from
"https://gist.github.com/jexp/189e9d7a47095ff96ff522fe350f0d36/raw/fa2f356514ec981067856ad7a5f6dfb017122c8d/wom-sa-2021.csv"
as row
merge (p:Partei {id:toInteger(row.`Partei: Nr.`)}) on create set p.text = row.`Partei: Name`, p.name = row.`Partei: Kurzbezeichnung`
View movies.cypher
//Movies based on similar users and favorite genres
MATCH (u:Users)-[:WATCHED]->(m:Movies)
WHERE u.userId ='1'
WITH collect(m) as watchedMovies
MATCH (u:Users)-[:WATCHED]->(m1:Movies)-[s:SIMILAR]->(m2:Movies),
(m2)-[:GENRES]->(g:Genres), (u)-[:FAVORITE]->(g)
WHERE u.userId ='10' and m2 IN watchedMovies
RETURN distinct u.userId as userId, g.genres as genres, m2.title as title, m2.rating_mean as rating
@jexp
jexp / giphy.py
Created Jun 8, 2021
Random Giphy images in Jupyter notebook to keep your audience entertained while they wait for data processing
View giphy.py
!pip install giphy_client
import giphy_client
import random
from IPython.core.display import display, HTML
api_instance = giphy_client.DefaultApi()
api_key = '***' # from https://developers.giphy.com/dashboard/
search = 'science'
api_response = api_instance.gifs_search_get( api_key, search, limit=25)
images = [img.images.fixed_height.url for img in api_response.data]
@jexp
jexp / dependencies.cypher
Last active Jun 4, 2021
Google deps.dev to #Neo4j graph on dev.neo4j.com/sandbox
View dependencies.cypher
// load initial package, adjust your name and version
with "org.neo4j:neo4j-kernel" as name, '4.2.6' as version
call apoc.load.json("https://deps.dev/_/s/maven/p/"+name+"/v/"+version+"/dependencies") yield value
where value.package.system = 'MAVEN'
merge (p:Package:Maven {name:value.package.name, version:value.version})
with *
unwind value.dependencies as dep
with p, dep where dep.package.system = 'MAVEN'
merge (d:Package:Maven {name:dep.package.name, version:dep.version})
View lombardi.cypher
call apoc.load.json("https://lombardinetworks.net/network/1027/1027.json") yield value
unwind value.nodes as n
call apoc.create.node([split(n.type,'#')[1]], n {.id, .name}) yield node
with value, apoc.map.groupBy(collect(node),"id") as nodes
unwind value.links as r
call apoc.create.relationship(nodes[r.source],split(r.type,'#')[1], {amount:toFloat(r.amount)},nodes[r.target]) yield rel
return count(*);
@jexp
jexp / transcript.txt
Created Apr 2, 2021
Devrel twitter space hoste by Colby with Angie, Sarah, Kelsey, Emily, James
View transcript.txt
Dev Rel
Don’t sound smart
Help others feels smart
Break thinks down to simple bits
Developer empathy
Not just for senior audiences
Netlify - docs, dx-eng, eng-integrations
Employee of community. Company is a sponsor
Ambassador progr.
@jexp
jexp / playlist.py
Last active Mar 16, 2021
Read correct YouTube Playlist views from the YT data API with Python (here Neo4j Twitch Stream videos)
View playlist.py
# -*- coding: utf-8 -*-
# https://developers.google.com/explorer-help/guides/code_samples#python
# pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
# python playlist.py
import os
import sys
import json
@jexp
jexp / load_nature_papers.cypher
Created Mar 10, 2021
Loading the cocited papers from the Nature visualisation into Neo4j https://www.nature.com/immersive/d41586-019-03165-4/index.html
View load_nature_papers.cypher
call apoc.load.csv('https://www.nature.com/immersive/d41586-019-03165-4/dat/data.zip!cociteNodes.csv',{})
yield map
create (p:Paper) set p =map {.NatureID, .PubYear, .Title, .HierCat, .size}
return count(*) as papers;
create index on :Paper(NatureID);
call db.awaitIndexes();
call apoc.load.csv('https://www.nature.com/immersive/d41586-019-03165-4/dat/data.zip!cociteEdges.csv',{ignore:['path']})
yield map
@jexp
jexp / categories.csv
Created Jan 27, 2021
Northwind CSV Files Neo4j Import
View categories.csv
CategoryID CategoryName Description Picture
1 Beverages Soft drinks, coffees, teas, beers, and ales \x
2 Condiments Sweet and savory sauces, relishes, spreads, and seasonings \x
3 Confections Desserts, candies, and sweet breads \x
4 Dairy Products Cheeses \x
5 Grains/Cereals Breads, crackers, pasta, and cereal \x
6 Meat/Poultry Prepared meats \x
7 Produce Dried fruit and bean curd \x
8 Seafood Seaweed and fish \x
View create-job-data.cypher
create constraint on (j:Job) assert j.id is unique;
// rows = [{id:1, name:"ddd"},{id:2,,}]
session.write_transaction(lambda tx:
tx.run("""
unwind $rows as row
merge (j:Job {id:row.id}) on create set j.name = row.name
""", rows=rows)
)
call apoc.periodic.iterate(
"call apoc.load.json(url) yield value return value",