Skip to content

Instantly share code, notes, and snippets.

import java.util.concurrent.ConcurrentHashMap
import java.util.{Set => JSet}
import scala.jdk.CollectionConverters._
import scala.util.Random
import scala.concurrent.{ExecutionContext, Future}
// https://github.com/alexandrnikitin/bloom-filter-scala
import bloomfilter.mutable.BloomFilter
import java.lang.invoke.*;
/* Problem: given an array of method handle, produce a method handle that will
*
* - use its first `int` argument to index into an array of method handles
* - call the extracted method handle with the second `int` argument
*
* Why is this interesting? Because we can use this sort of thing for a
* bootstrap `invokedynamic` method, for optimized indirect calls with an offset.
*/

Standing queries

Standing queries are defined with graph patterns. For the sake of convenience, we also provide an API option where you define the pattern you want to find using a Cypher query. For instance, suppose we want to match a pattern of a person and their two parents:

curl -X POST "http://localhost:8080/api/v1/query/standing/my_sq" \
  -H  "accept: */*" \
 -H "Content-Type: application/json" \
name gender birth_year
Lily Potter female 1960
James Potter male 1960
Molly Weasley female 1949
Arthur Weasley male 1950
Harry Potter male 1980
Ginny Weasley female 1981
Ron Weasley male 1980
Hermione Granger female 1979
James Sirius Potter male 2003
{ "name": "Lily Potter", "gender": "female", "birth_year": 1960, "children": ["Harry Potter"] }
{ "name": "James Potter", "gender": "male", "birth_year": 1960, "children": ["Harry Potter"] }
{ "name": "Molly Weasley", "gender": "female", "birth_year": 1949, "children": ["Ginny Weasley", "Ron Weasley"] }
{ "name": "Arthur Weasley", "gender": "male", "birth_year": 1950, "children": ["Ginny Weasley", "Ron Weasley"] }
{ "name": "Harry Potter", "gender": "male", "birth_year": 1980, "children": ["James Sirius Potter", "Albus Severus Potter", "Lily Luna"] }
{ "name": "Ginny Weasley", "gender": "female", "birth_year": 1981, "children": ["James Sirius Potter", "Albus Severus Potter", "Lily Luna"] }
{ "name": "Ron Weasley", "gender": "male", "birth_year": 1980, "children": ["Rose Weasley", "Hugo Weasley"] }
{ "name": "Hermione Granger", "gender": "female", "birth_year": 1979, "children": ["Rose Weasley", "Hugo Weasley"] }
{ "name"
@harpocrates
harpocrates / DebugDerivation.scala
Created April 22, 2020 22:27
Utility for debugging typeclass derivation
import $ivy.`com.chuusai::shapeless:2.3.3`
import $ivy.`io.spray::spray-json:1.3.5`
import shapeless._
import scala.reflect.runtime.universe.WeakTypeTag
import scala.collection.mutable
import spray.json._
sealed trait DataTypeDerivation {
def name: String
@harpocrates
harpocrates / rightClickUntilMouseMove.scala
Created March 4, 2020 03:58
Script for AFK-ing clicking 😛
import java.awt.event.InputEvent
def rightClickUntilMouseMove(setupMillis: Int, everyMillis: Int): Unit = {
Thread.sleep(setupMillis)
val pInit = MouseInfo.getPointerInfo().getLocation
while (pInit == MouseInfo.getPointerInfo().getLocation) {
val r = new Robot()
r.mousePress(InputEvent.BUTTON3_MASK)
r.mouseRelease(InputEvent.BUTTON3_MASK)
Thread.sleep(everyMillis)
@harpocrates
harpocrates / crawler.py
Created August 23, 2019 03:54
Crawl a website looking for download links
#!/usr/bin/env python3
import requests
import shutil
import os
from bs4 import BeautifulSoup
from urllib.parse import urljoin, urlparse
import re
import argparse
@harpocrates
harpocrates / vvm_java.sh
Created August 7, 2019 20:42
Wrapper script for calling `java` with JMX access on port 10000
#!/usr/bin/env bash
java \
-Dcom.sun.management.jmxremote.port=10000 \
-Dcom.sun.management.jmxremote.rmi.port=10000 \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
-Djava.rmi.server.hostname=localhost \
$@
@harpocrates
harpocrates / Json.scala
Created June 27, 2019 14:32
Quick example demonstrating custom type-safe serialization with typeclasses and generic programming
import scala.reflect.ClassTag
import shapeless._
import shapeless.labelled._
/*
* Simple Json type
*/
sealed trait Json
object Json {