Skip to content

Instantly share code, notes, and snippets.

View Codehunter-py's full-sized avatar
🏠
Working from home

Ibrahim Musayev Codehunter-py

🏠
Working from home
View GitHub Profile
@Codehunter-py
Codehunter-py / gitCloneFromRequirements.sh
Created December 6, 2024 11:11
A shell script that parses this YAML-formatted requirements file and clones the specified Git repositories.
#!/usr/bin/env bash
# Function to parse and clone repositories
clone_repositories() {
local requirements_file="$1"
local projects_dir="${HOME}/Projects"
# Validate requirements file
if [ ! -f "$requirements_file" ]; then
echo "Error: Requirements file not found." >&2
@Codehunter-py
Codehunter-py / Cleanup-OldBackups.ps1
Created November 16, 2024 21:20
This script deletes files older than 3 months in the specified folder on the F: drive.
# Script Name: Cleanup-OldBackups.ps1
# Description: This script deletes files older than 3 months in the specified folder on the F: drive.
# Define the path to the backup folder
$backupFolderPath = "F:\Data" # Double check path
# Define the age in days (3 months = 90 days)
$ageInDays = 90
# Get the current date
@Codehunter-py
Codehunter-py / .tmux.conf
Created November 14, 2024 14:39
Tmux conf file for Mac with additional plugins.
set-option -g history-limit 10000
# Options to make tmux more pleasant
set -g default-terminal "tmux-256color"
# Configure the catppuccin plugin
set -g @catppuccin_flavor "mocha" # latte, frappe, macchiato, or mocha
set -g @catppuccin_window_status_style "rounded" # basic, rounded, slanted, custom, or none
run ~/.config/tmux/plugins/catppuccin/tmux/catppuccin.tmux
@Codehunter-py
Codehunter-py / shutdown_k8s_node.sh
Last active October 14, 2024 21:36
Script to stop Kubernetes and container services on the control plane node and worker nodes
#!/bin/bash
# Script to stop Kubernetes and container services on any node (control or worker)
echo "This script is running on node: $(hostname)"
# Drain the node if it's a worker (assuming hostnames like 'worker1', 'worker2', etc.)
kubectl drain $(hostname) --ignore-daemonsets
# Stopping all running containers
echo "Stopping containers on $(hostname)..."
@Codehunter-py
Codehunter-py / scrape.py
Created July 28, 2022 11:40
Creating a request and parsing a web page
import requests
from bs4 import BeautifulSoup
def scrape_page(url):
response = requests.get(url)
soup = BeautifulSoup(response.text,'lxml')
print(soup)
quotes = soup.find_all("span", class_="text")
authors = soup.find_all("small", class_="author")
tags = soup.find_all("div", class_="tags")
@Codehunter-py
Codehunter-py / fileIO.py
Created July 28, 2022 10:39
Read the inputFile.txt then write two output files if conditions are matched
def fileIO(inputFile='inputFile.txt'):
f = open(inputFile,'r')
output1 = "PassFile.txt"
output2 = "FailFile.txt"
passFile = open(output1,'w')
failFile = open(output2, 'w')
for line in f:
line_split = line.split()
if line_split[2] == "P":
@Codehunter-py
Codehunter-py / flatten_2d_list.py
Created July 25, 2022 14:26
Given a 2D list, write a Python program to convert the given list into a flattened list.
import numpy
list_2d = [['Volkswagen', 'Mercedes', 'BMW'], ['Honda', 'Toyota', 'Mazda']]
def convertList(list_2d):
return list(numpy.concatenate(list_2d).flat)
print(convertList(list_2d)) # Output ['Volkswagen', 'Mercedes', 'BMW', 'Honda', 'Toyota', 'Mazda']
@Codehunter-py
Codehunter-py / show_time_of_pid.py
Created March 27, 2022 17:30
We're using the same syslog, and we want to display the date, time, and process id that's inside the square brackets. We can read each line of the syslog and pass the contents to the show_time_of_pid function.
‎‎​
@Codehunter-py
Codehunter-py / convert_phone_number.py
Last active August 23, 2023 11:55
The convert_phone_number function checks for a U.S. phone number format: XXX-XXX-XXXX (3 digits followed by a dash, 3 more digits followed by a dash, and 4 digits), and converts it to a more formal format that looks like this: (XXX) XXX-XXXX.
import re
def convert_phone_number(phone):
result = re.sub(r"\b(\d{3})-(\d{3})-(\d{4})\b",r"(\1) \2-\3", phone)
return result
print(convert_phone_number("My number is 212-345-9999.")) # My number is (212) 345-9999.
print(convert_phone_number("Please call 888-555-1234")) # Please call (888) 555-1234
print(convert_phone_number("123-123-12345")) # 123-123-12345
print(convert_phone_number("Phone number of Buckingham Palace is +44 303 123 7300")) # Phone number of Buckingham Palace is +44 303 123 7300
@Codehunter-py
Codehunter-py / transform_comments.py
Created March 12, 2022 17:14
The transform_comments function converts comments in a Python script into those usable by a C compiler. This means looking for text that begins with a hash mark (#) and replacing it with double slashes (//), which is the C single-line comment indicator. For the purpose of this exercise, we'll ignore the possibility of a hash mark embedded inside…
‎‎​