Skip to content

Instantly share code, notes, and snippets.

View andreasronge's full-sized avatar

Andreas Ronge andreasronge

View GitHub Profile
@andreasronge
andreasronge / Gemfile
Last active August 29, 2015 14:00
Example how to deploy Neo4j.rb / neo4j-core app on heroku
source "https://rubygems.org"
ruby "2.1.1"
gem 'sinatra', '1.1.0'
gem 'neo4j-core', '3.0.0.alpha.11'
@andreasronge
andreasronge / neo4j.rb
Created July 6, 2013 09:47
Spike on neo4j 2.0 featrues
require 'java'
require 'forwardable'
require 'fileutils'
# Load Neo4j Jars for the jars folder
# Put the neo4j 2.0 jars there
jar_folder = File.expand_path('../jars', __FILE__)
jars = Dir.new(jar_folder).entries.find_all { |x| x =~ /\.jar$/ }
jars.each { |jar| require File.expand_path(jar, jar_folder) }
@andreasronge
andreasronge / show.rb
Created April 22, 2013 07:34
Working with relstionships
require 'neo4j'
class Show < Neo4j::Rails::Model
property :show_name, type: String, index: :exact
has_n :booked_bands
end
#I have another model, band.rb
class Band < Neo4j::Rails::Model
class TransactionalExec
attr_accessor :commit_every, :block
def initialize(commit_every, max_lines = nil, verbose = true, &block)
@commit_every = commit_every
@block = block
@max_lines = max_lines
@verbose = verbose
end
@andreasronge
andreasronge / Gemfile
Last active December 10, 2015 08:28
Complete Ha Example
source 'https://rubygems.org'
gem 'rails', '3.2.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'jruby-openssl'
me = lookup('node_auto_index', 'name', "Joe").as(:me)
me > rel(:favorite) > node(:myFavorites) > rel(:tagged) > node(:tag) < rel(:tagged) < node(:theirFavorites) < rel(:favorite) < node(:people)
me != node(:people)
ret node(:people)[:name].as(:name), count.desc.as(:similar_favs)
@andreasronge
andreasronge / StackTrace
Created August 17, 2012 10:16
JVM Crash using JRuby 1.7.preview2
Environment
===========
Mac OSX
jruby 1.7.0.preview2
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
How to Reproduce
require 'rubygems'
require 'neo4j-core'
def connect(d)
d.each{|i| Neo4j::Relationship.new(:flies_to, i[:from], i[:to])}
end
tx = Neo4j::Transaction.new
@a, @b, @c, @z = %w[A B C D].map{|name| Neo4j::Node.new(:name => name)}
connect([ {:from=>@a, :to=>@b}, {:from=>@a, :to=>@c}, {:from=>@b, :to=>@c},
@andreasronge
andreasronge / basic_test.rb
Created January 5, 2012 13:42
Domain Example
# load 'nodes.rb'
require 'rubygems'
require 'neo4j'
alice = Neo4j::Transaction.run { Neo4j::Node.new }
bob = Neo4j::Transaction.run { Neo4j::Node.new }
Neo4j::Transaction.run do
alice[:name] = "alice"
alice[:score] = [42,4]
@andreasronge
andreasronge / cypher.rb
Created January 5, 2012 10:19
recommendation example
recommend = Neo4j.query do
node(alice).where_not{|me| me > ':follows' > :user} > ':used_tag' > :tag < ':used_tag' < :user
ret(node(:user), count(:tag).desc(count(:tag)))
end.first[:user]