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
Add-Type -TypeDefinition @' | |
using System.Runtime.InteropServices; | |
[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | |
interface IAudioEndpointVolume { | |
int f(); int g(); int h(); int i(); | |
int SetMasterVolumeLevelScalar(float fLevel, System.Guid pguidEventContext); | |
int j(); | |
int GetMasterVolumeLevelScalar(out float pfLevel); | |
} |
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
Add-Type -TypeDefinition @' | |
using System.Runtime.InteropServices; | |
[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] | |
interface IAudioEndpointVolume { | |
int f(); int g(); int h(); int i(); | |
int SetMasterVolumeLevelScalar(float fLevel, System.Guid pguidEventContext); | |
int j(); | |
int GetMasterVolumeLevelScalar(out float pfLevel); | |
} |
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 scrapy | |
from tabulate import tabulate | |
import os | |
class EndpointSpider(scrapy.Spider): | |
name = 'endpoint-spider' | |
base = 'wikipedia' # <-------- base of url you want to crawl | |
start_urls = [f'https://www.{base}.com'] | |
def __init__(self, *args, **kwargs): |
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 send_to_slackbot(dictionary_object: dict, webhook_string: str): | |
''' | |
This function sends the dictionary object to the slackbot | |
Args: | |
- dictionary_object (dict): dictionary object | |
- webhook_string (str): webhook string | |
Raises: | |
ValueError: if response status code is not 200 | |
Return type: None |
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 os | |
import logging | |
# if log folder does not exist create it | |
if not os.path.exists('main\log'): | |
os.makedirs('main\log') | |
logging.basicConfig(filename='main\log\deleted_folders.log', | |
level=logging.INFO, | |
format='%(asctime)s - %(levelname)s - %(message)s') |
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 re | |
import os | |
import logging | |
def read_error_log(): | |
''' | |
Read weekly_hr.log file and create two new files: | |
1. errors.log - contains all errors | |
2. info.log - contains all info |
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 re | |
import os | |
import shutil | |
desktop_path = os.path.expanduser("~/Desktop") | |
downloads_path = os.path.expanduser("~/Downlaods") | |
# get username | |
username = os.getlogin() | |
def convert_to_csv(txt_file): |
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
#! /usr/bin/env python3 | |
import os | |
import requests | |
directory = "/data/feedback" | |
for filename in os.listdir(directory): | |
if filename.endswith(".txt"): | |
with open(os.path.join(directory, filename)) as file: | |
lines = file.readlines() |
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 pkg_resources | |
# List all installed packages and their versions | |
installed_packages = [f"{dist.project_name}=={dist.version}" for dist in pkg_resources.working_set] | |
# Write the package list to a requirements.txt file | |
with open("requirements.txt", "w") as requirements_file: | |
requirements_file.write("\n".join(installed_packages)) | |
print("requirements.txt file generated.") |
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 time | |
import logging | |
import schedule | |
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S") | |
class AdvancedScheduler: | |
def __init__(self, start_time, end_time, interval): | |
self.start_time = start_time | |
self.end_time = end_time |
NewerOlder