Skip to content

Instantly share code, notes, and snippets.

View boggle's full-sized avatar

Stefan Plantikow boggle

  • neo4j
  • Berlin, Germany
View GitHub Profile
@boggle
boggle / unfixable.scala
Created April 10, 2017 12:39
How to generate extractors using shapeless to simplify pattern matching fixed point types from matryoshka
import matryoshka.data.Fix
import org.opencypher.spark.prototype.api.cyphertype.UnFixable.RecursiveExtractor
import matryoshka.Recursive
import shapeless.ops.hlist.Tupler
import scala.language.higherKinds
import scala.reflect.ClassTag
import scalaz.Functor
@boggle
boggle / truth table
Last active May 20, 2016 19:51
The implied truth
(in kleene logic K3)
goal: NOT x OR y
r.blocked x=exists(r.blocked) y=r.blocked <> true goal: x IMPLIES y suggestion: X AND NOT R.BLOCKED
true true false false true AND NOT true => false
false true true true true AND NOT false => true
null false null true false AND NOT null => false !!! Here is the difference
Here's another alternative for lukasiewicz logic L3, which defines implication as in K3 except null IMPLIES null => true
@boggle
boggle / constraint-and-index-proposal.asciidoc
Last active August 29, 2015 14:25
Cypher Constraint and Index Syntax Proposal

Cypher Constraint and Index Syntax Proposal

This proposoal follows three design principles:

  1. Make it easy to understand the affected part of the graph in relationship to querying it (Rationale: Minimize mental effort for using constraints and indices)

  2. Re-use existing concepts as much as possible (i.e. patterns and expressions) (Rationale: Minimize amount of new concepts that need to be learned)

  3. Use the same imperative form as all existing update and schema commands (verb first, like in CREATE INDEX) and try to use similiar syntax structure for both constraint and index creation

@boggle
boggle / gol.adoc
Last active May 4, 2017 22:32
Game Of Live

Game Of Life

Animated Glider

Game of Life is mathematic toy world that was invented by John Horton Conway in 1970. Game of Life is played on a grid of cells that are either dead or alive by simluating how the world evolves over a series of rounds. In each round cells die, survive, or are reborn depending on the number of neighbours they have. You can find out more about Game of Life by watching the video below or reading up on it in Wikipedia.

@boggle
boggle / pancakes
Last active August 29, 2015 13:56
Master of Pancakes: Find Missing Ingredients for a Recipe
= Master of Pancakes: Find Missing Recipe Ingredients =
:neo4j-version: 2.0.0
:author: Stefan Plantikow
:twitter: @boggle
image::http://www.perfectpancake.info/wp-content/uploads/2013/04/pancakes.jpg[]
Let's say you have a database of recipes and ingredients, as well as chefs and their current kitchen inventory.
-------------------------------------------------------------------------------
Test set: org.neo4j.kernel.impl.nioneo.store.IdGeneratorRebuildFailureEmulationTest
-------------------------------------------------------------------------------
Tests run: 20, Failures: 1, Errors: 9, Skipped: 0, Time elapsed: 92.186 sec <<< FAILURE! - in org.neo4j.kernel.impl.nioneo.store.IdGeneratorRebuildFailureEmulationTest
neostore_propertystore_db(org.neo4j.kernel.impl.nioneo.store.IdGeneratorRebuildFailureEmulationTest$FailureDuringRebuild) Time elapsed: 91.414 sec <<< FAILURE!
java.lang.AssertionError: makeStoreOk should have thrown UnderlyingStorageException
at org.junit.Assert.fail(Assert.java:88)
at org.neo4j.kernel.impl.nioneo.store.IdGeneratorRebuildFailureEmulationTest$FailureDuringRebuild.emulateFailureOnRebuildOf(IdGeneratorRebuildFailureEmulationTest.java:87)
neostore_propertystore_db_strings(org.neo4j.kernel.impl.nioneo.store.IdGeneratorRebuildFailureEmulationTest$FailureDuringRebuild) Time elapsed: 0.005
"/Users/stepn/Current/neo4j/manual/target/tools/bin/asciidoc/asciidoc.py" --attribute neo4j-version=2.0-SNAPSHOT --attribute gitversion=master --attribute importdir="/Users/stepn/Current/neo4j/manual/target/docs" --conf-file="/Users/stepn/Current/neo4j/manual/target/conf/asciidoc.conf" --conf-file="/Users/stepn/Current/neo4j/manual/target/conf/asciidoc.local.conf" --backend html5 --doctype book --attribute docinfo1 --attribute toc --out-file "/Users/stepn/Current/neo4j/manual/target/html5/index.html" "/Users/stepn/Current/neo4j/manual/target/src/neo4j-manual.asciidoc" 2>&1 | "/Users/stepn/Current/neo4j/manual/target/tools/build/outputcheck-includefiles.sh" || false
Traceback (most recent call last):
File "/Users/stepn/.asciidoc/filters/queryresult/queryresult.py", line 120, in <module>
if data[0][0] == '+':
IndexError: list index out of range
asciidoc: WARNING: union-union-two-queries.result.asciidoc: line 5: filter non-zero exit code: "/usr/bin/python" "/Users/stepn/.asciidoc/filters/queryresult/quer
package org.neo4j.cypher.performance
import org.junit.Test
class ScalaStreamTest {
@Test def stream_append_should_use_linear_memory() {
def streamAppendTimes(times: Int): Float =
{
@boggle
boggle / rewrite.scala
Created January 29, 2013 18:16
Solving AST typing riddles
trait Rewriter[T] extends {
def rewrite[X <: T](a: Rewritable[X]): Rewritable[X]
}
trait Rewritable[T] {
self: T with Rewritable[T] =>
def rewrite(r: Rewriter[T]): T = r.rewrite[T](self).reveal
def reveal: T = self
@boggle
boggle / gist:2500585
Created April 26, 2012 16:01
Nice way to add reloading support to a ruby gem's top-level module
module Foo
def self.files
f = []
f << 'foo/a'
f << 'foo/b'
f
end
def self.load_relative(f)