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 sshtunnel import SSHTunnelForwarder | |
import pymysql | |
with SSHTunnelForwarder( | |
('ec2-52-202-194-76.public-ec2-instance.amazonaws.com'), | |
ssh_username="ec2-user", | |
ssh_pkey="~/ssh-tunnel-rds.pem", | |
remote_bind_address=('private-rds-instance.ckfkidfytpr4.us-east-1.rds.amazonaws.com', 3306) | |
) as tunnel: | |
print("****SSH Tunnel Established****") |
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 math | |
n = int(input("Enter the number of points\n")) | |
line_points = [] | |
for i in range(n): | |
x, y = input("Enter the coordinate x,y \n").split(',') | |
coordinates = [int(x), int(y)] | |
line_points.append(coordinates) | |
xp, yp = input("Enter the coordinate of center point P \n").split(',') |
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 boto3 | |
access_key = "XXXXXXXXXXXXXXXXXX" | |
secret_key = "XXXXXXXXXXXXXXXXXX" | |
region = 'us-east-1' | |
client = boto3.client('ec2', aws_access_key_id=access_key, aws_secret_access_key=secret_key, | |
region_name=region) | |
conn = boto3.resource('ec2', aws_access_key_id=access_key, aws_secret_access_key=secret_key, region_name=region) |
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
apt-get update | |
apt-get install chrony -y | |
cp -pr /etc/chrony/chrony.conf /etc/chrony/chrony.conf.bk | |
vim /etc/chrony/chrony.conf | |
=========================chrony.conf============================== | |
# Welcome to the chrony configuration file. See chrony.conf(5) for more | |
# information about usuable directives. |
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 pprint import pprint | |
sample_json = { | |
"id": "0001", | |
"type": "donut", | |
"name": "Cake", | |
"ppu": 0.55, | |
"batters": | |
{ | |
"batter": |
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 azure.identity import ClientSecretCredential | |
from azure.storage.blob import BlobServiceClient | |
# Tenant ID for your Azure Subscription | |
TENANT_ID = "85XXX93e-XXXX-XXXX-XXXXX-96150XXX893e" | |
# Your Service Principal App ID (Client ID) | |
CLIENT_ID = "a3XXX40d-xxxxxxx-0ff72XXXX66a" | |
# Your Service Principal Password (Client Secret) |
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
def on_starting(server): | |
""" | |
Do something on server start | |
""" | |
print("Server has started") | |
def on_reload(server): | |
""" |
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 fastapi import FastAPI | |
app = FastAPI() | |
@app.get("/") | |
def my_first_get_api(): | |
""" | |
Sample GET method implementation using FastAPI | |
:return: |
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 json | |
import sys | |
import requests | |
URL = "" | |
message = "" | |
def send_notification(url, message): | |
title = (f"DMP Notification :zap:") |
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 os | |
import json | |
import pandas as pd | |
def data_extractor(file_path, delimiter, required_fields=[]): | |
""" | |
:param file_path: | |
:param delimiter: | |
:param required_fields: |