To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.
- Homebrew
- Mountain Lion
# Sets CORS headers for request from example1.com and example2.com pages | |
# for both SSL and non-SSL | |
SetEnvIf Origin "^https?://[^/]*(example1|example2)\.com$" ORIGIN=$0 | |
Header set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN | |
Header set Access-Control-Allow-Credentials "true" env=ORIGIN | |
# Always set Vary: Origin when it's possible you may send CORS headers | |
Header merge Vary Origin |
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work. | |
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0." | |
Database files have to be updated before starting the server, here are the steps that had to be followed: | |
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default | |
brew unlink postgresql | |
brew install [email protected] | |
brew unlink [email protected] | |
brew link postgresql |
# shortform git commands | |
alias g='git' | |
# push changes to an empty git repository for the first time | |
git push --set-upstream origin master | |
# Remove + and - from start of diff lines | |
git diff --color | sed "s/^\([^-+ ]*\)[-+ ]/\\1/" | less -r | |
# clear out git hooks |
To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.
require 'active_record' | |
require 'sqlite3' | |
ActiveRecord::Base.establish_connection( | |
:adapter => "sqlite3", | |
:database => "teachers.db" | |
) | |
# Migration | |
ActiveRecord::Schema.define do |
# Permissions cheatsheet | |
`chmod [a]bcd` | |
* bit a — sticky:1/setgid:2/setuid:4 (optional, default: 0) | |
* bit b — owner | x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7 | |
* bit c — group | x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7 | |
* bit d — everyone | x:1/w:2/r:4 - xw:3/xr:5/wr:6/xwr:7 | |
note: only file/dir owner can chmod it |
class ApplicationController < ActionController::Base | |
include Pundit | |
# Verify that controller actions are authorized. Optional, but good. | |
after_filter :verify_authorized, except: :index | |
after_filter :verify_policy_scoped, only: :index | |
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized | |
private |
If the namespace is not used then the commands will perform on top of the default database.
bundle exec rake db:create
bundle exec rake db:migrate
By using the namespace we are going to use all the configuration for our alternate DB.
bundle exec rake store:db:create
bundle exec rake store:db:migrate