Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Jay Modi mjrulesamrat

🎯
Focusing
View GitHub Profile
@mjrulesamrat
mjrulesamrat / Custom_Transform.py
Created Jul 12, 2016
Custom transform for django date filter. It works like charm. :)
View Custom_Transform.py
from django.db import models
from django.db.models import Transform
# Custom Date filter transform class
# Added by : Jay Modi
class MySQLDatetimeDate(Transform):
"""
This implements a custom SQL lookup when using `__date` with datetimes.
To enable filtering on datetimes that fall on a given date, import
View django-secret-keygen.py
"""
Pseudo-random django secret key generator.
- Does print SECRET key to terminal which can be seen as unsafe.
"""
import string
import random
from __future__ import print_function
@mjrulesamrat
mjrulesamrat / threading.py
Last active Jun 25, 2019
Concurrency in python snippets
View threading.py
################ threading.py
import threading
def my_task():
print("Hello world: {}".format(threading.current_thread()))
# my_task()
my_thread = threading.Thread(target=my_task)
my_thread.start()
@mjrulesamrat
mjrulesamrat / README.md
Last active Dec 7, 2019
Docker Commands
View README.md

Docker Networking

  • Use the docker network to create the frontend network:

docker network create frontend

  • User the docker network command to create the localhost network:

docker network create localhost --internal

@mjrulesamrat
mjrulesamrat / vim.md
Last active Dec 12, 2021
Vim shortcuts
View vim.md

Modes

  1. Normal
  2. Edit/Insert
  3. Visual
  4. Replace

Normal Mode

Alphanumeric keys can not be used to edit open code. We can use commands to manipulate content of open file.

@mjrulesamrat
mjrulesamrat / Custom_backend.py
Created Mar 30, 2016
My custom Django Email Backend. Forked from Django's core.mail.smtp
View Custom_backend.py
"""SMTP email backend class."""
import smtplib
import ssl
import threading
from django.conf import settings
from django.core.mail.backends.base import BaseEmailBackend as CoreBaseEmailBackend
from django.core.mail.message import sanitize_address
from django.core.mail.utils import DNS_NAME
@mjrulesamrat
mjrulesamrat / countryinfo.py
Created Jul 14, 2016 — forked from pamelafox/countryinfo.py
Python list of country codes, names, continents, capitals, and pytz timezones
View countryinfo.py
countries = [
{'timezones': ['Europe/Andorra'], 'code': 'AD', 'continent': 'Europe', 'name': 'Andorra', 'capital': 'Andorra la Vella'},
{'timezones': ['Asia/Kabul'], 'code': 'AF', 'continent': 'Asia', 'name': 'Afghanistan', 'capital': 'Kabul'},
{'timezones': ['America/Antigua'], 'code': 'AG', 'continent': 'North America', 'name': 'Antigua and Barbuda', 'capital': "St. John's"},
{'timezones': ['Europe/Tirane'], 'code': 'AL', 'continent': 'Europe', 'name': 'Albania', 'capital': 'Tirana'},
{'timezones': ['Asia/Yerevan'], 'code': 'AM', 'continent': 'Asia', 'name': 'Armenia', 'capital': 'Yerevan'},
{'timezones': ['Africa/Luanda'], 'code': 'AO', 'continent': 'Africa', 'name': 'Angola', 'capital': 'Luanda'},
{'timezones': ['America/Argentina/Buenos_Aires', 'America/Argentina/Cordoba', 'America/Argentina/Jujuy', 'America/Argentina/Tucuman', 'America/Argentina/Catamarca', 'America/Argentina/La_Rioja', 'America/Argentina/San_Juan', 'America/Argentina/Mendoza', 'America/Argentina/Rio_Gallegos', 'America/Argentina/Ushuai
@mjrulesamrat
mjrulesamrat / multiple_ssh_keys.md
Last active Oct 25, 2022
How to Setup Multiple Ssh Keys for Multiple Github/Bitbucket accounts
View multiple_ssh_keys.md

How to Setup Multiple Ssh Keys for Multiple Github/Bitbucket accounts

create the SSH keys.

ssh-keygen -t rsa -b 4096 -C "mjrulesamrat@gmail.com"

Add the SSH Keys to the SSH-Agent