Django Code Coverage

April 19, 2019

I have a Django application with tests, and I wanted to see what my code coverage was when those tests are run. This is fairly straightforward.

First, install coverage:

$ pip install coverage

Then, instead of running python manage.py test, run the following in the same directory:

$ coverage run --source ...

Mac Disk Usage One Level

March 24, 2019

I'm used to using du --max-depth=1 on linux boxes, but it doesn't work on my mac.

You can get the same values using du -hd1

References

Tags: du macos depth

Revert Latest Commit on a git repo

February 19, 2019

I have changes committed to my branch that I want to revert.

$ git checkout HEAD~1 -- filename.txt

This will look at the file filename.txt, look back one commit from HEAD, and then replace the contents of filename.txt with that version one commit back.

Installing Postgres Client on Amazon Linux

February 11, 2019

I needed to install a postgres client onto Amazon Linux so that I could access my RDS database with it temporarily.

Installing

To install:

[ec2-user ~]$ sudo yum install -y  https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm

[ec2-user ~]$ sudo sed -i "s/rhel-\$releasever-\$basearch ...

ps to find command line

January 10, 2019

I wanted to use ps on linux to find the full command line that a process was started with. This can be done using the options -eaf

ps -eaf | grep drumcoder                     
root     28382 28322  0 08:18 pts/0    00:00:00 /home/drumcoder/.venv/drumcoder/bin/python /home/drumcoder ...

Tags: ps gunicorn