Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Simons michael-simons

View GitHub Profile
@michael-simons
michael-simons / ApplicationTest2.java
Last active Nov 19, 2020
A couple of ways to load data into Neo4j (4) test container
View ApplicationTest2.java
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.GraphDatabase;
import org.testcontainers.containers.Neo4jContainer;
/**
* Creates everything from the test itself.
*
View Peng.java
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
@michael-simons
michael-simons / Server.java
Created Oct 12, 2020 — forked from nigjo/Server.java
A simple, insecure One-File-Java-Server to serve static pages. Main purpose is to have a simple server to locally test some github pages.
View Server.java
/*
* Copyright 2020 Jens "Nigjo" Hofschröer.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View reactive zeug.java
public static void main(String... a) throws Exception {
var driver = GraphDatabase.driver(
"bolt://localhost:7687",
AuthTokens.basic("neo4j", "secret"),
Config.builder().withLogging(Logging.console(Level.INFO)).build()
);
System.out.println("\nImperative transaction functions\n---");
Function<Record, String> getNameFromRecord = record -> record.get("name").asString();
View filter-repo-example
#!/bin/bash
git filter-repo --force \
--message-callback '
import re
return re.sub(rb"GH-\d+ - ", b"", message)
' \
--path .editorconfig \
--path .gitignore \
--path .mvn \
@michael-simons
michael-simons / wait_for_bolt.sh
Last active Jul 1, 2020
A bash script waiting for port 7687 to become available without netcat or similar.
View wait_for_bolt.sh
#!/bin/bash
until (exec 3<>/dev/tcp/127.0.0.1/7687) &>/dev/null; do
echo "Try again"
sleep 1s
done
View GraphApplication.java
package ac.simons.neo4j.twitch;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import org.neo4j.configuration.connectors.BoltConnector;
import org.neo4j.configuration.helpers.SocketAddress;
import org.neo4j.dbms.api.DatabaseManagementServiceBuilder;
View Parameter.kt
inline fun String.asParameter() = "\$" + this
infix fun String.Companion.asParameter(s: String) = "\$" + s
View gist:69d9c0ed3d98abed8673eb6fbe01b4ce
https://twitter.com/rotnroll666/status/735456236280393730
https://twitter.com/rotnroll666/status/734421673026392064
https://twitter.com/rotnroll666/status/839844535664578561
https://twitter.com/rotnroll666/status/757439545155649536
https://twitter.com/rotnroll666/status/682837938770685952
https://twitter.com/rotnroll666/status/702070054637150208
https://twitter.com/rotnroll666/status/713967198973337600
https://twitter.com/rotnroll666/status/974170243525431296
@michael-simons
michael-simons / batch-rsync.sh
Created Jan 24, 2020
zsh script for "batching" rsync of a large tree alphabetically
View batch-rsync.sh
#!/bin/zsh
for x in {a..z}
do
rsync --delete -cav --include="[${x}${x:u}]*/***" --exclude="*" /largeSourceFolder/ /Backup/
done
You can’t perform that action at this time.