Mock the method what not, where it is imported and not where it exists. If the test runs a method in a file called foo
. and inside foo
, you want to patch bar
, then the patch should be foo.bar
, even if bar
is imported from baz
originally.
Also gotchas: http://alexmarandon.com/articles/python_mock_gotchas/
If you are stacking up decorator patches, the order is down to up, the lowest one goes to the first agument.
Search someone by email:
gpg --keyserver hkp://keyserver.ubuntu.com --search-key '[email protected]'
For the AIM AWS:
- Make sure it is at least t2.small, nano will starve
- If you ssh, you need to run
docker-compose run --rm server bin/run ./manage.py database create_tables
docker-compose run --rm server create_db
for the postgres errors. IT WILL ADD EXTRA TABLES TO YOUR PROD DATABASE - If you already added a datasource and then restarted the docker-compose and now you cannot get in because of Postgres password error, simply add the third party postgres URI to the end of the env file, so it overwrites the test one. ( I think this happens, because redash will try to auth with the existing postgres first)
VIM biding key repeats on Mac: https://gist.github.com/kconragan/2510186 Python: IndentationError: unexpected indent: probably mixed spaces and tabs
block commenting:
Put your cursor on the first # character, press CtrlV (or CtrlQ for gVim), and go down until the last commented line and press x, that will delete all the # characters vertically.
For commenting a block of text is almost the same:
- First, go to the first line you want to comment, press CtrlV. This will put the editor in the VISUAL BLOCK mode.
- Then using the arrow key and select until the last line
- Now press ShiftI, which will put the editor in INSERT mode and then press #. This will add a hash to the first line.
- Then press Esc (give it a second), and it will insert a # character on all other selected lines.
here_document
is good, it can deliver you from the pain of echo swallowing quotes and many more. use it, and also for piping do like:
cat <<EOF | base64
"this will be base64"
EOF
try stty sane
- Basically follow this but with the following caveats.
- For a service account change the authenticator to a JWT like this
- You cant NOT update a service account to have domain wide delegation AFTER it is created. The button is there, but it will tell you you don't have permissions, and then it will appear and disappear. So you need to enable it upon creation.
- You need to include the
subject
field in the JWT authenticator, not shown in the link above. Like this; Code is here - The original GCP link says
users = response.users
that is incorrect, it should beusers = response.data.users
To authenticate without checking in the client_secret.json
you can stringify and parse the JSON.
Inspecting the scope: choose an element and
angular.element($0).scope()
you can only call close() on a $modalInstance, when you pass it to a controller.
kubectl get <Resource> <ResourceName> -o yaml
simple triggers don't need installing. If a trigger needs permission it will get wiped and needs installing. The scope of the triggers is limited to the trigger code and will not look at all the script to see if permission is required. Unlike normal scripts, where if a function has a permission requiring method but is not even called and another non-permission requiring method is called, then the non-permission requiring will ask for authorization.
Most probably due to the pager, add -P pager=off to the psql commands, or use \pset
As a super user ask postgres to show where the hba file is:
sudo su postgres -c psql
postgres=> SHOW hba_file;
Go there and edit and add your host:
host all(this is user) all(this is database) xxx.xx.xx.xx/32 trust
The restart postgres:
sudo /etc/init.d/postgresql restart
pg_dump -Fc postgres://user:pass@host:port/database > pg.dump
pg_restore -C -d postgres://user:pass@host:port/database pg.dump
with a file.sql.gzip
gunzip file.sql.gzip
cat file.sql | psql postgres://user:password@host:port/database
select unnest(enum_range(null, null::name_of_enum_type));
if
SELECT email FROM users WHERE _id IN (1,2)
will return nothing. Then run:
WITH updated AS
(SELECT u._id as _id, c.email as email
FROM users AS u
JOIN (
VALUES ('1', '[email protected]'),
('2','[email protected]')) AS c (_id, email) ON c._id = u._id
)
UPDATE users AS u
SET email = updated.email
FROM updated
WHERE updated._id = u._id ;
SELECT oid::regclass::text
FROM pg_class
WHERE relkind = 'm';
SELECT pg_get_viewdef('viewName');
Add these to sources_non_forked
of vimrc
Don't use https://github.com/isRuslan/vim-es6 it breaks on backticks and sucks, use this instead: https://github.com/pangloss/vim-javascript.git
https://github.com/othree/yajs.vim.git
https://github.com/othree/es.next.syntax.vim.git
you also NEED https://github.com/mxw/vim-jsx.git
and use it with peaksea; mango doesn't work
run cat. Press alt forward and back. you will get patterns X and Y. add to zshrc: bindkey "X" forward-word
The ecr link that is hard to find for some reason https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html#registry_auth
Ultimately I think, if the instruction does not directly relate to the desired output, as something being done on the input, it is going to be more of an imperative, e.g. using a list, a variable to mutate during a loop etc.
to get the GOOGLE_APPLICATION_CREDENTIALS: gcloud auth application-default login
To install:
brew install mysql-connector-c
then: vi $(which mysql_config)
and then make the changes mentioned here
Finally: export LDFLAGS="-L/usr/local/opt/openssl/lib"
and then pip install mysqlclient