Skip to content

Instantly share code, notes, and snippets.

import boto3
ec2_client = boto3.client('ec2', region_name="eu-central-1")
vpc_dict = ec2_client.create_vpc(
CidrBlock='10.0.0.0/16',
TagSpecifications=[
{
'ResourceType': 'vpc',
'Tags': [
import requests
response = requests.get("https://gitlab.com/api/v4/users/nanuchi/projects")
my_projects = response.json()
for each_project in my_projects:
print(f"Project Name:{each_project['name']}\nProject URL: {each_project['web_url']}\n")
class Post:
def __init__(self, message, author):
self.message = message
self.author = author
def get_post_info(self):
print(f"Post: {self.message} written by {self.author}")
class User:
def __init__(self,user_email, name, password, current_job_title):
self.email = user_email
self.name = name
self.password = password
self.current_job_title = current_job_title
def change_password(self, new_password):
self.password = new_password
from user import User
from post import Post
app_user_one = User("pig@pig.com","Holy Pig","pwd1","DevOps EE")
app_user_one.get_user_info()
app_user_two = User("cat@cat.com","Cute Cat","pwd2","Agent")
app_user_two.get_user_info()
new_post = Post("on a secret mission today", app_user_two.name)
@JavaNoobPig
JavaNoobPig / DevOps_Python_6.py
Last active May 30, 2023 08:26
DevOps_Python_6
import openpyxl
inv_file = openpyxl.load_workbook("inventory.xlsx")
product_list = inv_file["Sheet1"]
products_per_supplier = {}
total_value_per_supplier = {}
product_under_10_inv = {}
from datetime import datetime
user_input = input("enter your goal with a deadline separated by colon\n")
input_list = user_input.split(":")
goal = input_list[0]
deadline = input_list[1]
dateline_date = datetime.strptime(deadline,"%d.%m.%Y")
today_date = datetime.today()
def days_to_units(num_of_days, conversion_unit):
if conversion_unit == "hours":
return f"{num_of_days} days are {num_of_days * 24} hours"
elif conversion_unit == "minutes":
return f"{num_of_days} days are {num_of_days * 24 * 60} minutes"
else:
return "unsupported unit"
def validate_and_execute():
try:
@JavaNoobPig
JavaNoobPig / DevOps_Python_3.py
Last active May 28, 2023 08:16
DevOps_Python_3
def days_to_units(num_of_days, conversion_unit):
if conversion_unit == "hours":
return f"{num_of_days} days are {num_of_days * 24} hours"
elif conversion_unit == "minutes":
return f"{num_of_days} days are {num_of_days * 24 * 60} minutes"
else:
return "unsupported unit"
def validate_and_execute():
try:
@JavaNoobPig
JavaNoobPig / DevOps_Python_1.py
Last active May 28, 2023 05:16
DevOps_Python_1
calculation_to_hours = 24
name_of_unit = "hours"
def days_to_units(num_of_days):
return f"{num_of_days} days are {num_of_days * calculation_to_hours} {name_of_unit}"
def validate_and_execute():
try: