⌘T | go to file |
⌘⌃P | go to project |
⌘R | go to methods |
⌃G | go to line |
⌘KB | toggle side bar |
⌘⇧P | command prompt |
require 'spec_helper' | |
# comment out `config.order = "random"` in spec_helper or run rspec with `--order default` configuration (just for illustration) | |
# I have Database Cleaner set up in spec_helper too | |
$count1 = 0 | |
$count2 = 0 | |
describe "let and let!" do | |
describe "let!" do |
require 'spec_helper' | |
$count = 0 | |
$count_each = 0 | |
$count_all = 0 | |
shared_examples_for "before :each" do | |
it { should == 1 } | |
it { should == 2 } | |
end |
The documentation is okay, but it has some holes, and I had to read it many many times and play with the API myself to "get it" in terms of implementation. So here is a guide that I hope will help someone along the way.
DISCLAIMER: This is by no means the canonical or the most secure way to do this. Below are my findings upon my reading of the docs and the spec. But I might be wrong, very wrong.
This gist is meant to complement the documentation in https://getkong.org/plugins/oauth2-authentication/.
The Resource Owner Password Credentials Grant makes sense if we want to authenticate users who are using our trusted 1st party applications of our own service. (However, you might not want to trust your JavaScript SPA with your refresh token, and maybe you need to store that refresh token in the server on behalf of the SPA if you are paranoid about security. Disclaimer: I am not a security expert)
This issue is so infuriating that I'm going to take some time to write about it.
-
MOST IMPORTANT. Your local development server must be bound to IP address 0.0.0.0. Some do this by default, but many don't. You need to make sure that you run your local server with correct IP bindings. You may need to provide additional flags to your serve commands e.g.
polymer serve --hostname domain.local
,hugo serve --bind 0.0.0.0
. If you use a named domain likedomain.local
, it has to be defined in/etc/hosts
and pointing at 0.0.0.0. -
My Parallels setting is using Shared Network, nothing special there.
-
Open macOS Terminal and type
ifconfig
. Look for the value undervnic0
>inet
. It is typically10.211.55.2
.
user web; | |
# One worker process per CPU core. | |
worker_processes 8; | |
# Also set | |
# /etc/security/limits.conf | |
# web soft nofile 65535 | |
# web hard nofile 65535 | |
# /etc/default/nginx |
On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:
2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files) 2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...
An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.
-
- Instead of using
su
to runulimit
on the nginx account, useps aux | grep nginx
to locate nginx's process IDs. Then query each process's file handle limits usingcat /proc/pid/limits
(wherepid
is the process id retrieved fromps
). (Note:sudo
may be necessary on your system for thecat
command here, depending on your system.)
- Instead of using
- Added
fs.file-max = 70000
to /etc/sysctl.conf - Added `nginx soft nofile 1