Apacheでwwwありのアクセスをなしに転送する

ウェブサーバーで、wwwありのドメインとなしのドメインではGoogleで別評価されるようなので
Apacheの.htaccessで301リダイレクトしてみました

公開しているWebディレクトリの転送したい場所で、.htaccessを設置して

RewriteCond %{HTTP_HOST} ^www.sample.jp [NC]
RewriteRule ^(.*)$ http://sample.jp/$1 [R=301,L]                                                   

こんな感じです

Virtualboxをアップデートしたらエラー発生

DKMSをいれたらとのことなので入れてみる

$ sudo apt-get install dkms

が入ってました

指示通りコマンド実行

$ sudo /etc/init.d/vboxdrv setup

Stopping VirtualBox kernel modules ...done.
Uninstalling old VirtualBox DKMS kernel modulesError! Could not locate dkms.conf file.
File:  does not exist.
 ...done.
Removing old VirtualBox pci kernel module ...done.
Removing old VirtualBox netadp kernel module ...done.
Removing old VirtualBox netflt kernel module ...done.
Removing old VirtualBox kernel module ...done.
Trying to register the VirtualBox kernel modules using DKMSError! DKMS tree already contains: vboxhost-4.3.26
You cannot add the same module/version combo more than once.
 ...failed!
  (Failed, trying without DKMS)
Recompiling VirtualBox kernel modules ...done.
Starting VirtualBox kernel modules ...done.

なんだかFailedって出てるけど、Virtualboxが動くようになりました

rakeでタスクの一覧を見る

Spreeのときはデフォルトの管理ユーザーを作るのに

$ rake spree_auth:admin:create

を使ったりします
参考: Ruby on RailsにSpreeを入れてみた | bgbgbg

こういったタスクなにがあるんだっけ..?のときに

$ rake -T

とすると一覧で見れて便利です

ちなみに spree を入れた時の結果はこんな感じ

rake assets:clobber                                 # Remove compiled assets
rake assets:environment                             # Load asset compile environment
rake assets:precompile                              # Compile all the assets named in config.assets.precompile
rake cache_digests:dependencies                     # Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)
rake cache_digests:nested_dependencies              # Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)
rake db:bootstrap                                   # Bootstrap is: migrating, loading defaults, sample data and seeding (for all extensions) and load_products tasks
rake db:create                                      # Creates the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:create:all to create all databases in the config)
rake db:drop                                        # Drops the database from DATABASE_URL or config/database.yml for the current RAILS_ENV (use db:drop:all to drop all databases in the config)
rake db:fixtures:load                               # Load fixtures into the current environment's database
rake db:load_dir[dir]                               # Loads fixtures from the the dir you specify using rake db:load_dir[loadfrom]
rake db:load_file[file,dir]                         # Loads a specified fixture file:
rake db:migrate                                     # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
rake db:migrate:status                              # Display status of migrations
rake db:remigrate                                   # Migrate schema to version 0 and back up again
rake db:rollback                                    # Rolls the schema back to the previous version (specify steps w/ STEP=n)
rake db:schema:cache:clear                          # Clear a db/schema_cache.dump file
rake db:schema:cache:dump                           # Create a db/schema_cache.dump file
rake db:schema:dump                                 # Create a db/schema.rb file that is portable against any DB supported by AR
rake db:schema:load                                 # Load a schema.rb file into the database
rake db:seed                                        # Load the seed data from db/seeds.rb
rake db:setup                                       # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the database first)
rake db:structure:dump                              # Dump the database structure to db/structure.sql
rake db:structure:load                              # Recreate the databases from the structure.sql file
rake db:version                                     # Retrieves the current schema version number
rake deface:clean                                   # Removes all precompiled override templates
rake deface:failures_by_virtual_path[virtual_path]  # Report on failing overrides for a partial/template
rake deface:get_result[virtual_path]                # Get the resulting markup for a partial/template
rake deface:precompile                              # Precompiles overrides into template files
rake deface:test_all                                # Load and apply all overrides, and output results
rake deface:test_selector[virtual_path,selector]    # Applies selectors to given partial/template, and returns match(s) source
rake doc:app                                        # Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE="Custom Title")
rake email:test                                     # Sends test email to specified address - Example: EMAIL=spree@example.com bundle exec rake test:email
rake exchanges:charge_unreturned_items              # Takes unreturned exchanged items and creates a new order to charge
rake log:clear                                      # Truncates all *.log files in log/ to zero bytes (specify which logs with LOGS=test,development)
rake middleware                                     # Prints out your Rack middleware stack
rake notes                                          # Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)
rake notes:custom                                   # Enumerate a custom annotation, specify with ANNOTATION=CUSTOM
rake paperclip:clean                                # Cleans out invalid attachments
rake paperclip:refresh                              # Refreshes both metadata and thumbnails
rake paperclip:refresh:metadata                     # Regenerates content_type/size metadata for a given CLASS (and optional ATTACHMENT)
rake paperclip:refresh:missing_styles               # Regenerates missing thumbnail styles for all classes using Paperclip
rake paperclip:refresh:thumbnails                   # Regenerates thumbnails for a given CLASS (and optional ATTACHMENT and STYLES splitted by comma)
rake rails:template                                 # Applies the template supplied by LOCATION=(/path/to/template) or URL
rake rails:update                                   # Update configs and some other initially generated files (or use just update:configs or update:bin)
rake routes                                         # Print out all defined routes in match order, with names
rake secret                                         # Generate a cryptographically secure secret key (this is typically used to generate a secret for cookie sessions)
rake spec                                           # Run all specs in spec directory (excluding plugin specs)
rake spec:controllers                               # Run the code examples in spec/controllers
rake spec:helpers                                   # Run the code examples in spec/helpers
rake spree:install:migrations                       # Copy migrations from spree to application
rake spree:reset_taxon_permalinks                   # Resets all taxon permalinks
rake spree_api:install:migrations                   # Copy migrations from spree_api to application
rake spree_auth:admin:create                        # Create admin username and password
rake spree_auth:install:migrations                  # Copy migrations from spree_auth to application
rake spree_i18n:install:migrations                  # Copy migrations from spree_i18n to application
rake spree_paypal_express:install:migrations        # Copy migrations from spree_paypal_express to application
rake spree_sample:load                              # Loads sample data
rake stats                                          # Report code statistics (KLOCs, etc) from the application or engine
rake test                                           # Runs all tests in test folder
rake test:all                                       # Run tests quickly by merging all types and not resetting db
rake test:all:db                                    # Run tests quickly, but also reset db
rake test:db                                        # Run tests quickly, but also reset db
rake time:zones:all                                 # Displays all time zones, also available: time:zones:us, time:zones:local -- filter with OFFSET parameter, e.g., OFFSET=-6
rake tmp:clear                                      # Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)
rake tmp:create                                     # Creates tmp directories for sessions, cache, sockets, and pids

bundleでインストールしたgemの場所を見たり開いたりする

rubyでgemをbundleでインストールした際、gemのソースが見たくなったら

$ bundle show rails
/home/vagrant/.rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/rails-4.2.0

などと場所がわかります

一気にエディタで開きたかったら

$ bundle open rails

で指定したエディタで開きます

エディタを指定してなければエラーが発生

To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR

そういうときはUbuntuの場合

$ vim ~/.vimrc

EDITOR="vim"

とか書き込んで、設定読み込み

$ source ~/.vimrc

で再度 bundle openしてあげるといいです