Skip to content

Instantly share code, notes, and snippets.

View olange's full-sized avatar
🚀

Olivier Lange olange

🚀
View GitHub Profile
@olange
olange / neo4j-compiling.md
Last active August 27, 2015 22:57
Compiling Neo4j Community on my Mac OS X

Resume of the build instructions found in the Neo4j project page on GitHub.

### Compiling

$ export MAVEN_OPTS="-Xmx512m"
$ cd neo4j/community/
$ mvn [clean] install -Dlicense.skip=true -DskipTests
@olange
olange / neo4j-graphviz-runnning.md
Last active August 29, 2015 14:26
Getting Neo4j Graphviz command-line options right

### Running the Neo4j GraphViz module

The quotes around the nodeTitle, relationshipTitle and nodePropertyFilter must be escaped on the shell command-line, to get them to the graphviz main class:

$ ./graphviz ~/neo4j/data/graph.db \
             relationshipTitle=\"@type\" nodePropertyFilter=name

or

@olange
olange / ShowMyTransforms.cs
Last active January 20, 2016 18:10 — forked from david-hodgetts/ShowMyTransforms.cs
An Unity Gizmo that displays the origin and orientation of a _game object_ when it is selected in the _Editor_, displaying its right/forward/up as red/blue/green axis
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class ShowTransforms : MonoBehaviour {
private const float radius = 0.02f;
void OnDrawGizmosSelected() {
Vector3 origin, axisRight, axisForward, axisUp;
@olange
olange / mono-runtime-version.cs
Created March 4, 2016 15:40
Reading Mono Runtime version
using System.Reflection;
System.Type type = System.Type.GetType( "Mono.Runtime");
if( type != null) {
MethodInfo displayName = type.GetMethod( "GetDisplayName", BindingFlags.NonPublic|BindingFlags.Static);
if( displayName != null)
Debug.Log( "Mono Runtime version" + displayName.Invoke(null,null));
}
@olange
olange / graphqlScalarDateTimeType.coffee
Last active April 8, 2016 17:55
Defines and exports a custom GraphQL scalar type that represents date and time with a time zone, which, while serialized as a string, promises to conform to ISO‐8601 format.
# Defines and exports a custom GraphQL scalar type that represents date and time,
# which, while serialized as a string, promises to conform to ISO‐8601 format.
# (adapted from https://github.com/soundtrackyourbrand/graphql-custom-datetype)
graphql = require 'graphql'
graphql_language = require 'graphql/language'
graphql_error = require 'graphql/error'
GraphQLScalarType = graphql.GraphQLScalarType
GraphQLError = graphql_error.GraphQLError
@olange
olange / symmetricDiff.coffee
Created May 13, 2016 18:12
Symmetric difference of two Sets in CoffeeScript
##
# Given two sets A and B, returns a triple with the set of elements
# in A only, in both and in B only.
#
symmetricDiff = (setA, setB) ->
[inAOnly, inBoth, inBOnly] = [new Set(), new Set(), new Set()]
setA.forEach (eid) ->
(if setB.has( eid) then inBoth else inAOnly).add eid
setB.forEach (eid) ->
inBOnly.add( eid) unless inBoth.has( eid)
@olange
olange / measuringDuration.coffee
Created May 19, 2016 16:56
Measuring a duration of execution in Node.js
##
# Utility function to measure time intervals. Polymorphic return value:
#
# * returns either the current high-resolution real time, given no argument;
# * or the time elapsed since a given high-resolution real time, that was
# retrieved from a previous call to this function.
#
# Usage:
# t0 = hrtime()
# duration = hrtime( t0) # expressed in milliseconds
@olange
olange / nearlyEqual.coffee
Last active May 20, 2016 16:13
Near equality in CoffeeScript for Node.js (comparison with a maximum relative difference)
##
# Minimum number added to one that makes the result different than one
#
EPSILON = Number.EPSILON ? 2.2204460492503130808472633361816e-16
##
# Given two floating point numbers and the maximum relative difference
# between the two, returns true if the two numbers are nearly equal,
# false otherwise. If the maximum relative difference (aka _epsilon_)
# is undefined, the function will test whether x and y are exactly equal.
@olange
olange / user.keymap
Created May 25, 2016 10:22
My LightTable settings (intended for a CH/FR keyboard layout)
;; User keymap
;; -----------------------------
[
[:editor "alt-w" :editor.watch.watch-selection]
[:editor "alt-shift-w" :editor.watch.unwatch]
[:app "pmeta-*" :workspace.show]
[:app "pmeta-/" :toggle-console]
[:app "pmeta-shift-/" :clear-console]
[:app "pmeta-alt-/" :console-tab]
@olange
olange / type-yatd.coffee
Created January 19, 2017 18:30
Yet another type detective – CoffeeScript version of the type `component/type` NPM package
#
# A less-broken `typeof` function. CoffeeScript version of the
# `component/type` NPM package [1].
#
# See also:
#
# [1] https://github.com/component/type/blob/master/index.js
# and https://gist.github.com/olange/2aa1abe1001c92bde78be1c84d7f1261
exp.type = (val) ->
toString = Object.prototype.toString