Skip to content

Instantly share code, notes, and snippets.

View cheerfulstoic's full-sized avatar

Brian Underwood cheerfulstoic

View GitHub Profile
@cheerfulstoic
cheerfulstoic / wiki.rb
Created July 7, 2011 12:57 — forked from federomero/wiki.rb
Simple script for testing http://xkcd.com/903/ alltext trivia
# encoding: UTF-8
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'graphviz'
target = 'Philosophy'
links = {}
require 'rubygems'
require 'rake'
require 'fileutils'
require "bundler"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
desc "Task for cruise Control"
@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|
= Bank Fraud Detection
:neo4j-version: 2.0.0-RC1
:author: Kenny Bastani
:twitter: @kennybastani
:tags: domain:finance, use-case:fraud-detection
= Bank Fraud Detection
(original source: https://github.com/neo4j-contrib/gists/blob/master/other/BankFraudDetection.adoc )
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:7e8ec61f9104017430af
Last active April 12, 2022 18:36
Examining what is possible for StackOverflow with a graph database

Analyzing StackOverflow with Neo4j and Clojure

Joining multiple disparate data-sources, commonly dubbed Master-Data-Management (MDM), is usually not a fun exercise. I would like to show you how using a graph database (Neo4j) and an interesting dataset (developer-oriented collaboration sites) to put the fun back into MDM. This approach will allow you to quickly and sensibly merge data from different sources into a consistent picture and query across the data efficiently to answer your most pressing questions.

You can read the associated blog posts on my blog. The blog posts cover the hows and whys of the project, while this and other GraphGists will examine how to answer specific questions of the data.

@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)