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 / 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
@jexp
jexp / movies.js
Created March 15, 2022 10:18
neo4j movies javascript example
/* npm install --save neo4j-driver
node movies.js
export NEO4J_URI='neo4j+s://demo.neo4jlabs.com:7687'
export NEO4J_USER='mUser'
export NEO4J_PASSWORD='s3cr3t'
export NEO4J_DATABASE='movies'
*/
(async() => {
@jexp
jexp / pi-graph-pairs.cypher
Last active March 14, 2022 12:24
pi-graph Represent the digits of π as a graph
create constraint on (p:Pair) assert p.digits is unique;
// pi digits from https://github.com/eneko/Pi (we use 10k here) in pairs of 2
load csv from "https://raw.githubusercontent.com/eneko/Pi/master/Pi10KDP.txt" as row
with row[0] as digits
unwind range(0,size(digits)-4,2) as idx
merge (from:Pair {digits:substring(digits,idx,2)})
merge (to:Pair {digits:substring(digits,idx+2,2)})
merge (from)-[:NEXT {idx:idx}]->(to);
We can't make this file beautiful and searchable because it's too large.
Geo Point;Geo Shape;Status;ISO 3 country code;Region of the territory;ISO 3 territory code;Continent of the territory;English Name;ISO 3166-1 Alpha 2-Codes;French Name
43.94363973453168,12.45863291380937;"{""coordinates"": [[[12.409130000000062, 43.908420000000035], [12.403520000000071, 43.92092000000008], [12.408280000000047, 43.93387000000007], [12.401870000000088, 43.94944000000004], [12.405550000000062, 43.95431000000008], [12.417880000000082, 43.96079000000009], [12.432480000000055, 43.962950000000035], [12.441460000000063, 43.966260000000034], [12.463560000000086, 43.98267000000004], [12.51004000000006, 43.99981000000008], [12.515570000000082, 43.99566000000004], [12.498520000000042, 43.972290000000044], [12.499820000000057, 43.96225000000004], [12.50759000000005, 43.95335000000006], [12.484420000000057, 43.907610000000034], [12.458070000000077, 43.89791000000008], [12.450960000000066, 43.898750000000064], [12.444140000000061, 43.90351000000004], [12.437860000000057, 43.907170000000065], [12.42980000000
CREATE CONSTRAINT word_name IF NOT EXISTS ON (w:Word) ASSERT w.name IS UNIQUE;
CREATE CONSTRAINT cap_idx_char IF NOT EXISTS FOR (cap:CharAtPos) REQUIRE (cap.idx, cap.char) IS NODE KEY;
LOAD CSV FROM
"https://gist.githubusercontent.com/jexp/b1882301adb95a8015d6c29d3e24e341/raw/6fe6ac31b9ed46900451e17b5215e9088ec09a6e/wordle.csv" as row
MERGE (w:Word {name:row[0]});
:auto MATCH (w:Word)
CALL { WITH w
@jexp
jexp / gedcom2csv.py
Last active January 31, 2022 10:42
Simple GEDCOM to CSV converter
#!/usr/bin/python3
# usage: ./gedcom2csv.py file.get > file.csv
# https://pypi.org/project/python-gedcom/
import sys
from gedcom.element.individual import IndividualElement
from gedcom.parser import Parser
file_path = sys.argv[1]
gedcom_parser = Parser()
gedcom_parser.parse_file(file_path)
@jexp
jexp / cypher-avg-value-max-date.md
Created December 22, 2021 08:00
Select Average Value of Records with a Max Date in Cypher

Select Average Value of Records with a Max Date in Cypher

Question: Oddman

Hmmmm. How would I go about getting the average of a value for a given date, for all records? Ie. For all records on a given date, I want the highest value on that date, and then average that value across all the results.

in SQL, it'd be something like avg... select max... group by date

@jexp
jexp / sorted_path_expand.adoc
Last active December 11, 2021 13:42
Sorted Path Expand Question

Sorted Path Expansion by Node Property

Yesterday we got a question on Discord

Maxe — gestern um 19:40 Uhr

Hi folks,

I am searching for some way to expand a graph from one source node like with Apoc.path.expand. But I want to filter on each depth depending on properties.