Skip to content

Instantly share code, notes, and snippets.

View santoshpy's full-sized avatar
🐍
Focusing

Santosh Purbey santoshpy

🐍
Focusing
View GitHub Profile
@santoshpy
santoshpy / string_exercise.py
Last active December 7, 2018 14:04
String exercise
"""
1. Write a Python program to get a string from a given string
where all occurrences of its first char have been changed to '$',
except the first char itself.
Sample String : 'restart'
Expected Result : 'resta$t'
"""
"""
@santoshpy
santoshpy / git_commit_message.md
Last active October 14, 2018 10:36
How to write git commit message

How to Write a Git Commit Message


It is useful to write good commit message which shows professionalism. it shows whether a developer is a good collaborator or not?

The most basic element of keeping a healthy commit history: How to write a great commit message.

Just follow the seven rules below and you’re on your way to committing like a pro.

@santoshpy
santoshpy / models.py
Last active April 28, 2018 04:50
Choices for Choices in Django CharFields
from .utils import ChoiceEnum
class Car(models.Model):
# Encapsulation, we meet again.
class Colors(ChoiceEnum):
RED = 'red'
WHITE = 'white'
BLUE = 'blue'
color = models.CharField(max_length=5, choices=Colors.choices(), default=Colors.RED)
from django.contrib.auth.models import User
admin.site.unregister(User)
from app_name.models import User
admin.site.register(User)
@santoshpy
santoshpy / javascript_framework.md
Created November 12, 2017 16:30
javascript_framework
@santoshpy
santoshpy / pip_install_package_from_github.md
Created November 12, 2017 02:17
pip install package from github

pip install package from github

comand in shell:

pip install git+https://github.com/username/repository.git@branch
@santoshpy
santoshpy / beautiful_idiomatic_python.md
Last active August 16, 2018 15:37 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:

To start rabbitmq server

sudo rabbitmq-server start

To check status of server

sudo rabbitmqctl status

To stop server

@santoshpy
santoshpy / interview_sample_questons_1.md
Last active February 3, 2019 08:47
Interview Sample Question

Interview Sample Question

    1. why is not all memory free when Python exits?
    1. write the output of below code:
   var1 = lambda q: q * 5
   var2 = lambda q: q * 3
   x = 2
   x = var1(x)
   x = var1(x)
   x = var2(x)
@santoshpy
santoshpy / email_settings.py
Created October 3, 2017 03:30
Django Email settings
##EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # For development and test only
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # For Production
# Django Eamil Settings for gmail
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '<user>@gmail.com' # use email adress
EMAIL_HOST_PASSWORD = '***********' # use password of your email adress
EMAIL_USE_TLS = True