Skip to content

Instantly share code, notes, and snippets.

View ryanpstauffer's full-sized avatar
🐺

Ryan Stauffer ryanpstauffer

🐺
  • San Francisco, CA
View GitHub Profile
@ryanpstauffer
ryanpstauffer / ChangeSchema_Fails.groovy
Created February 12, 2019 07:13
JanusGraph Schema Bug
// JanusGraph Change Schema Bug - Fails
graph = JanusGraphFactory.build().
set('storage.backend', 'inmemory').
set('schema.default', 'none').
set('schema.constraints', true).open()
mgmt = graph.openManagement()
// Define Vertex labels and Properties
Artist = mgmt.makeVertexLabel('Artist').make()
@ryanpstauffer
ryanpstauffer / InitialSchema.groovy
Last active April 2, 2019 19:06
Evolving Data Models with JanusGraph
// SymphonyGraph Initial Schema
mgmt = graph.openManagement()
// Define Vertex labels
Orchestra = mgmt.makeVertexLabel('Orchestra').make()
Artist = mgmt.makeVertexLabel('Artist').make()
Work = mgmt.makeVertexLabel('Work').make()
Concert = mgmt.makeVertexLabel('Concert').make()
// Define Edge labels - the relationships between Vertices
@ryanpstauffer
ryanpstauffer / rheingoldgraph_magenta_demo.py
Last active February 8, 2018 09:32
Demo of RheingoldGraph & Magenta interface
# Use our line as a primer for generating new melodies
# from a trained TensorFlow (Magenta) model
bundle_file = '~/magenta_data/mag/basic_rnn.mag'
session.generate_melody_from_trained_model(trained_model_name='melody_rnn_generator',
bundle_file=bundle_file,
primer_line_name='bach_cello',
primer_len=11,
num_outputs=1,
qpm=80,
num_steps=150)
@ryanpstauffer
ryanpstauffer / rheingoldgraph_demo.py
Last active February 8, 2018 16:48
Loading XML data into RheingoldGraph
from rheingoldgraph.session import Session
# Connect to an existing Gremlin Server via Websocket
server_uri = 'ws://localhost:8182/gremlin'
session = Session(server_uri)
# Add an XML file to the graph
session.add_lines_from_xml(filename='scores/BachCelloSuiteDminPrelude.xml',
piece_name='bach_cello')
@ryanpstauffer
ryanpstauffer / bach_cello_graph.groovy
Last active February 5, 2018 04:47
Gremlin - Bach's Cello Suite No.2, I. Prelude as a graph
// Create the musical line
l0 = g.addV('Line').property('name', 'bach_cello').next()
// Create notes
n0 = g.addV('Note').property('name', 'D3').
property('length', 8).
property('dot', 0).next()
n1 = g.addV('Note').property('name', 'F3').
property('length', 8).
@ryanpstauffer
ryanpstauffer / bach_cello.xml
Created February 4, 2018 20:11
Music XML Example (Bach Cello Suite No. 2, I. Prelude)
<note>
<pitch>
<step>D</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>eighth</type>
<stem>down</stem>
<beam number="1">begin</beam>
@ryanpstauffer
ryanpstauffer / 0_reuse_code.js
Created June 26, 2017 16:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console