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 / test-db
Created December 1, 2022 16:45
Neo4j single transaction testing using java core api and drivers, using https://jbang.dev
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 17
//DEPS org.neo4j:neo4j:5.2.0
import static java.lang.System.*;
import org.neo4j.dbms.api.*;
import org.neo4j.graphdb.*;
import java.nio.file.Path;
import java.util.Map;
@jexp
jexp / aws-services-codes.json
Created November 28, 2022 15:47
AWS Services
{
"Services": [
{
"ServiceCode": "AWSCloudMap",
"ServiceName": "AWS Cloud Map"
},
{
"ServiceCode": "a4b",
"ServiceName": "Alexa for Business"
},
@jexp
jexp / aggregation-index.cypher
Last active September 27, 2022 14:47
Cypher Optimization for aggregation and compound indexes
unwind range(2010,2022) as year unwind range(1,365) as day create (d:Date {year:year, day:day});
// Added 4745 labels, created 4745 nodes, set 9490 properties, completed after 194 ms.
create index for (d:Date) on (d.year);
:auto unwind range(2010,2022) as year unwind range(1,365) as day match (d:Date {year:year, day:day})
unwind range(1, 1000) as id
call { with id,d
create (l:LineItem {revenue:rand()*1000, quantity:toInteger(rand()*100)})
create (l)-[:ON_DATE]->(d)
@jexp
jexp / bar-chart.cypher
Created September 1, 2022 14:54
bar chart cypher
with [x in range(1,10) | rand()] as values
return values as result;
/*
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| result |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [0.659425004010523, 0.8694425986764492, 0.9257514428672218, 0.953247608626841, 0.19473427486287131, 0.41928993743169174, 0.9691737560680762, 0.564805684330218, 0.5061905379193724, 0.5653656414569036] |
+--------------------------------------------------------------------------------------------------------------------------------------
@jexp
jexp / architecture.tsv
Last active August 29, 2022 07:32
Podcasts
URL Title
/series/ninety-nine-percent-invisible 99% Invisible
/series/new-books-in-architecture-2421478 New Books in Architecture
/series/rebuilding-the-renaissance Rebuilding The Renaissance
/series/blueprint-for-living-full-program-78888 Blueprint For Living - Full program
/series/kunstlercast-suburban-sprawl-a-tragic-comedy KunstlerCast - Suburban Sprawl: A Tragic Comedy
/series/business-of-architecture-podcast Business of Architecture Podcast
/series/failed-architecture Failed Architecture
/series/scaffold Scaffold
/series/on-the-bench-1522321 On The Bench
@jexp
jexp / common_neo4j_cypher_problems.adoc
Created July 15, 2022 00:17
Common Neo4j Cypher Problems and their Solutions

Most frequent issues in Cypher Statements

How can you prevent this? Check your statements before you run them, best with EXPLAIN that parses them without execution. Use Integration Tests, e.g. with Docker/Testcontainers to check your cypher queries against your current database/dataset.

Slow MERGE

MERGE fails on Null

We can't make this file beautiful and searchable because it's too large.
Year;(semi-) final;Edition;Jury or Televoting;From country;To country;Points ;Duplicate
1975;f;1975f;J;Belgium;Belgium;0;x
1975;f;1975f;J;Belgium;Finland;0;
1975;f;1975f;J;Belgium;France;2;
1975;f;1975f;J;Belgium;Germany;0;
1975;f;1975f;J;Belgium;Ireland;12;
1975;f;1975f;J;Belgium;Israel;1;
1975;f;1975f;J;Belgium;Italy;6;
1975;f;1975f;J;Belgium;Luxembourg;0;
1975;f;1975f;J;Belgium;Malta;7;
@jexp
jexp / gol-create.adoc
Last active April 13, 2022 10:34
game of life in neo4j
@jexp
jexp / mushroom.csv
Last active April 6, 2022 11:03
mushroom color values
0 0 none
1 0 none
2 0 none
3 0 none
4 0 none
5 0 black
6 0 black
7 0 black
8 0 black
9 0 black
@jexp
jexp / load-so.cypher
Last active March 21, 2022 08:16
Stackoverflow API to CSV Scripts
create constraint on (q:Question) assert q.id is unique;
create constraint on (u:User) assert u.id is unique;
create constraint on (t:Tag) assert t.name is unique;
create constraint on (a:Answer) assert a.id is unique;
create index on :Question(title);
create index on :User(display_name);
WITH "https://api.stackexchange.com/2.2/questions?pagesize=100&order=desc&sort=creation&tagged=neo4j&site=stackoverflow&filter=!5-i6Zw8Y)4W7vpy91PMYsKM-k9yzEsSC1_Uxlf" AS url
CALL apoc.load.json(url) YIELD value
UNWIND value.items AS q