Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tkroman
tkroman / l3.java
Last active August 29, 2015 14:03
I don't know whether this piece is correct or not, neither do I know if it works at all, but this is definitely the most complete version I managed to find in my code clutter.
import java.util.Arrays;
import java.util.stream.IntStream;
public class Main {
final static int GMOD = 0x8000;
final static int MOD = 0x8003;
final static int DEG = 15;
final static int[] f1 = new int[GMOD];
static int[][] wf1;
@tkroman
tkroman / rels
Created July 10, 2014 08:34
rels
USING PERIODIC COMMIT 5000
LOAD CSV FROM 'file:///home/roman/dirs1.csv' AS line
MATCH
(parent:Node {nid: toInt(line[0])}),
(child: Node {nid: toInt(line[1])})
CREATE
(child)-[:CHILD_OF]->(parent)
def dumpCypher() {
val createConstraint = """create index on :Node(nid)"""
val dumpNodes =
"""USING PERIODIC COMMIT 5000
|LOAD CSV WITH HEADERS FROM 'file:///home/roman/toDump.csv' AS line
|CREATE (c:Node {title: line.title, nid: toInt(line.nid)})""".stripMargin
val db = new GraphDatabaseFactory().newEmbeddedDatabase("/tmp/skip")
val cypher = new ExecutionEngine(db)
private void bootstrapWebGUI(final String host, final Integer port) {
final Configurator cfg = new ServerConfigurator((GraphDatabaseAPI) db);
cfg.configuration().setProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, port);
cfg.configuration().setProperty(Configurator.WEBSERVER_ADDRESS_PROPERTY_KEY, host);
webServer = new WrappingNeoServer((GraphDatabaseAPI) db, cfg);
webServer.start();
}
public UnsignedLong incrementProperty(final UnsignedLong id, final String propKey, final UnsignedLong incrementAmount) {
return changePropValue(id, propKey, oldProp -> oldProp.plus(incrementAmount));
}
public UnsignedLong decrementProperty(final UnsignedLong id, final String propKey, final UnsignedLong decrementAmount) {
return changePropValue(id, propKey, oldProp -> oldProp.minus(decrementAmount));
}
public UnsignedLong getProperty(final UnsignedLong id, final String propKey) {
return changePropValue(id, propKey, Function.identity());
import java.util
import java.util.Collections
import scala.util.Random
object Perceptron {
def main (args: Array[String]) {
val Variant = 13
val CsvRegex = """(.+)\;(.+)\;(.+)""".r
import java.util.*;
import java.util.function.*;
import java.util.stream.*;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
/**
* Delegates all operations to an underlying Stream, but wraps them in transactions.
* Transaction is wrapped around the whole method call (i.e. map(), forEach() etc.),
* so may become potentially heavy.
public T fn(int required) {
return fn(required, "defaultString");
}
public T fn(int required, String optional) {
fn(required, optional, false);
}
public T fn(int required, String optional, boolean flag) {
// BUSINESS SHIT
def fn(x: Int, optStr: String = "defaultValue", flag: Boolean = false) = {
// BUSINESS SHIT
}
def fn(x: Int, optStr: Option[String], flag: Option[Boolean]) = {
businessShit(x, optStr.getOrElse("defaultValue"), flag.getOrElse(false))
}