This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ember breaks on refresh (404) | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
try_files $uri $uri/ =404; | |
# Uncomment to enable naxsi on this location | |
# include /etc/nginx/naxsi.rules | |
# Add the below rule to fix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Forward all to https for Django / DRF viewsets | |
# settings.py | |
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https') | |
# Nginx location header (see also http://nginx.org/en/docs/http/configuring_https_servers.html) | |
location / { | |
# ... | |
proxy_set_header X-Forwarded-Protocol $scheme; | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Super simple fix for Android keyboard overlapping form inputs --> | |
<preference name="fullscreen" value="false" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Your Django project's media files - amend as required | |
location /media { | |
if ($request_filename ~* ^.*?/([^/]*?)$) { | |
set $filename $1; | |
} | |
if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){ | |
add_header Access-Control-Allow-Origin *; | |
} | |
alias /django/django_project/media; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# connect to db | |
sudo -u postgres psql postgres | |
# export table as CSV | |
COPY table_name TO '/tmp/users_export.csv' DELIMITER ',' CSV HEADER; | |
# create db | |
CREATE DATABASE <name>; | |
# create role |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import chain | |
from operator import attrgetter | |
group1_queryset = group1.objects.all() or filter() | |
group2_queryset = group2.objects.all() or filter() | |
result = sorted( | |
chain(group1_queryset, group2_queryset), | |
key=attrgetter('created')) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reminder for me! How to configure PyCharm to use venv | |
- create virtual env as per usual via command line | |
- PyCharm > Preferences > Project / Project Interp. | |
- click cog > Add Local & and select Python from within local project bin | |
- Done! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# need to add the below or DRF will throw auth errors | |
WSGIPassAuthorization On |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/nginx.conf | |
## | |
# `gzip` Settings | |
# | |
# | |
gzip on; | |
gzip_disable "msie6"; | |
gzip_vary on; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# view all running processes | |
ps aux | |
# kill a process | |
sudo kill <PID> | |
# edit SSH keys | |
cd ~/.ssh | |
nano authorized_keys |