Skip to content

Instantly share code, notes, and snippets.

View cheerfulstoic's full-sized avatar

Brian Underwood cheerfulstoic

View GitHub Profile
@cheerfulstoic
cheerfulstoic / gist:bae681a589c4dc172bad
Created February 22, 2015 12:53
Testing performance of various queries in neo4j
require 'net/http'
require 'json'
server_url = 'http://localhost:7504'
queries = [
"MATCH (u:User) RETURN *",
"MATCH (u:User:GitHub) RETURN *",
"MATCH (u:User:StackOverflow) RETURN *",
"MATCH (u:User) WHERE u:GitHub RETURN *",
### Keybase proof
I hereby claim:
* I am cheerfulstoic on github.
* I am cheerfulstoic (https://keybase.io/cheerfulstoic) on keybase.
* I have a public key whose fingerprint is DB07 298B 96EC 8866 97A1 E1C7 78F5 02CB B09E F117
To claim this, I am signing this object:
@cheerfulstoic
cheerfulstoic / gist:f0a264d37b3651855b8a
Created April 15, 2015 14:24
Neo4j Workshop sports data models

World Cup

Summer Olympics

@cheerfulstoic
cheerfulstoic / gist:6b6bceda69a8f0fbef89
Last active August 29, 2015 14:19
Advanced Neo4j Question

World Cup questions

  • What is the most that any country has played in a given stadium?

  • For each country, what is the stadium which is has played in the most?

  • For all of the World Cup years, which continents were represented in the "Semi-finals" phase? What about the "Final" phase?

  • What players has "Philipp Lahm" played against the most? Note that a Squad is tied to a match both through it's Country and the WorldCup is was named for

Here we explore how to model a conference

Test!

CREATE

Flight wifi timer

Flights and wifi!

CREATE
  (lon:City {name: 'London'}),
@cheerfulstoic
cheerfulstoic / gist:767e64209891e47f541e
Last active August 29, 2015 14:20
Maximizing Wi-Fi Time on Flights

Maximizing Wi-Fi Time on Flights

On the way to GraphConnect I was preparing a talk about GraphGists. Since the flight didn’t have wi-fi I thought that the perfect topic for a demostration GraphGist would be to calculate the maximum percentage of wi-fi time that you can have for various flight options.

Belong is my setup query which I made up by looking at my seat’s on-screen map showing my flight’s progress and guessing how long flights would take:

MERGE (ruan :User {control: 50, fullname: 'Ruan'})
MERGE (amber :User {control: 60, fullname: 'Amber'})
MERGE (task1 :Task {control: 1, subject: 'Root Task:'})
MERGE (task2 :Task {control: 2, subject: 'Child of Root:'})
MERGE (task3 :Task {control: 3, subject: 'User properties'})
= Chess Games and Positions in Neo4j!!
:neo4j-version: 2.0.0
:author: Wes Freeman
:twitter: @wefreema
:tags: chess
Heya!
The goal is to load a bunch of chess games into Neo4j for further analysis. Scores listed are Stockfish's take on a position after a 25 move horizon (but this number can be deepened as the graph is filled out or as more processing is done). Positions can also be loaded as alternative moves (not connected to a game) based on suggestions from Stockfish. The positions are recorded as link:http://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation[FEN], a human-readable/compressed chess board state notation.
@cheerfulstoic
cheerfulstoic / gist:3142ed2e15ad08ef6631
Last active March 4, 2019 12:56
Script for "Neo4j.rb Screencast #1 - Create a Neo4j Rails Application"

Welcome to the first episode in a series of short screencasts for the Ruby neo4j gem. Each episode will describe a different aspect of the gem. In this first episode, we will start by discussing how to set up a new Ruby on Rails app using Neo4j. The neo4j gem is not Rails specific so you can use other frameworks like Sinatra or Lotus, but because of the popularity of Ruby on Rails we will be using it for this screencast series.

In this series we’re going to create an application to host digital assets which we’ll call "asset_portal". To create your Rails app you can run a rails new command as usual. To use Neo4j instead of ActiveRecord you can give arguments which will set up a new Rails app using Neo4j models.

rails new asset_portal -m http://neo4jrb.io/neo4j/neo4j.rb -O

The dash-m argument runs a script from the neo4j gem project and the dash-capital-O argument says to exclude ActiveRecord. There aren’t any restrictions on using Neo4j with other ORMs like ActiveRecord, but you will need to conf