Skip to content

Instantly share code, notes, and snippets.

When /^(\d+) (minutes|hours|days) pass$/ do |amount, unit|
now = Time.now
Time.stubs(:now).returns(now + amount.to_i.send(unit.to_sym))
end
When /^going back (\d+) (minutes|hours|days)$/ do |minutes|
now = Time.now
Time.stubs(:now).returns(now - amount.to_i.send(unit.to_sym))
end
@shageman
shageman / bootstrap_workshop.sh
Last active September 23, 2015 13:32
Setup for RMR 2015 #cbra workshop
#!/bin/bash
git clone https://github.com/shageman/r4ia_examples
wget https://gist.githubusercontent.com/shageman/89d869ef8539f78312b0/raw/f12ffc2fada4d4d201fad6bb2874dae79aee8fab/extract_persistence.sh
chmod +x extract_persistence.sh
./extract_persistence.sh
@shageman
shageman / leak.rb
Created January 13, 2011 17:54
Memory (and classes) leak in neo4jrb
#!/usr/bin/env ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m
# Profile these different versions (e.g. with VisualVM)
# jruby 1.5.6: watch the number of classes rise with every iteration. Eventually PermGen space will be exhausted.
# jruby 1.6.0.rc1: the classes get garbage collected regularly.
require "rubygems"
require 'neo4j' #1.0.0.beta.26
class Node
@shageman
shageman / reader.rb
Created March 1, 2011 19:53
Files for example regarding data writer + reader to test concurrency of neo4j access through neo4j gem (http://wiki.neo4j.org/content/Getting_Started_With_Ruby)
require "rubygems"
require "neo4j"
#domain model
class Waypoint
include Neo4j::NodeMixin
#the persistent properties of this class
property :name, :lon, :lat
#friend relationships to other persons
has_n :roads
@shageman
shageman / Gemfile
Created March 9, 2011 16:11
Performance comparison MySQL and Neo4j
source "http://rubygems.org"
gem 'neography'
gem 'activesupport', '~>2.3.4', :require => 'active_support'
gem 'i18n'
group :test do
gem 'test-unit', :require => 'test/unit'
gem 'minitest'
gem 'dm-core'
import javax.ws.rs.DELETE;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.server.NeoServer;
@shageman
shageman / conductor.rb
Created November 17, 2011 01:20 — forked from paul/conductor.rb
class Conductor
include ActiveModel::Conversion
extend ActiveModel::Naming
include ActiveModel::Validations
class_attribute :object_names
def self.presents(*object_names)
self.object_names = object_names
object_names.each do |object_name|
class SignUpPage
def initialize
current_path.should == sign_up_path
end
def with_email(email)
fill_in "Login", :with => email
end
def with_password(password, confirmation = password)
@shageman
shageman / .ideamodules.xml
Created February 8, 2012 01:38
InetlliJ Modules in Rubymine
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/custom_engine1/module1.iml" filepath="$PROJECT_DIR$/custom_engine1/custom_engine1.iml" />
<module fileurl="file://$PROJECT_DIR$/custom_engine2/module2.iml" filepath="$PROJECT_DIR$/custom_engine2/custom_engine2.iml" />
</modules>
</component>
</project>
@shageman
shageman / predicate_matchers.rb
Created March 8, 2012 03:40
The problem of rspec predicate matchers
require 'rspec/core'
class VeryImportantQuestions
def self.really?(answer)
answer == 'Yes. I am telling you.'
end
def self.really_really?(answer)
answer == 'Yes. I am telling you.' ? 42 : nil
end