Skip to content

Instantly share code, notes, and snippets.

View jbmusso's full-sized avatar

Jean-Baptiste Musso jbmusso

View GitHub Profile
// Proposal: transactions over the Gremlin extension
var tx = new Transaction(); // g.begin();
var v1 = tx.g.addVertex('v1', {name: 'Alice'});
var v2 = tx.g.addVertex('v2', {name: 'Bob'});
tx.g.addEdge(v1, v2, 'knows', {since: '1970'});
// And/or, alternatively:
var tx = new Transaction();
tx.g.addVertex('v1', {name: 'Alice'});
tx.g.addVertex('v2', {name: 'Bob'});
v1 = g.addVertex([name: 'Alice']);
v2 = g.addVertex([name: 'Bob']);
g.addEdge(v1, v2, 'knows', [since: '1970']);
npm http GET https://registry.npmjs.org/grex
npm http 304 https://registry.npmjs.org/grex
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/q
npm http GET https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/q
npm http GET https://registry.npmjs.org/json-stringify-safe
npm http GET https://registry.npmjs.org/qs
@jbmusso
jbmusso / st2-replace-permille-char
Last active November 11, 2015 10:07
Sublime Text automatically replace permille char (‰) with percent char (%)
// edit config file: Sublime Text 2 > Preferences > Key Bindings - User
[{
"keys": ["‰"],
"command": "insert_snippet",
"args": {
"contents": "%"
}
}]
client.execute('g.V().filter(function(it) { return it.get().value("lang") !== "java" });', callback)
Gremlin Server log:
[WARN] StandardOps - Exception processing a script on request [RequestMessage{, requestId=db546f8a-c671-a6ea-5bfe-7bc8786e4631, op='eval', processor='', args={gremlin=g.V().filter(function(it) { return it.get().value("lang") !== "java" });, accept=application/json, language=nashorn}}].
java.util.concurrent.CompletionException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NoSuchMethodException: Can't unambiguously select between fixed arity signatures [(com.tinkerpop.gremlin.util.function.SPredicate), (com.tinkerpop.gremlin.util.function.SBiPredicate)] of the method com.tinkerpop.gremlin.tinkergraph.process.graph.TinkerGraphTraversal.filter for argument types [jdk.nashorn.internal.objects.ScriptFunctionImpl]
[WARN] StandardOps - Exception processing a script on request [RequestMessage{, requestId=2f27165c-f829-9aee-dac5-cf288466d531, op='eval', processor='', args={gremlin=g.v(id), bindings={id=1}, accept=application/json, language=gremlin-groovy}}].
java.util.concurrent.CompletionException: java.lang.RuntimeException: javax.script.ScriptException: javax.script.ScriptException: java.util.NoSuchElementException: The vertex with id id of type does not exist in the graph
at java.util.concurrent.CompletableFuture.internalComplete(CompletableFuture.java:205)
at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:482)
at java.util.concurrent.CompletableFuture$Async.run(CompletableFuture.java:428)
at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:36)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: javax.script.ScriptException: javax.
'use strict';
import React from 'react';
export default class Clearfix extends React.Component {
render() {
const beforeStyle = {
display: 'table'
};
@jbmusso
jbmusso / introrx.md
Last active August 29, 2015 14:24 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@jbmusso
jbmusso / fold.js
Created November 19, 2015 22:41 — forked from kpuputti/fold.js
Functional acrobatics using folds in JavaScript.
/*eslint-env es6 */
// Inspired by the paper "A tutorial on the universality and
// expressiveness of fold" by Graham Hutton (available at
// http://www.cs.nott.ac.uk/~gmh/fold.pdf), implementing some generic
// list handling functions in JavaScript in terms of `fold`.
// Personally I had an enlightnening moment when I realised the
// beautiful interplay of cons lists and foldr during the FP101x
// Haskell course. JavaScript's syntax doesn't make this very apparent
gremlin.graph=com.thinkaurelius.titan.core.TitanFactory
storage.backend=cassandrathrift
storage.hostname=127.0.0.1
storage.cassandra.keyspace=primus # Defaults to titan
index.primus.backend=elasticsearch
index.primus.hostname=127.0.0.1