Skip to content

Instantly share code, notes, and snippets.

View deepanshu-nickelfox's full-sized avatar
:octocat:
Billy

Deepanshu Mehta deepanshu-nickelfox

:octocat:
Billy
View GitHub Profile
@deepanshu-nickelfox
deepanshu-nickelfox / aws_basic_concept.md
Created November 10, 2020 04:50 — forked from vicly/aws_basic_concept.md
[AWS basic concept] #AWS

Basic Concept

127.0.0.1 vs 0.0.0.0

127.0.0.1 is the loopback Internet protocol (IP) address also referred to as the localhost. The address is used to establish an IP connection to the same machine or computer being used by the end-user.

0.0.0.0 is a special IP which is "no particular address" (invalid/unknown/not-applicable).

0.0.0.0/0 : all IPs

def djangoview(request, language1, language2):
async def main(language1, language2):
loop = asyncio.get_event_loop()
r = sr.Recognizer()
with sr.AudioFile(path.join(os.getcwd(), "audio.wav")) as source:
audio = r.record(source)
def reco_ibm(lang):
return(r.recognize_ibm(audio, key, secret language=lang, show_all=True))
future1 = loop.run_in_executor(None, reco_ibm, str(language1))
future2 = loop.run_in_executor(None, reco_ibm, str(language2))
@deepanshu-nickelfox
deepanshu-nickelfox / clean_database_tables.py
Created November 10, 2020 04:48 — forked from harunurkst/clean_database_tables.py
Drop all tables of postgresql with python code
from django.db import connections, OperationalError
# Drop all tables from a given database
"""
python manage.py runscript clean_database_tables
"""
def run():
@deepanshu-nickelfox
deepanshu-nickelfox / pushme.py
Created November 10, 2020 04:47 — forked from harunurkst/pushme.py
basic function to test time counting.
import time
def send_push(user_id):
"""
demo function to send notification
"""
print("Start: "+str(user_id))
time.sleep(1) # sleep 1 second when sending notification.
print("Complete: "+str(user_id))
@deepanshu-nickelfox
deepanshu-nickelfox / object_count_per_month.py
Created November 10, 2020 04:47 — forked from harunurkst/object_count_per_month.py
Count number of object created or total number of amount per month in Django
class FundRaisePerMonth(APIView):
def get(self, request):
year = datetime.date.today().year
# Filter data as monthly(number serial) [{'month_serial': views_count} like [{'1': 50, '2': 55}]
queryset = CustomUser.objects.filter(date_joined__year=year)
search = queryset.annotate(month=ExtractMonth('date_joined'),).order_by('month').values('month')\
.annotate(total=Sum('amount')).values('month', 'total')
# convert int month to str month, 1 to January
data = []