This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deposit_sum = Sum('amount', filter=Q(transaction_type='deposit')) | |
withdraw_sum = Sum('amount', filter=Q(transaction_type='withdraw')) | |
deposit = Savings.objects.filter(branch=branch).aggregate( | |
total_deposit= deposit_sum - withdraw_sum | |
)['total_deposit'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open(str(BASE_DIR) + '/oidc.key', 'rb') as f: | |
OIDC_RSA_PRIVATE_KEY = f.read().decode() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Initialize credential veriable | |
dbname=teamshape | |
dbuser=admin | |
userpass=admin | |
# install python3.8 | |
echo "Installing python3.8" | |
sudo add-apt-repository ppa:deadsnakes/ppa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax({ | |
url: apiUrl, | |
method: 'POST', | |
contentType: "application/json", | |
dataType: 'json', | |
data: JSON.stringify(orderData), | |
headers: { | |
'X-CSRFToken': csrftoken, | |
'Accept': 'application/json', | |
'Content-Type': 'application/json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$('#search-data').dataTable( { | |
destroy: true, // destroy previous datatable to remove error. | |
"ajax": url, | |
"columns": [ | |
{"data":"latitude"}, | |
{"data":"longitude"}, | |
{"data":"data__product_data__Name"}, | |
{"data":"id__count"}, | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import connections, OperationalError | |
# Drop all tables from a given database | |
""" | |
python manage.py runscript clean_database_tables | |
""" | |
def run(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run bash in docker image | |
# docker run -it <image-name> bash | |
# if entrypoint defined | |
docker run -it --entrypoint bash jifcastback_djangoapp | |
# create superuser in docer container django app | |
sudo docker-compose run --entrypoint="python manage.py createsuperuser" djangoapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends 'base.html' %} | |
{% block content %} | |
<div class="container"> | |
<div class="dashboard-block"> | |
<h2 class="dashboard-info-title">Profile Info</h2> | |
<form method="POST" action="{% url 'userprofile:create-profile' %}" enctype="multipart/form-data">{% csrf_token %} | |
{% for field in form %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
NewerOlder