Skip to content

Instantly share code, notes, and snippets.

View linuxkathirvel's full-sized avatar

Kathirvel Rajendran linuxkathirvel

View GitHub Profile
@linuxkathirvel
linuxkathirvel / how-to-comment-remove-all-print-statements-from-Python-codebase.md
Created November 17, 2020 15:31
How to comment/remove all print statements from Python codebase?
@linuxkathirvel
linuxkathirvel / security-configurations-in-django-while-deploying-on-production.md
Last active December 7, 2021 14:33
Security configurations in Django while deploying on production

Security configurations in Django while deploying on production

I am using below settings to secure Django application with Gunicorn+NGINX

Configurations on Django side

in settings.py

# https://docs.djangoproject.com/en/3.1/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'your-django-site-domain.com']
# https://docs.djangoproject.com/en/3.1/ref/settings/#debug
DEBUG = False
# https://docs.djangoproject.com/en/3.1/ref/settings/#secure-hsts-seconds
@linuxkathirvel
linuxkathirvel / fix-must-be-owner-of-relation-error-in-django-postgresql.md
Created October 26, 2020 11:07
How to solve "django.db.utils.ProgrammingError: must be owner of relation table_name"

How to solve "django.db.utils.ProgrammingError: must be owner of relation table_name"?

\c database_name;
REASSIGN OWNED BY old_owner TO new_owner;
@linuxkathirvel
linuxkathirvel / django-permission-denied-for-relation.md
Created October 15, 2020 16:35
How to solve "django.db.utils.ProgrammingError: permission denied for relation"?
@linuxkathirvel
linuxkathirvel / google-drive-and-sheet-api-with-python.md
Last active October 7, 2020 17:36
How to read and update Google Sheet using Python without OAuth?

Create a Credentials object from the service account's credentials and the scopes your application needs access to.

https://developers.google.com/identity/protocols/oauth2/service-account#authorizingrequests

from google.oauth2 import service_account

SCOPES = ['https://www.googleapis.com/auth/sqlservice.admin']
SERVICE_ACCOUNT_FILE = '/path/to/service.json'

credentials = service_account.Credentials.from_service_account_file(
 SERVICE_ACCOUNT_FILE, scopes=SCOPES)
@linuxkathirvel
linuxkathirvel / dump-and-load-data-in-django.md
Last active August 6, 2020 16:59
How to dump and load data in Django?

How to dump and load data in Django?

Dump data

./manage.py dumpdata app_name > app_name.json
# You can give any name to JSON file

Load data

./manage.py loaddata app_name app_name.json
@linuxkathirvel
linuxkathirvel / how-to-open-web-pages-using-python.md
Last active July 29, 2020 10:37
How to open single/multiple web pages using Python?

How to open single/multiple web pages using Python?

import webbrowser

urls = ['https://gnu.org', 'https//kde.org']
for url in urls:
    webbrowser.open(url,new=0)
@linuxkathirvel
linuxkathirvel / ssh-copy-id-succeeded-but-still-prompt-password-input.md
Created July 27, 2020 14:04
How to resolve "ssh-copy-id succeeded, but still prompt password input" issue?
@linuxkathirvel
linuxkathirvel / ERR_INCOMPLETE_CHUNKED_ENCODING-django-nginx.md
Last active July 25, 2020 17:09
Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING django nginx

Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING django nginx

https://stackoverflow.com/questions/42636837/getting-err-incomplete-chunked-encoding-on-server-when-django-apiview-is-used/49631484#49631484

Well in my case the issue was happening because the box on which my server was hosted was hitting 100% Disk Usage and thus nginx was failing while writing the access logs.Just adding this in case someone hits the same issue. And so it might mean that there is some other issue and you should debug from a more holistic view.