This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| call db.indexes() | |
| yield indexName, type | |
| with [i in collect({name: indexName, type: type}) where i.type = "node_fulltext" | i.name] as nis | |
| unwind nis as n | |
| call db.index.fulltext.drop(n) | |
| return true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import kotlin.reflect.KProperty | |
| interface ValDelegate<C, P> { | |
| operator fun getValue(thisRef: C, prop: KProperty<*>): P | |
| } | |
| interface ValDelegateProvider<C, P> { | |
| operator fun provideDelegate(thisRef: C, prop: KProperty<*>): ValDelegate<C, P> | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Seq<out T>(val takeOne: () -> Pair<T, Seq<T>>?) | |
| val nil: Seq<Nothing> = Seq { null } | |
| fun <T> cons(head: T, tail: Seq<T> = nil) = Seq { Pair(head, tail) } | |
| fun <T> list(vararg elements: T): Seq<T> { | |
| var result: Seq<T> = nil | |
| for (i in elements.indices.reversed()) | |
| result = cons(elements[i], result) | |
| return result | |
| } | |
| tailrec fun <T> Seq<T>.forEach(consume: (T) -> Unit) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns clojure-play.core | |
| (:require [quil.core :as q :include-macros true] | |
| [quil.middleware :as m])) | |
| (def world-size 16) | |
| (def cell-padding-ratio 0.1) | |
| (def win-size 500) | |
| (def cell-radius-ratio 0.1) | |
| (def update-millis 100) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun replaceParams(string: String, params: Map<String, Any>) = buildString { | |
| var i = 0 | |
| var j: Int | |
| while (i < string.length) { | |
| while (string[i] != '{') { | |
| append(string[i]) | |
| i++ | |
| if (i > string.length) | |
| return@buildString | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun <A, R> memoize(function: (A) -> R): (A) -> R { | |
| val results = mutableMapOf<A, R>() | |
| return { arg -> results[arg] ?: function(arg).also { results[arg] = it } } | |
| } | |
| fun fib(n: Long): Long = if (n < 2) n else cfib(n - 1) + cfib(n - 2) | |
| val cfib = memoize(::fib) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DeterminantTeller { | |
| Double tellToQuadratic(Double a, Double b, Double c) { b ** 2 - 4 * a * c } | |
| } | |
| class Solver { | |
| def teller = new DeterminantTeller() | |
| List<Double> solveQuadratic(Double a, Double b, Double c) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Example API description object. | |
| //In most requests we attach data as query params and/or json. | |
| //Usually the fields can be optional in some requests. | |
| const REQ = 'required' | |
| const OPT = 'optional' | |
| export const Api = { | |
| users: { | |
| me: { | |
| GET: {} | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import github.etx.neo4j.CursorWrapper | |
| import github.etx.neo4j.NeoQuery | |
| import github.etx.neo4j.destruct | |
| import github.etx.neo4j.DefaultNeoSerializer | |
| val driver: Driver = GraphDatabase.driver( | |
| "bolt://localhost", | |
| AuthTokens.basic("neo4j", "demo") | |
| ) |
NewerOlder