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
# 1) Create your private key (any password will do, we remove it below) | |
$ cd ~/.ssh | |
$ openssl genrsa -des3 -out server.orig.key 2048 | |
# 2) Remove the password | |
$ openssl rsa -in server.orig.key -out server.key |
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
class UserProfile < ActiveRecord::Base | |
has_attached_file :picture, | |
styles: { | |
original: {geometry: '1000x0>'}, | |
thumb: '100x100#', | |
large: '300x200>', | |
}, | |
convert_options: {large: "-quality 80 -strip -interlace Plane"}, | |
default_url: "http://s3-ap-southeast-1.amazonaws.com/#{ENV["S3_BUCKET"]}/user_profiles/placeholder.png", | |
path: (Rails.env == 'test' || Rails.env == 'development') ? ":rails_root/public/images/:class/:id/:style/:filename" : "/:class/:id/:style/:filename", |
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
SELECT relname, PG_SIZE_PRETTY(PG_TOTAL_RELATION_SIZE(relid)) FROM pg_stat_all_tables WHERE schemaname != 'pg_toast' AND relname LIKE 'pg_%' ORDER BY PG_TOTAL_RELATION_SIZE(relid) DESC; |
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
require 'rubygems' | |
require 'aws-sdk' | |
s3 = AWS::S3.new( | |
:access_key_id => 'XXXXXXXXXXXXXXX', | |
:secret_access_key => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') | |
bucket = s3.buckets['your_bucket_name'] | |
ten_year_in_seconds = 10 * 365 * 24 * 60 * 60 |
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
Delivered-To: XXXX@mydomain.com | |
Received: by 10.229.25.199 with SMTP id a7csp15957qcc; | |
Wed, 7 May 2014 05:55:13 -0700 (PDT) | |
X-Received: by 10.182.241.67 with SMTP id wg3mr44908240obc.16.1399467313246; | |
Wed, 07 May 2014 05:55:13 -0700 (PDT) | |
Return-Path: <rahul100885@gmail.com> | |
Received: from mail-pd0-x22d.google.com (mail-pd0-x22d.google.com [2607:f8b0:400e:c02::22d]) | |
by mx.google.com with ESMTPS id yb4si1843965pbb.403.2014.05.07.05.55.12 | |
for <XXXX@mydomain.com> | |
(version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); |
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
MyApp::Application.routes.draw do | |
# If you concern about SEO then send permanent redirect (301) on old routes to new routes | |
# It is always better to do this setting in web server that is in nginx or apache. | |
# Here I am showing how to do it in rails routes file | |
get '/users/sign_in', to: redirect("/sign-in") | |
get '/users/sign_up', to: redirect("/sign-up") | |
# Need to skip session and registration so that we can override them in devise_scope block | |
# If we not do so then default route of devise continue to work | |
devise_for :users, :skip => [:sessions, :registrations] |
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
# spec/support/device_size.rb | |
module DeviceSize | |
extend ScreenSize | |
RSpec.configure do |config| | |
config.before(:each) do | |
if example.metadata[:device_size].blank? | |
# set screen size default to :large |
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
# spec/support/screen_size.rb | |
module ScreenSize | |
SCREENS = { | |
small: { width: 590 , height: 768 }, | |
medium: { width: 1025, height: 768 }, | |
large: { width: 1280, height: 768 } | |
} |
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
If your database supports setting the isolation level for a transaction, | |
you can set it like so: | |
Post.transaction(isolation: :serializable) do | |
# ... | |
end | |
Valid isolation levels are: | |
* `:read_uncommitted` |
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
railsadmin@prodApp:~/application/production/my_app$ sudo bundle install | |
[sudo] password for lvadmin: | |
/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:49:in `initialize': not in gzip format (Zlib::GzipFile::Error) | |
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:49:in `new' | |
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:49:in `initialize' | |
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:64:in `each' | |
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:55:in `loop' | |
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_reader.rb:55:in `each' | |
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:32:in `initialize' | |
from /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/site_ruby/1.8/rub |
NewerOlder