Skip to content

Instantly share code, notes, and snippets.

View jexp's full-sized avatar
🐉
Watching the chamaeleon.

Michael Hunger jexp

🐉
Watching the chamaeleon.
View GitHub Profile
@jexp
jexp / 101_movies_query.graphql
Last active December 8, 2021 15:50
GraphQL Training Queries
{
movies(options: { limit: 10 }) {
title
actors {
name
}
}
}
@jexp
jexp / Html.java
Created October 3, 2021 22:54
Some https://jbang.dev examples for my JavaSpektrum article
//DEPS org.jsoup:jsoup:1.14.3
import static java.lang.System.*;
import org.jsoup.*;
public class Html {
public static void main(String...args) throws Exception {
var doc = Jsoup.connect(args[0]).get();
out.println(doc.title());
doc.select(args[1])
@jexp
jexp / 01-load.cypher
Last active July 6, 2021 09:44
Wahlomat Daten Sachsen Anhalt 2021
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`
//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 June 8, 2021 22:16
Random Giphy images in Jupyter notebook to keep your audience entertained while they wait for data processing
!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 January 5, 2023 13:09
Google deps.dev to #Neo4j graph on dev.neo4j.com/sandbox
// 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})
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 April 2, 2021 20:06
Devrel twitter space hoste by Colby with Angie, Sarah, Kelsey, Emily, James
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 October 14, 2023 23:04
Read correct YouTube Playlist views from the YT data API with Python (here Neo4j Twitch Stream videos)
# -*- 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 March 10, 2021 00:10
Loading the cocited papers from the Nature visualisation into Neo4j https://www.nature.com/immersive/d41586-019-03165-4/index.html
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