Skip to content

Instantly share code, notes, and snippets.

View robyurkowski's full-sized avatar

Rob Yurkowski robyurkowski

View GitHub Profile
function rr {
cwd=`pwd`
not_found=true
while [[ "`pwd`" != "/" && $not_found == true ]]; do
if [[ ( -f '.rails_root' ) || ( -d 'app' && -d 'config' ) ]]; then
not_found=false
cd `pwd`
continue
fi
cd ..
@robyurkowski
robyurkowski / spec_helper.rb
Created February 23, 2012 19:59
Spec helper for @pivotal-liquidit
def setup_environment
# Configure Rails Environment
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../dummy/config/environment", __FILE__)
require 'rspec/rails'
require 'capybara/rspec'
require 'factory_girl_rails'
2012-03-05T20:32:02+00:00 heroku[web.1]: Stopping process with SIGKILL
2012-03-05T20:32:04+00:00 heroku[web.1]: Process exited with status 137
2012-03-05T20:32:06+00:00 app[web.1]: [2012-03-05 20:32:06] INFO WEBrick 1.3.1
2012-03-05T20:32:06+00:00 app[web.1]: [2012-03-05 20:32:06] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2012-03-05T20:32:06+00:00 app[web.1]: [2012-03-05 20:32:06] INFO WEBrick::HTTPServer#start: pid=1 port=56080
2012-03-05T20:32:07+00:00 heroku[web.1]: State changed from starting to up
2012-03-05T20:34:01+00:00 heroku[run.1]: State changed from created to starting
2012-03-05T20:34:07+00:00 app[run.1]: Awaiting client
2012-03-05T20:34:07+00:00 app[run.1]: Starting process with command `bundle exec rake db:migrate`
2012-03-05T20:34:08+00:00 heroku[run.1]: State changed from starting to up
# Generates the link to determine where the site bar switch button returns to.
def site_bar_switch_link
if admin? ? admin_switch_link : frontend_switch_link
end
def admin_switch_link
link_url = session[:website_return_to].present? ? session[:website_return_to] :
refinery.root_path(:locale => (Refinery::I18n.default_frontend_locale if Refinery.i18n_enabled?))
link_to t('.switch_to_your_website', site_bar_translate_locale_args), link_url, {:class => 'btn btn-primary'}
# Generates the link to determine where the site bar switch button returns to.
def site_bar_switch_link(html_options = {})
if admin? ? admin_switch_link(html_options) : frontend_switch_link(html_options)
end
def admin_switch_link(html_options = {})
link_to t('.switch_to_your_website', site_bar_translate_locale_args),
session[:website_return_to] || refinery.root_path(:locale => (Refinery::I18n.default_frontend_locale if Refinery.i18n_enabled?)),
html_options
end
@robyurkowski
robyurkowski / Gemfile
Created June 27, 2012 15:44
Customizing Menus in RefineryCMS 2.0
# Add this:
gem 'cells'
FactoryGirl.define do
factory :user do
sequence(:email) { |n| "email#{n}@example.com" }
password "secret"
factory :admin do
after_build {|u| u.roles << :admin }
end
end
end
module Admin
class UsersController < ::AuthenticatedController
load_and_authorize_resource
def index
users = User.untrashed
render_with :users => users
end
def trashed
@robyurkowski
robyurkowski / s3_metadata_change.rb
Last active December 18, 2015 12:39
Uploading a selection of S3 files' metadata
options = {
'x-amz-metadata-directive' => 'REPLACE',
'Content-Type' => 'application/pdf',
'Content-Disposition' => nil
}
count = 0
files = directory.files.each do |file|
next unless file.key =~ /pdf\z/i
count += 1