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
| """ | |
| This script will check server response time in seconds. | |
| """ | |
| import requests | |
| while True: | |
| a = requests.get("your api url").elapsed.total_seconds() | |
| print(a) |
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
| # dump all databases once every 24 hours | |
| 45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz | |
| # vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night) | |
| 45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze" | |
| 45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet" | |
| # re-index all databases once a week | |
| 0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database {};"' |
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
| //Add in text after price to all products | |
| function custom_text_to_price( $price, $product ) { | |
| $price = $price . ' USD'; | |
| return $price; | |
| } | |
| add_filter( 'woocommerce_get_price_html', 'custom_text_to_price', 100, 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
| 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(); | |
| } |
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="admin@mail.com" | |
| 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
| 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
| 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 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
| """ | |
| 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
| 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]) |