Skip to content

Instantly share code, notes, and snippets.

@royw
royw / example.html
Created Aug 3, 2013
Addition to CollapsibleLists.js to support expand all, collapse all.
View example.html
<div id="floatingbar">
<ul>
<li><a href="#" onClick="CollapsibleLists.expand(true)">Expand All</a></li>
<li><a href="#" onClick="CollapsibleLists.expand(false)">Collapse All</a></li>
</ul>
</div>
@royw
royw / home_spec.rb
Created Dec 9, 2012
Issue where provide json handling is being invoked on rspec+capybara visit on Ramaze 2012.12.08
View home_spec.rb
require 'spec_helper'
# abridged
feature "Home Page" do
background do
@session.header 'Accept', 'text/html'
end
scenario 'Accessing the home page' do
visit('/')
@royw
royw / gist:1812150
Created Feb 13, 2012
Example code showing @pager.navigation
View gist:1812150
# This gist originally showed the problem where I was not seeing the pagination navigation controls.
# This gist now shows how to correctly use pagination navigation controls.
# Thank you Yorick!
# Ramaze thread: http://groups.google.com/group/ramaze/browse_thread/thread/b40c827dce8d6ec1
#####
# controller/init.rb:
class Controller < Ramaze::Controller
layout :default
helper :xhtml, :paginate, :gestalt
@royw
royw / gist:1260479
Created Oct 3, 2011
DataMapper query returning duplicates
View gist:1260479
#!/usr/bin/env ruby
require 'rubygems'
require 'data_mapper'
require 'extlib'
require 'pp'
require 'rspec'
# If you want the logs displayed you have to do this before the call to setup
DataMapper::Logger.new($stdout, :debug)
View gist:231789
require 'spec'
require 'dm-core'
require 'dm-validations'
require 'dm-timestamps'
require 'dm-types'
require 'dm-aggregates'
DataMapper.setup(:default, 'mysql://localhost/test')
# DataMapper.setup(:default, 'sqlite3::memory:')
View embedded_documents.rb
require 'mongo_mapper'
require 'spec'
MongoMapper.connection = Mongo::Connection.new('localhost')
MongoMapper.database = 'tmp'
class Cast
include MongoMapper::EmbeddedDocument
key :person, Integer
key :name, String
View gist:216763
require 'mongo_mapper'
require 'spec'
require 'extlib'
MongoMapper.connection = Mongo::Connection.new('localhost')
MongoMapper.database = 'tmp'
class Bar
include MongoMapper::EmbeddedDocument
key :title, String
View gist:213584
require 'mongo_mapper'
require 'spec'
MongoMapper.connection = Mongo::Connection.new('localhost')
MongoMapper.database = 'tmp'
class Book
include MongoMapper::Document
key :title, String
key :_keywords, Array, :index => true
View mongomapper $where examples
require 'mongo_mapper'
require 'spec'
require 'log4r'
require 'versionomy'
# Logger used for logging MongoDB database commands
Log4r::Logger.new('TMP')
Log4r::Logger['TMP'].outputters = Log4r::StdoutOutputter.new(:console)
Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => "%m")
Log4r::Logger['TMP'].level = Log4r::DEBUG
View gist:205303
require 'mongo_mapper'
require 'spec'
MongoMapper.connection = Mongo::Connection.new('localhost')
MongoMapper.database = 'tmp'
class Test
include MongoMapper::Document
key :first, Integer
key :second, Integer