Skip to content

Instantly share code, notes, and snippets.

= IKEA GraphGist =
This gist is to complement the http://blog.bruggen.com/2013/09/ikea-wardrobes-and-graphs-perfect-fit.html[more elaborate blogpost] that I wrote about using http://neo4j.org[neo4j] to model the partlist and the assembly process of two IKEA wardrobes.
First, we will create a part of the graph using this model:
image::https://lh4.googleusercontent.com/7XxUuCjnFtDhO-JAI5Ia6tcYZkQoMfcv_1pNE0mTA2cx76vIySrBU0z0tnykAPvqsMrZZD-cca3Q7ca-ERI0f5sDsGAUCEJTIx7wt15mxKhFEXeYFrZD_vEGJQ[]
[source,cypher]
----
@dsisnero
dsisnero / README.md
Last active August 29, 2015 14:10 — forked from fnichol/README.md

Why?

There is a long standing issue in Ruby where the net/http library by default does not check the validity of an SSL certificate during a TLS handshake. Rather than deal with the underlying problem (a missing certificate authority, a self-signed certificate, etc.) one tends to see bad hacks everywhere. This can lead to problems down the road.

From what I can see the OpenSSL library that Rails Installer delivers has no certificate authorities defined. So, let's go fetch some from the curl website. And since this is for ruby, why don't we download and install the file with a ruby script?

Installation

The Ruby Way! (Fun)

2.1.2 :004 > pp Google::Contacts.new(client).contacts
[{:emails=>{:other=>{:address=>"fake@gmail.com", :primary=>true}},
:phone_numbers=>
{:main=>"(555) 123-1234", :home=>"123-123-1234", :mobile=>"555-555-5555"},
:handles=>
{:home=>{:address=>"something", :protocol=>"AIM"},
:other=>{:address=>"something-else", :protocol=>"AIM"}},
:nickname=>nil,
:websites=>[],
include 'dm-is-list'
class Node
include DataMapper::Resource
property :id, Serial
# other properties...
has n, :parts
end
#!/usr/bin/env ruby -Ku
require 'rubygems'
require 'dm-core'
require 'dm-sweatshop'
require 'bacon'
#DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'sqlite3::memory:')
@dsisnero
dsisnero / graph_models.rb
Created May 12, 2010 20:03
Graph of data mapper
#!/usr/bin/env ruby -Ku
# encoding: utf-8
require 'rubygems'
require 'dm-core'
require 'graphviz'
def recursive_require(dir)
Dir.glob("#{dir}/**/*.rb").sort.each { |file| require file }
#!/usr/bin/env ruby -Ku
# encoding: utf-8
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'sqlite3::memory:')
#!/usr/bin/env ruby -Ku
# encoding: utf-8
require 'pp'
require 'rubygems'
require 'dm-core'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'sqlite3::memory:')
class AppBuilder < Rails::AppBuilder
#include Thor::Actions
#include Thor::Shell
@@versions = %w( 1.4.2 1.4.1 1.4.0 1.3.2 1.3.1 1.3.0 1.2.6 )
def test
append_test_gems
rspec

Open question for the Neo4j.rb community:

ActiveNode models allow for query chaining like so:

object.foo.bar.baz

This is a powerful way to traverse entities which builds Cypher queries under the covers. It is also currently possible to name your variables for later use like so:

object.foo(:f).bar.baz(:b).pluck(:f, 'collect(b)')