Skip to content

Instantly share code, notes, and snippets.

@statonjr
statonjr / ActiveRepository.rb
Created October 15, 2012 12:48 — forked from bokmann/ActiveRepository.rb
ActiveRepository Strawman
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks
# of the ActiveRecord pattern. Several apps I have seen, and several
# developers I have spoken to are looking towards other patterns for object
# persistence. The major drawback with ActiveRecord is that the notion
# of the domain object is conflated with what it means to store/retrieve
# it in any given format (like sql, json, key/value, etc).
#
# This is an attempt to codify the Repository pattern in a way that would
# feel comfortable to beginner and seasoned Ruby developers alike.
#
@statonjr
statonjr / gist:3834254
Created October 4, 2012 15:10
Neo4j Calendar Example in Cypher on Relationship
START calendar=node(206) MATCH (calendar)<-[:`2012`]-(y)<-[:`8`]-(m)<-[:`13`]-(d)<-[:START_DATE]-(n) RETURN n.first_name, n.last_name AS Teammate
@statonjr
statonjr / gist:3834139
Created October 4, 2012 15:00
Neo4j Calendar Example in Cypher
START me=node(0) MATCH (me)-[:START_DATE]->(day)-[]->(month)-[]->(year) RETURN day.number, month.number, year.number
@statonjr
statonjr / gist:3779257
Created September 25, 2012 00:20
Siren H-Factors
H-Factors of Siren:
LE: Yes, through entities.href
LO: Yes, through links.href
LT: Yes, through actions
LN: Yes, through actions
LI: Yes, through actions
CR: No
CU: Yes, through actions.type
CM: Yes, through actions.method
@statonjr
statonjr / gist:3763489
Created September 21, 2012 19:47 — forked from philharvey/gist:3763444
Resources on Implementing REST/Hypermedia APIs
@statonjr
statonjr / gist:3717367
Created September 13, 2012 20:28
params for webmachine
def params
@params = {}
request.body.to_s.split(/&/).each do |kv|
key, value = kv.split(/=/)
if key && value
key, value = CGI.unescape(key), CGI.unescape(value)
@params[key] = value
end
end
@params
@statonjr
statonjr / gist:3610238
Created September 3, 2012 15:55 — forked from seancribbs/gist:1359079
Combining Roar with Webmachine.
require 'bundler/setup'
require 'roar/representer/json'
require 'roar/representer/feature/hypermedia'
require 'webmachine'
class Product
include Roar::Representer::JSON
include Roar::Representer::Feature::Hypermedia
property :name
@statonjr
statonjr / gist:3609999
Created September 3, 2012 15:15
Torquebox webmachine output
6:39,371 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "api-knob.yml"
10:56:50,866 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) warning: -J-Xmx1024m argument ignored (launched in same VM?)
10:56:50,866 INFO [org.torquebox.core.runtime] (http-localhost/127.0.0.1:8080-1) Creating ruby runtime (ruby_version: RUBY1_9, compile_mode: JIT, app: api, context: web)
10:56:51,413 INFO [org.torquebox.core.runtime] (http-localhost/127.0.0.1:8080-1) Setting up Bundler
10:56:51,825 INFO [org.torquebox.core.runtime] (http-localhost/127.0.0.1:8080-1) Created ruby runtime (ruby_version: RUBY1_9, compile_mode: JIT, app: api, context: web) in 0.95s
10:56:52,110 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) [2012-09-03 10:56:52] INFO WEBrick 1.3.1
10:56:52,111 ERROR [stderr] (http-localhost/127.0.0.1:8080-1) [2012-09-03 10:56:52] INFO ruby 1.9.2 (2012-05-01) [java]
10:56:52,115 ERROR [stderr] (RubyThread-115: /Users/statonjr/Documents/hendrick/api/vendor/bundle/jruby/1.9/gems/webmach
@statonjr
statonjr / env.rb
Created August 29, 2012 19:00
Monkey patching Aruba
require 'aruba/cucumber'
module Aruba
class Process
include Shellwords
def initialize(cmd, exit_timeout, io_wait)
@exit_timeout = exit_timeout
@io_wait = io_wait
@out = Tempfile.new("aruba-out")
@statonjr
statonjr / gist:3444873
Created August 24, 2012 02:28
TorqueBox upstart configuration
description "This is an upstart job file for TorqueBox"
pre-start script
bash << "EOF"
mkdir -p /var/log/torquebox
chown -R torquebox /var/log/torquebox
EOF
end script
start on (local-filesystems and net-device-up IFACE=eth0)