Skip to content

Instantly share code, notes, and snippets.

View sanjaykrishnan's full-sized avatar

sanjay krishnan sanjaykrishnan

  • Sayone Technologies
  • Kerala
View GitHub Profile
ssh -R 80:localhost:8000 ssh.localhost.run
<!--
/((((((\\\\
=======((((((((((\\\\\
(( \\\\\\\
( (* _/ \\\\\\\
\ / \ \\\\\\________________
| | | </ ((\\\\
o_| / / \ \\\\ \\\\\\\
| ._ ( \ \\\\\\\\\\\\\\\\
| / / / \\\\\\\ \\
@sanjaykrishnan
sanjaykrishnan / ssh_add_instructions.txt
Created December 24, 2019 05:22
Instructions to add SSH key to repository
ssh-keygen -t rsa -b 4096 -C "your_email_id"
ssh-add ~/.ssh/id_rsa
copy content in .ssh/id_rsa.pub and paste in "Add SSH Key" option in your profile.
cd to your git repository.
git remote -v
git remote set-url origin <git_ssh_clone_url>
@sanjaykrishnan
sanjaykrishnan / history.py
Created November 22, 2019 06:44
Django Simple History, track all changes for this object.
p = "Object for which change is to be "
for i in p.history.all():
previous = i.prev_record
if previous:
delta = i.diff_against(previous)
for change in delta.changes:
print("{} user changed {} from {} to {}".format(i.history_user, change.field, change.old, change.new))
else:
print("{} created this item")
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO db_user;
GRANT ALL ON SCHEMA public TO public;
@sanjaykrishnan
sanjaykrishnan / datatables.py
Last active September 13, 2019 11:17
jquery datatables with django
from django.db.models import QuerySet
from django.views import View
class DataTableMixin(View):
queryset = None
columns = None
serializer_class = None
page_size = 10
def get_queryset(self):
@sanjaykrishnan
sanjaykrishnan / query_counter_mixin.py
Created August 29, 2019 10:56
Mixin to print query count and time of execution.
from django.db import connection
from django.http import HttpResponse
from django.utils.deprecation import MiddlewareMixin
# from django.utils.log import getLogger
# logger = getLogger(__name__)
class QueryCountDebugMiddleware(MiddlewareMixin):
"""
This middleware will log the number of queries run
@sanjaykrishnan
sanjaykrishnan / base.html
Last active May 11, 2021 11:59
Django messages integration with toastr
<!-- Download the js and css file and place at the below specified location. -->
<!-- In html add this to head tag -->
<link href="{% static 'css/toastr.min.css' %}" rel="stylesheet">
<!-- In html add this just before end of body tag -->
<script src="{% static 'js/toastr.js' %}" type="text/javascript"></script>
@sanjaykrishnan
sanjaykrishnan / pg_dump.txt
Created August 5, 2019 07:40
Postgres Dump
pg_dump -U username -p 5433 -h localhost -F c database_name > dk_dump.dump