Skip to content

Instantly share code, notes, and snippets.

@neerajgupta2407
neerajgupta2407 / README.md
Created June 8, 2017 19:46 — forked from oodavid/README.md
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc

import base64
import os
import time
from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
"""
Desired Capabilities
"""
# TODO provide the desired cap as per your requirement
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"""
@neerajgupta2407
neerajgupta2407 / Mock_requests_and_functions.py
Last active May 12, 2020 07:19
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.
"""
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...
@neerajgupta2407
neerajgupta2407 / retry_request.py
Created May 12, 2020 07:25
Decorator used to retry the failed request with default retry limit to 3.
"""
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):
@neerajgupta2407
neerajgupta2407 / logger_function.py
Created May 12, 2020 07:31
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
"""
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):
@neerajgupta2407
neerajgupta2407 / Steps.
Last active May 16, 2020 13:04
Script used to add host machine ip address to Aws security group.
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'
# 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
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
cd /home/ubuntu/codes/backend/saleor
source /home/ubuntu/codes/backend/venv/bin/activate
export ALLOWED_HOSTS=3.6.136.178
export ALLOWED_CLIENT_HOSTS=3.6.136.178
export DEBUG=True
export SECRET_KEY=123456
export INTERNAL_IPS=127.0.0.1,3.6.136.178,
export API_URI=http://3.6.136.178:8000/graphql/
export APP_MOUNT_URI=/dashboard/
export DEFAULT_COUNTRY=IN