Skip to content

Instantly share code, notes, and snippets.

Avatar
🐉
Watching the chamaeleon.

Michael Hunger jexp

🐉
Watching the chamaeleon.
View GitHub Profile
View esc-1975-2019.csv
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;
@jexp
jexp / gol-create.adoc
Last active Apr 13, 2022
game of life in neo4j
View gol-create.adoc
@jexp
jexp / mushroom.csv
Last active Apr 6, 2022
mushroom color values
View mushroom.csv
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 Mar 21, 2022
Stackoverflow API to CSV Scripts
View load-so.cypher
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 Mar 15, 2022
neo4j movies javascript example
View movies.js
/* 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 Mar 14, 2022
pi-graph Represent the digits of π as a graph
View pi-graph-pairs.cypher
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);
View borders.csv
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
View _wordle.cypher
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 Jan 31, 2022
Simple GEDCOM to CSV converter
View gedcom2csv.py
#!/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 Dec 22, 2021
Select Average Value of Records with a Max Date in Cypher
View cypher-avg-value-max-date.md

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