Skip to content

Instantly share code, notes, and snippets.

View cheerfulstoic's full-sized avatar

Brian Underwood cheerfulstoic

View GitHub Profile
@cheerfulstoic
cheerfulstoic / gist:280f57c9bbee94e22d85
Created September 22, 2014 12:12
Script to find a good batch size for neo4j find_in_batches
batch_size = 10_000
previous_nodes_per_second = nil
while true
total_found = 0
puts "Testing batch size of #{batch_size}..."
time_taken = Benchmark.realtime do
i = 0
House.as(:h).find_in_batches(batch_size: batch_size) do |batch|
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;
CREATE (:Product {id: 1, name: 'Apple iPhone 6 128GB iOS 8 4.7" Touchscreen Factory Unlocked', price: 839.99});
CREATE (:Product {id: 2, name: 'HTC One M8 32GB Factory Unlocked Windows 8.1 Smartphone', price: 349.99});
CREATE (:Product {id: 3, name: 'DELL 15.6" Intel Core i7 1TB HDD Notebook', price: 649.99});
CREATE (:Product {id: 4, name: 'Canon EOS Rebel T5 EF-S 18-55mm IS II Digital SLR Kit US Warranty', price: 399.99});
CREATE (:Product {id: 5, name: 'Terralux TLF-TT-5 Tactical 5 Light 650 Lumens', price: 77.88});
CREATE (:Product {id: 6, name: 'Emergency One Person 3-month Food Storage Kit', price: 479.99});
require 'json'
queries = []
queries << <<QUERY
{
"statements" : [
{
"statement" : "CREATE (n:TransactionTestFoo) RETURN id(n)"
},
{
@cheerfulstoic
cheerfulstoic / Sample queries
Created January 29, 2015 19:18
store load script
# Show user friend relationships
MATCH (user:User) RETURN user
# Show products in category hierarchy
MATCH (product:Product)-[:has_category]->(category:Category)<-[:has_subcategory*]-(super_category:Category)
RETURN *
# All users 25 and under
MATCH (user:User) WHERE user.age <= 25 RETURN user.name, user.age;
= Competitive Intelligence in Cancer Drug Discovery =
:neo4j-version: 2.0.0-RC1
:author: Wolfgang Hoeck
:twitter: @LiveDataConcept
:tags: life science domain:competitive intelligence in cancer drug discovery
Using the _Design for Queryability_ modeling approach by http://twitter.com/ianrobinson[Ian Robinson]
=== 1. Application/End-User Goals ===
@cheerfulstoic
cheerfulstoic / gist:117ad8770aa5e5f165e2
Created February 20, 2015 13:02
GithubClientCache - First, not ideal attempt, at caching `github_api` responses
class GithubClientCache
CACHE = ActiveSupport::Cache::FileStore.new('cache')
CACHE_EXPIRY_PERIOD = (60 * 60 * 24 * 365) # 1 year
def initialize(current_object, arg_stack = [])
@current_object = current_object
@arg_stack = arg_stack
end
def method_missing(method, *args, &block)
@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