Skip to content

Instantly share code, notes, and snippets.

View mcmire's full-sized avatar
🎯
Not a lot of time for side projects these days, so ping me if I'm unresponsive!

Elliot Winkler mcmire

🎯
Not a lot of time for side projects these days, so ping me if I'm unresponsive!
View GitHub Profile

Setting up Capybara (w/ @culerity support) using rvm

The following steps will setup ruby 1.8.7-p174 as well as the gems required for Capybara and Culerity support. It will also install Celerity using macports-managed JRuby. Note: sudo is not used.

Steps: $ rvm install 1.8.7-p174 $ rvm 1.8.7-p174 $ gem install rails cucumber capybara webrat rspec cucumber-rails email_spec database_cleaner rspec-rails factory_girl clearance formtastic sqlite3-ruby pg thin mongrel paperclip will_paginate ZenTest autotest-rails culerity $ rvm jruby-1.4.0 $ gem install celerity

# In all comments :stage represents the stage you want to use (i.e. production, staging, etc.)
# Follow these steps AFTER modifying your /etc/apache2/httpd.conf file to add a new rails instance and running `sudo apachectl restart`
# Steps to setup capistrano for the first time:
# - cap :stage deploy:setup # this creates the correct directory tree
# - cap :stage deploy:check # this checks to make sure setup ran
# - cap :stage deploy:update # this updates the server with the app code
# - ssh :user@:main_server # fill in the correct user and server here
# - cd :deploy_to/current # again fill in the correct deploy to dir
# - RAILS_ENV=:stage sudo rake gems:install # this installs gems that need native compiling
require 'culerity'
$env_javascript_tag = ENV['CULERITY_JAVASCRIPT_TAG'] || '@javascript'
def set_jruby_env
rvm_jruby = ENV['CULERITY_RVM_JRUBY'] || 'jruby'
info = `rvm info #{rvm_jruby}`
gem_home = info =~ /GEM_HOME:\s?"([^"]*)"/ ? $1 : ''
gem_path = info =~ /GEM_PATH:\s?"([^"]*)"/ ? $1 : ''
my_ruby_home = info =~ /MY_RUBY_HOME:\s?"([^"]*)"/ ? $1 : ''
require 'minitest/unit'
require 'minitest/spec'
require 'rubygems'
require 'ansi'
class MiniTest::Unit
include ANSI::Code
PADDING_SIZE = 4
Before("@culerity,@celerity,@javascript") do |scenario|
unless @env_rvm_jruby
@env_rvm_jruby = {}
require 'yaml'
# NOTE: updated due to change in `rvm info` structure
# assumes JRuby 1.5, but no error checking if it's missing
rvm_info = YAML::load(`rvm info jruby`)['jruby-1.5.0']
rvm_info['environment'].each do |k, v|
@env_rvm_jruby[k] = v
end
@markbates
markbates / watchr script
Created July 20, 2010 15:25
A Watchr script for rails, rspec, and cucumber
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
puts message
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)

StillMaintained status buttons

Nice status buttons you can add to your README file in your Github repositories to show your project’s current status, fetched from StillMaintained:

   

For a live demo, check out StillMaintained’s own README.

Code

# a little rake task to rename a Rails3 project. handles editing files,
# renaming files, and renaming directories. use NOOP=true to view
# edits/renames before performing them.
#
begin
### gem install map
#
### gem 'map'
#
# an application initializer which configures a rails application for logging
#
module RailsApp
class Application < Rails::Application
# load the libs - don't forget lockfile for process safe log rolling
#
require 'logging' unless defined?(Logging)
require 'lockfile' unless defined?(Lockfile)
# do the actual logging configuration - this one will keep 7 log files of
@rbxbx
rbxbx / incrudable.rb
Created March 3, 2011 14:35
CRUD with decent_exposure
# pulled out of a project authored by tpope && rbxbx
# not generic enough for general use, but a decent example of
# an application specific restful crud abstraction
module Incrudable
extend ActiveSupport::Concern
included do
expose(controller_name) { controller_name.classify.constantize.scoped }
expose(controller_name.singularize)