Skip to content

Instantly share code, notes, and snippets.

Avatar
🐉
Watching the chamaeleon.

Michael Hunger jexp

🐉
Watching the chamaeleon.
View GitHub Profile
View loom.java
// sdk install java 20-open
// java -version
/*
openjdk version "20" 2023-03-21
OpenJDK Runtime Environment (build 20+36-2344)
OpenJDK 64-Bit Server VM (build 20+36-2344, mixed mode, sharing)
*/
// jshell --enable-preview --add-exports java.base/jdk.internal.vm=ALL-UNNAMED --add-modules=jdk.incubator.concurrent
View laureates.json
This file has been truncated, but you can view the full file.
{
"laureates": [
{
"id": "745",
"knownName": {
"en": "A. Michael Spence",
"se": "A. Michael Spence"
},
"givenName": {
"en": "A. Michael",
@jexp
jexp / aoc_day1.cypher
Last active December 4, 2022 12:15
Advent of Code 2022 in some languages
View aoc_day1.cypher
with split($input, "\n\n") as elves
unwind elves as elf
return reduce(s=0, c in split(elf,"\n") | s + toInteger(c)) as total
order by total desc limit 1;
with split($input, "\n\n") as elves
unwind elves as elf
with reduce(s=0, c in split(elf,"\n") | s + toInteger(c)) as total
order by total desc limit 3
@jexp
jexp / test-db
Created December 1, 2022 16:45
Neo4j single transaction testing using java core api and drivers, using https://jbang.dev
View test-db
///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
View aws-services-codes.json
{
"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
View aggregation-index.cypher
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
View 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
View architecture.tsv
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
View common_neo4j_cypher_problems.adoc

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

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;
1975;f;1975f;J;Belgium;Malta;7;