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
# Installing python and other essentials | |
https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-programming-environment-on-an-ubuntu-18-04-server | |
sudo add-apt-repository ppa:deadsnakes/ppa | |
sudo apt-get update | |
sudo apt-get -y upgrade | |
sudo apt-get install python3.7 libpython3.7-dev python3-all-dev | |
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
import base64 | |
import string | |
import random | |
import hashlib | |
import sys | |
from Crypto.Cipher import AES | |
iv = '@@@@&&&&####$$$$' |
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 | |
# Written 2018-11-15 by 4410287 | |
# This script will create a backup file of a postgres database and compress it. It is capable of access a local or remote server to pull the backup. After creating a new backup, it will delete backups that are older than 15 days, with the exception of backups created the first of every month. It is recommended to create a seperate database user specifically for backup purposes, and to set the permissions of this script to prevent access to the login details. Backup scripts for different databases should be run in seperate folders or they will overwrite each other. | |
HOSTNAME= | |
USERNAME= | |
PASSWORD= | |
DATABASE= | |
FILENAME=$(date +%Y-%m-%d).backup.sql |
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
https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-14-04 | |
Steps: 1) | |
sudo apt-get update | |
sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3 | |
2) | |
sudo vim /etc/apache2/sites-available/000-default.conf |
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
# Installing ElasticSearch ANd Kibana | |
# Ref: https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html | |
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - | |
sudo apt-get install apt-transport-https | |
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list | |
sudo apt-get update | |
sudo apt-get install elasticsearch kibana |
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
1. Configure Aws with command `aws configure --profile aws_user` | |
2. Run script to add Ip to security group. 'sh aws_add_ip_to_security_group.sh add' |
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
""" | |
A generic logger decorstor function which is used to log the function input and output at custom directory. | |
@logs_func('dummy') will saves the results into /tmp/logs/dummy/date.txt | |
""" | |
import os | |
from datetime import datetime | |
BASE_DIR="/tmp" | |
def get_dir(path): |
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
""" | |
Decorator used to retry the failed request with default retry limit to 3. | |
""" | |
import time | |
from functools import wraps | |
default_timeout = 1 # timeout of 1 sec. | |
def retry_request(retry_limit=3): |
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
""" | |
A custoom decorastor functions which can be used to mock the reqpose for particular | |
function based on a flag called EnableMock. | |
If EnableMock set to True, then mock_response will not execute the underlying function and returns the mock response provided in decorator. | |
""" | |
from functools import wraps | |
EnableMock = True | |
DummyRespone = 1000 # could be anything Int, Str, Float, Dict, list... |
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 datetime import timedelta | |
import jwt | |
import requests | |
from social_core.utils import handle_http_errors | |
from datetime import datetime, timezone | |
class AppleOAuth2(): | |
"""apple authentication backend""" |