Posts

Showing posts from February, 2018

Redirect non www to www via routes.rb in rails

In routes.rb: if Rails.env.production?     def query_params_to_query(request)       query_params = request.params.except(:path, :format, :subdomain)       query_params.any? ? "?#{query_params.to_query}" : ""     end       constraints(:subdomain => '') do       redirect_action = ->(params, _request) do         "https://www.example.com/#{params[:path]}#{query_params_to_query(_request)}"       end       root to: redirect(redirect_action)       get '/*path', to: redirect(redirect_action)     end   end

Copy files or folder from local to AWS s3 bucket

Import S3tools signing key:     wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | sudo apt-key add -  A dd the repo to sources.list:    sudo wget -O/etc/apt/sources.list.d/s3tools.list http://s3tools.org/repo/deb-all/stable/s3tools.list R efresh package cache and install the newest s3cmd:  sudo apt-get update && sudo apt-get install s3cmd   s3cmd --configure New settings: 2 Access Key: [your access key] 3 Secret Key: [your securet key] 4 Encryption password: somepassword 5 Path to GPG program: /usr/bin/gpg 6 Use HTTPS protocol: False 7 HTTP Proxy server name: 8 HTTP Proxy server port: 0 9 Test access with supplied credentials? [Y/n] Y 10 Please wait... 11 Success. Your access key and secret key worked fine :-) 12 13 Now verifying that encryption works... 14 Success. Encryption and decryption worked fine :-) 15 Save settings? [y/N] y Run Command To transfer file from source to   ============================== ============= s3cmd sync uploads s3://b