Skip to content

Instantly share code, notes, and snippets.

@dkubb
dkubb / gist:556033
Created August 29, 2010 06:26
DO API ideas
connection = DataObjects::Connection.new(uri)
connection.close
# immediately executed statements
reader = connection.query('SELECT * FROM table WHERE id = ?', 1)
reader.set_types(Integer) # returns self for chaining
reader.each { |row| ... }
@dkubb
dkubb / dm_sunspot.rb
Created June 16, 2011 18:57
DataMapper and Sunspot Integration Spike
# gem install datamapper dm-sqlite-adapter sunspot sunspot_rails activesupport
require 'rubygems'
require 'datamapper'
require 'sunspot'
require 'sunspot/rails'
require 'active_support/all'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'sqlite::memory:')
@crosebrugh
crosebrugh / application_controller.rb
Created August 4, 2011 19:36
Rails Admin config and runtime management
# add this to your ../app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
before_filter { |c| _admin_prolog(c) } # should be the first one!
after_filter { |c| _admin_epilog(c) } # should be the last one!
@metaskills
metaskills / wait_until.rb
Last active May 2, 2024 01:51
Never sleep() using Capybara!
# WAIT! Do consider that `wait` may not be needed. This article describes
# that reasoning. Please read it and make informed decisions.
# https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations?
describe 'Modal' do
should 'display login errors' do
visit root_path
@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@headius
headius / gist:1319127
Created October 27, 2011 09:17
JRuby master configuration properties.
These properties can be used to alter runtime behavior for perf or compatibility.
Specify them by passing -X<property>=<value>
or if passing directly to Java, -Djruby.<property>=<value>
or put <property>=<value> in .jrubyrc
compiler settings:
compile.mode=[JIT, FORCE, OFF]
Set compilation mode. JIT = at runtime; FORCE = before execution. Default is JIT.
compile.dump=[true, false]
@cmeiklejohn
cmeiklejohn / rbenv-install-system-wide.sh
Created November 22, 2011 04:59
rbenv install and system wide install on Ubuntu 10.04 LTS.
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential
apt-get -y install git-core
# Install rbenv
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv
# Add rbenv to the path:
@jeffmccune
jeffmccune / repair_mac_ruby_links.sh
Created December 1, 2011 17:26
Repair Mac OS X Ruby Symlinks
@nz
nz / bonsai.md
Last active July 3, 2018 22:51
Bonsai.io - The ElasticSearch add-on for Heroku

Bonsai offers a Heroku add-on for ElasticSearch.

ElasticSearch is the latest generation search engine built on the powerful Lucene library. Its API is freshly designed around modern RESTful JSON conventions, making it easy to learn and understand. ElasticSearch will automatically index your JSON data with sensible defaults, which means that you can get started without writing a single line of configuration. ElasticSearch is the perfect place to start for anyone new to full-text search engine concepts, or for anyone who is looking for more clarity and less ceremony in their search engine.

The ElasticSearch internals are designed from the ground up with data distribution in mind. This means you get greater scalability, performance and reliability in a cloud hosted environment. An ElasticSearch index can automatically shard your data, to scale to the largest indexes and support high volumes of write traffic. All of our

@nz
nz / configuring tire for bonsai.md
Last active October 1, 2015 18:58
Configuring Tire to work with Bonsai

1. Configure Tire to use the Bonsai ElasticSearch Heroku add-on

gem 'tire'

config/initializers/bonsai.rb

ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']