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 pyautogui | |
from time import sleep | |
from pynput.mouse import Button, Controller | |
import random | |
import string | |
# generate random file name | |
def randomString(stringLength=10): | |
letters = string.ascii_lowercase |
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 pprint import pprint | |
from googleapiclient import discovery | |
from oauth2client.client import GoogleCredentials | |
import random | |
import string | |
from time import sleep | |
credentials = GoogleCredentials.get_application_default() | |
service = discovery.build('compute', 'v1', credentials=credentials) |
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 json | |
import boto3 | |
from botocore.exceptions import ClientError | |
def lambda_handler(event, context): | |
bucket_name = event['Records'][0]['s3']['bucket']['name'] | |
s3_file = event['Records'][0]['s3']['object']['key'] | |
print(bucket_name, s3_file) | |
s3 = boto3.client('s3') |
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 boto3 | |
from datetime import timedelta, datetime | |
### Logic: | |
# this script will list all aws buckets, and will retrieve each bucket size per storage type, | |
# output will be displayed in mb, if output is 0Mb, the specific storage size is less than 1Mb. | |
# output will only display used storage types | |
### |
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 googletrans import Translator | |
from urllib.parse import unquote | |
def lambda_handler(event, context): | |
data = event['body'].split('&') | |
body = '' | |
for item in data: | |
tt = item.split('=') | |
if tt[0] == 'Body': |
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 string | |
import random | |
from google.cloud import container_v1 | |
from google.api_core.retry import Retry | |
from pprint import pprint | |
cluster = { | |
"name": "cluster-" + ''.join(random.choice(string.ascii_lowercase) for i in range(8)), | |
"master_auth": { |
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
def tag_instance(instance: str, project: str, zone: str, creator_email: str): | |
instance_information = compute.instances().get(project=project, zone=zone, instance=instance).execute() | |
print(instance_information) | |
instance_disks_list = [disk['deviceName'] for disk in instance_information['disks']] | |
instance_fingerprint = instance_information['fingerprint'] | |
print(instance_fingerprint) | |
instance_labels = {'labels': {'createdby': '123'}, 'labelFingerprint': instance_fingerprint} | |
print(instance_labels) | |
request = compute.instances().setLabels(project=project, zone=zone, instance=instance, body=instance_labels) | |
try: |
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
def tag_instance(instance: str, project: str, zone: str, creator_email: str): | |
instance_information = compute.instances().get(project=project, zone=zone, instance=instance).execute() | |
print(instance_information) | |
instance_disks_list = [disk['deviceName'] for disk in instance_information['disks']] | |
instance_fingerprint = instance_information['fingerprint'] | |
print(instance_fingerprint) | |
instance_labels = {'labels': {'createdby': '123'}, 'labelFingerprint': instance_fingerprint} | |
print(instance_labels) | |
request = compute.instances().setLabels(project=project, zone=zone, instance=instance, body=instance_labels) | |
try: |
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 boto3 | |
from pprint import pprint | |
profiles = ['default'] | |
regions = [region['RegionName'] for region in boto3.client('ec2', region_name='us-east-1').describe_regions()['Regions']] | |
print('profile,region,instance_id,instance_type,instance_state') | |
for profile in profiles: | |
for region in regions: |
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
def lambda_handler(event, context): | |
host_header = event['Records'][0]['cf']['request']['headers']['host'][0]['value'] | |
new_host_header = host_header.replace('www.', '') | |
uri_path = event['Records'][0]['cf']['request']['uri'] | |
response = { | |
'status': '301', | |
'statusDescription': 'Found', | |
'headers': { | |
'location': [{ | |
'key': 'Location', |
OlderNewer