Skip to content

Instantly share code, notes, and snippets.

@unnitallman
unnitallman / gist:6533343
Created September 12, 2013 05:29
Script to copy objects from one S3 bucket to another. Works across buckets located in different geographical areas.
require 'rubygems'
require 'right_aws'
aws_access_key_id = 'access-id'
aws_secret_access_key = 'access-key'
target_bucket = 'yoursaycafe'
destination_bucket = 'unni-test'
s3 = RightAws::S3Interface.new(aws_access_key_id, aws_secret_access_key)
@unnitallman
unnitallman / gist:6533192
Created September 12, 2013 04:54
Creating a S3 bucket with location constraint
pry(main)> s3= AWS::S3.new(:region=> "eu-west-1")
=> <AWS::S3>
[3] pry(main)> s3.buckets
=> <AWS::S3::BucketCollection>
[4] pry(main)> s3.buckets.create
ArgumentError: wrong number of arguments (0 for 1..2)
from /Users/unni/.rvm/gems/ruby-2.0.0-p195@ehqv2/gems/aws-sdk-1.11.1/lib/aws/s3/bucket_collection.rb:91:in `create'
[5] pry(main)> s3.buckets.create("unni-test")
=> #<AWS::S3::Bucket:unni-test>
[6] pry(main)> s3.buckets
@unnitallman
unnitallman / capybara cheat sheet
Last active December 17, 2015 11:29 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
no change in User#usertype
def present_user
user_signed_in? ? current_user : non_logged_in_user
end
def non_logged_in_user
unverified_user_present? ? unverified_user : User.new
end
@unnitallman
unnitallman / gist:5268949
Last active December 15, 2015 13:39
brew update - fix
cd /usr/local
git fetch origin
git reset --hard origin/master
@unnitallman
unnitallman / gist:3910618
Created October 18, 2012 09:16
Running Pow in production environment
echo export RAILS_ENV=production > .powenv && touch tmp/restart.txt
@unnitallman
unnitallman / gist:2692255
Created May 14, 2012 06:41
mysql - home brew - my.cnf
sudo cp $(brew --prefix mysql)/support-files/my-small.cnf /etc/my.cnf
@unnitallman
unnitallman / gist:2692072
Created May 14, 2012 06:03
Custom time formats
#config/initializers/conversions.rb
Time::Conversions::DATE_FORMATS.update(:event => '%I:%M%p')
Time.now.to_s(:event) #=> "03:23PM"
@unnitallman
unnitallman / gist:2426598
Created April 20, 2012 06:30
Custom html in link text using link_to
=link_to "http://google.co.in" do
Hello
<i class="icon-search icon-white">Unni</i>
<b> World </b>
Customer.stub(:find).with(:all) { data_array }