aws s3 sync s3://mybucket .
Using FTP to backup a large S3 bucket is slow. That's because FTP creates a new request for each file, downloads the file, and closes the request. That adds a lot of time to your download.
aws s3 sync s3://mybucket .
Using FTP to backup a large S3 bucket is slow. That's because FTP creates a new request for each file, downloads the file, and closes the request. That adds a lot of time to your download.
| # Open bash.rc in Terminal using the 'mate' command | |
| mate ~/.bashrc | |
| # Do you have this line in your .bashrc file? The PostgresApp should have added PostgresApp to your PATH. | |
| PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH" |
| # Load Twitter Widgets | |
| window.twttr = ((d, s, id) -> | |
| js = undefined | |
| fjs = d.getElementsByTagName(s)[0] | |
| unless d.getElementById(id) | |
| js = d.createElement(s) | |
| js.id = id | |
| js.src = "//platform.twitter.com/widgets.js" | |
| fjs.parentNode.insertBefore js, fjs | |
| window.twttr || t = { _e: [], ready: (f)-> t._e.push(f) } |
| # Add this to config/environments/development.rb | |
| # Limit your development log file to 5 MB | |
| config.logger = Logger.new(config.paths["log"].first, 1, 5242880) # 5 megabytes |
| # Gemfile | |
| gem 'rails', '4.0.0' | |
| gem 'pg' | |
| gem 'sass-rails', '~> 4.0.0' | |
| gem 'compass-rails', github: 'Compass/compass-rails', branch: 'rails4-hack' | |
| gem 'uglifier', '>= 1.3.0' | |
| gem 'coffee-rails', '~> 4.0.0' | |
| # etc... | |
| # config/initializers/compass.rb |
| rm -rf ~/Library/Application\ Support/TextMate/Cache/* |
| // Simple SCSS mixin for adding colored bullets to your <li> elements | |
| @mixin colored-bullet($color){ | |
| list-style:none; | |
| text-indent:-19px; // Adjust the text-indent to your specific needs based on your font-size and the typeface you're using | |
| &:before{ | |
| content:"\002022\00a0\00a0\00a0"; // Add a bullet character and three spaces before your <li> content starts | |
| color:$color; // Add color to the bullet | |
| } | |
| } |
| if reflection.options[:conditions] | |
| reflection_table = (reflection.options[:class_name] || reflection.options[:source] || reflection.name).gsub('::', '_').tableize | |
| if reflection.options[:conditions].to_s.include?("#{reflection_table}") | |
| send(through.name).select("DISTINCT #{through.quoted_table_name}.#{primary_key}").joins(reflection.options[:source]).where(reflection.options[:conditions]).map! { |r| r.send(primary_key) } | |
| else | |
| send(through.name).select("DISTINCT #{through.quoted_table_name}.#{primary_key}").where(reflection.options[:conditions]).map! { |r| r.send(primary_key) } | |
| end | |
| else | |
| send(through.name).select("DISTINCT #{through.quoted_table_name}.#{primary_key}").map! { |r| r.send(primary_key) } |
| # Validator: | |
| # /app/validators/date_validator.rb | |
| class DateValidator < ActiveModel::EachValidator | |
| def validate_each(record, attribute, value) | |
| unless value.to_s =~ /^\d{4}-\d{2}-\d{2}$/i | |
| record.errors[attribute] << (options[:message] || "is an invalid date") | |
| end | |
| end | |
| # Ruby 1.9 | |
| # Object.tap | |
| # Here we use tap to set the post factory's author (since Factory Girl doesn't create singleton instances). | |
| # Using tap passes a block where you can "tap" into the object. | |
| # At the end of the block, the object is returned. | |
| let(:author) { Factory(:author) } | |
| let(:post) { | |
| Factory(:post).tap do |p| | |
| post.update_attribute(:author, author) |