This file contains hidden or 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
yum install -y gcc gcc-c++ make git patch openssl-devel zlib-devel readline-devel sqlite-devel bzip2-devel | |
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash | |
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> .zshrc | |
echo 'eval "$(pyenv init -)"' >> .zshrc | |
echo 'eval "$(pyenv virtualenv-init -)"' >> .zshrc | |
exec $SHELL - l | |
pyenv install 3.6.0 | |
pyenv global 3.6.0 |
This file contains hidden or 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
""" | |
## ==== Never create O(n), if you can O(1) ===== # | |
“A dispatch table is a table of pointers to functions or methods.” | |
Link: https://en.wikipedia.org/wiki/Dispatch_table?fbclid=IwAR392A7zZELtQxij7w5iHurjdKJxuYbdyOc6_iVBh7pqvr4oeEUr0xLUNpk | |
""" | |
import datetime | |
def monday_task(): |
This file contains hidden or 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.contrib.postgres.indexes import BrinIndex | |
from django.db import models | |
class SampleData(models.Model): | |
created_at = models.DateTimeField() | |
class Meta: | |
""" | |
You must need to use PostgreSQL DB unless you can't use BrinIndex | |
""" |
This file contains hidden or 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
import csv | |
from django.contrib.auth.models import User | |
def run(): | |
with open("users.xls", "w", newline='') as csvfile: | |
writer = csv.writer(csvfile) | |
writer.writerow(['Username', 'Full Name', 'Email address']) | |
users = User.objects.filter(is_active=True, is_staff=False) | |
for user in users: | |
writer.writerow([user.username, user.first_name + user.last_name, user.email]) |
This file contains hidden or 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
""" | |
python manage.py runscript <script name> --script-args <args> | |
""" | |
import datetime | |
from contact.v2.models import TestModel | |
from django.utils import timezone | |
def run(): | |
start_date = (timezone.now().date() - timezone.timedelta(days=1)).strftime('%Y-%m-%d') + 'T20:00:00' |
This file contains hidden or 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 alpine:3.6 | |
ENV PYTHONUNBUFFERED 1 | |
WORKDIR /usr/src/national_id | |
ADD requirements.txt /usr/src/national_id/ | |
RUN apk add --no-cache python3 && \ | |
python3 -m ensurepip && \ | |
rm -r /usr/lib/python*/ensurepip && \ | |
pip3 install --upgrade pip setuptools && \ | |
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \ | |
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \ |
This file contains hidden or 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 datetime import date, timedelta, datetime | |
start_date = date(2018,1,1) | |
end_date = datetime.now() | |
every_month = 28 | |
def finding_date(start_date, end_date, every_month): | |
start_month = start_date.month | |
end_months = (end_date.year-start_date.year)*12 + end_date.month | |
has_month = [] | |
has_not = 0 |
This file contains hidden or 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 datetime import date, timedelta, datetime | |
def month_in_range(start_date, end_date): | |
"""Get the last day of every month in a range between two datetime values. | |
Return a generator | |
""" | |
start_month = start_date.month | |
end_months = (end_date.year-start_date.year)*12 + end_date.month | |
date_obj = [] | |
for month in range(start_month, end_months + 2): |
This file contains hidden or 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
#!/usr/bin/env bash | |
DEFAULT_USER="admin" | |
DEFAULT_EMAIL="[email protected]" | |
DEFAULT_PASS="nothing1234" | |
######### MAIN CLEAN ######### | |
rm 'db.sqlite3' | |
readonly virtual='/home/vubon/personal/upwork_env/bin/activate' | |
source ${virtual} |
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
// for generation QR Code | |
import 'package:qr_flutter/qr_flutter.dart'; | |
class QRCodeGenerator extends StatefulWidget{ | |
@override | |
_QRCodeGenerator createState() => new _QRCodeGenerator(); | |
} |