Skip to content

Instantly share code, notes, and snippets.

View inceabdullah's full-sized avatar
🏢
Working from office

inceabdullah

🏢
Working from office
View GitHub Profile
@inceabdullah
inceabdullah / deps_downloader.sh
Last active January 9, 2024 04:42
Kube Aliases Loader
#!/bin/bash
cd ${HOME}
# kubernetes fn aliases
## krmpvc
## kavpv
curl -LO https://gist.githubusercontent.com/inceabdullah/64e4fe55e4b9abbe507970f8eebd04cf/raw/dd39721e555ac00b1d7d203778845aa326cf692a/.kubernetes_fn_aliases
@inceabdullah
inceabdullah / modify_hosts_file.sh
Created October 25, 2023 07:14
The "modify_hosts_file.sh" script is a Bash utility for managing the /etc/hosts file on Unix-based systems. It can remove specified hosts and add new entries, aiding in local DNS customization and resolution. Use it with superuser privileges and make backups for safe usage.
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Please run this script with sudo."
exit 1
fi
HOST_TO_REMOVE=example.domain
IP="127.0.0.1"
@inceabdullah
inceabdullah / .kubernetes_fn_aliases
Last active October 14, 2023 15:15
Kubernetes Functions
# krmpvc: Kubernetes Remove PVCs
# This function removes Persistent Volume Claims (PVCs) associated with a specific name. It takes a name as an argument and deletes all PVCs with a label matching the release name.
krmpvc() {
local PVC=$1
kubectl get pvc | grep $PVC | awk '{print $1}' | xargs kubectl delete pvc
}
# kavpv: Kubernetes Available PVs
# This function makes Persistent Volumes (PVs) available in a Kubernetes cluster by clearing the `claimRef` field. It filters PVs based on a specified pattern and release name and then patches each PV to set the `claimRef` to `null`, making the PV available for reuse.
kavpv() {
@inceabdullah
inceabdullah / html-file-collector.sh
Created September 4, 2023 16:45
html-file-collector.sh
#!/bin/bash
# Source directory containing .html files
SOURCE_DIR="./stable"
# Destination directory where .html files will be copied
DEST_DIR="./destination_folder"
# Create the destination directory if it doesn't exist
mkdir -p "$DEST_DIR"
@inceabdullah
inceabdullah / find_unused_subnet.sh
Created August 27, 2023 23:04
Find Minimum Unused Subnet
#!/bin/bash
# ./find_unused_subnet.sh "127.0.0.1 172.17.0.2 10.0.0.1 10.0.1.1 10.156.0.2 127.0.0.1 10.0.0.2 10.0.1.2"
# Declare an associative array to store used subnets
declare -A usedSubnets
# Get IPs from the first argument and split them into an array
IFS=' ' read -ra ADDR <<< "$1"
@inceabdullah
inceabdullah / generate_base64.sh
Last active August 6, 2023 07:22 — forked from mattmc3/rand.bash
Bash - generate random base64 string
#!/bin/bash
# Generate random base64 string using openssl
# Usage: generate_base64 [length]
# length: Optional, the length of the base64 string (default is 32)
generate_base64() {
if [[ "$1" == "--help" ]]; then
echo "Usage: generate_base64 [length]"
echo " length: Optional, the length of the base64 string (default is 32)"
return
@inceabdullah
inceabdullah / rusoto-ecs-clusters-list.rs
Created June 16, 2023 06:16
Rusoto library to list AWS ECS clusters
extern crate rusoto_core;
extern crate rusoto_ecs;
use rusoto_core::Region;
use rusoto_ecs::{Ecs, EcsClient, ListClustersRequest};
#[tokio::main]
async fn main() {
let client = EcsClient::new(Region::UsEast1);
@inceabdullah
inceabdullah / rusoto-task-definitions-list.rs
Created June 16, 2023 05:54
Rusoto Getting List of Task Definitions
extern crate rusoto_core;
extern crate rusoto_ecs;
use rusoto_core::Region;
use rusoto_ecs::{Ecs, EcsClient, ListTaskDefinitionsRequest};
#[tokio::main]
async fn main() {
let client = EcsClient::new(Region::UsEast1);
@inceabdullah
inceabdullah / rusoto-check-credentials.rs
Created June 16, 2023 05:49
Rusoto check Credentials
extern crate rusoto_core;
extern crate rusoto_s3;
use rusoto_core::{Region, RusotoError};
use rusoto_s3::{S3Client, S3};
#[tokio::main]
async fn main() {
let client = S3Client::new(Region::UsEast1);
@inceabdullah
inceabdullah / get-list-of-addres-of-iface.rs
Created May 29, 2023 16:12
get list addresses of iface
use std::ffi::{CStr, CString};
use libc::{getifaddrs, ifaddrs, sockaddr};
struct Result {
ipV4: Vec<String>,
ipV6: Vec<String>,
}
fn get_interface_addresses(iface_name: &str) -> Result {
let mut result = Result {