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 |
| wget https://cots.gitn.net.my/1govnet/upload/SSL_Extended.cer | |
| openssl x509 -in SSL_Extended.cer -inform PEM -out Mampu.crt | |
| mv SSL_Extended.cer Mampu.pem | |
| sudo cp Mampu.crt /etc/ssl/certs | |
| sudo cp Mampu.pem /usr/local/share/ca-certificates/ | |
| sudo update-ca-certificates | |
| export NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/Mampu.pem |
| 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 |
| class RoutesReloader | |
| def initialize(app) | |
| @app = app | |
| end | |
| def call(env) | |
| reload_routes_if_changed | |
| return *@app.call(env) | |
| end |
| #respond remote true redirect | |
| def create | |
| @post = Post.new(post_params) | |
| respond_to do |format| | |
| if @post.save | |
| format.js { redirect_to post_comments_path(@post), turbolinks: false} | |
| #or | |
| #redirect_to post_comments_path(@post), status: 303, turbolinks: false | |
| else | |
| format.html { render :new } |
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.
#install
sudo apt-get install postgresql
sudo apt-get install libpq-dev
# for hstore
sudo apt-get install postgresql-contrib
##Modify /etc/postgresql/9.3/main/pg_hba.conf access control, local TCP access set to full trust
| require 'active_record' | |
| require 'sqlite3' | |
| ActiveRecord::Base.establish_connection( | |
| :adapter => "sqlite3", | |
| :database => "teachers.db" | |
| ) | |
| # Migration | |
| ActiveRecord::Schema.define do |