This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
images = @album.image_assignments | |
changed = Array.new | |
# Get the images that changed order | |
for image in images | |
order = params["order_#{image.image_id}".to_sym] | |
if !order.blank? && order =~ /^\d+$/ && image.position.to_i != order.to_i | |
image.position = order.to_i | |
changed << image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Options: | |
# * :tries - Number of retries to perform. Defaults to 1. | |
# * :on - The Exception on which a retry will be performed. Defaults to Exception, which retries on any Exception. | |
# | |
# Example | |
# ======= | |
# retryable(:tries => 1, :on => OpenURI::HTTPError) do | |
# # your code here | |
# end | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put in config/application.rb | |
config.to_prepare do | |
::PagesController.module_eval do | |
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
end | |
::Page.module_eval do | |
after_save :clear_static_caching! | |
after_destroy :clear_static_caching! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__or_fn = lambda do |*scopes| | |
where = [] | |
joins = [] | |
includes = [] | |
# for some reason, flatten is actually executing the scope | |
scopes = scopes[0] if scopes.size == 1 | |
scopes.each do |s| | |
w = [] | |
s.where_clauses.each do |where_clause| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Capybara::Node::Element.class_eval do | |
def click_at(x, y) | |
wait_until do | |
right = x - (native.size.width / 2) | |
top = y - (native.size.height / 2) | |
driver.browser.action.move_to(native).move_by(right.to_i, top.to_i).click.perform | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# As root user | |
# Update the OS | |
sudo apt-get update | |
sudo apt-get upgrade | |
sudo apt-get dist-upgrade | |
# Setup Hostname & TimeZone | |
echo "{{HOSTNAME}}" > /etc/hostname | |
hostname -F /etc/hostname | |
dpkg-reconfigure tzdata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyApp | |
class Application < Rails::Application | |
if Rails.env == 'test' | |
require 'diagnostic' | |
config.middleware.use(MyApp::DiagnosticMiddleware) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /usr/src | |
$ wget http://nginx.org/download/nginx-1.0.15.tar.gz | |
$ tar xzvf ./nginx-1.0.15.tar.gz | |
$ rm -f ./nginx-1.0.15.tar.gz | |
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz | |
$ tar xzf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz | |
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz | |
$ tar xzf openssl-1.0.1c.tar.gz && rm -f openssl-1.0.1c.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http { | |
map $http_user_agent $limit_bots { | |
default ''; | |
~*(google|bing|yandex|msnbot) $binary_remote_addr; | |
} | |
limit_req_zone $limit_bots zone=bots:10m rate=1r/m; | |
server { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :attachments do | |
task :migrate_to_s3 => :environment do | |
require 'aws/s3' | |
# Load credentials | |
s3_options = YAML.load_file(File.join(Rails.root, 'config/s3.yml')).symbolize_keys | |
bucket = s3_options[:bucket_name] | |
# Establish S3 connection |
OlderNewer