Skip to content

Instantly share code, notes, and snippets.

View hiranp's full-sized avatar
💭
Don't Panic... working on it!

HP hiranp

💭
Don't Panic... working on it!
View GitHub Profile
@hiranp
hiranp / para_rsync.sh
Last active July 22, 2024 21:20
Parallel rsync
#!/bin/bash
# Note: Adjust rsync flags as needed for your specific requirements
# Author: Hiran P
# Date: 2024-07-19
# Description: A script to perform parallel rsync operations with optional continuous sync using inotifywait
#### Usage ####
## ./para_rsync.sh --exclude-from /path/to/exclude_me.txt
@hiranp
hiranp / time_calc.sh
Last active July 29, 2024 19:44
Calculate time 4 hours earlier in bash
#!/bin/bash
# Get the current time in UTC
CURRENT_TIME=$(date -u +'%FT%T')
EARLIER=$(date -u -d '-1 hour' +'%FT%T')
echo "Current Time: $CURRENT_TIME"
echo "One Hour Earlier: $EARLIER"
# Calculate four hours earlier
@hiranp
hiranp / pyav_streamlink_youtube_live.py
Created July 6, 2024 17:40 — forked from mikaelhg/pyav_streamlink_youtube_live.py
Using PyAV and Streamlink to decode Youtube Live HLS streams
@hiranp
hiranp / oci-curl.sh
Last active July 18, 2024 18:55
Scritpt to simplify calling Oracle OCI Rest API's
#!/bin/bash
# Version: 1.0.2
# ORGIGNAL: https://github.com/f5devcentral/f5-oci-failover/blob/master/oci-curl
# Updated by: hiran.patel on 2024-06-25
# Usage:
# oci-curl <host> <method> [file-to-send-as-body] <request-target> [extra-curl-args]
#
# ex:
# oci-curl iaas.us-ashburn-1.oraclecloud.com get "/20160918/instances?compartmentId=some-compartment-ocid"
# oci-curl iaas.us-ashburn-1.oraclecloud.com post ./request.json "/20160918/vcns"
@hiranp
hiranp / excel-oci-security-list.py
Created March 4, 2024 16:44
Excel spreadsheet to OCI security list
import pandas
import json
excel_data_df = pandas.read_excel('Security-List.xls', sheet_name='Ingress')
excel_data_ds = pandas.read_excel('Security-List.xls', sheet_name='Egress')
#Ingress Rules JSON
json_str = excel_data_df.to_json(orient='records')
#Egress Rules JSON
@hiranp
hiranp / passphrase-gen.py
Last active December 29, 2023 18:39
A pass phrase generator for Oracle database passwords
import os
import random
import re
import string
## OCI Console:
## Password must be 9 to 30 characters and contain at least 2 uppercase, 2 lowercase, 2 special, and 2 numeric characters.
## The special characters must be _, #, or -.
MAX_LENGTH = 30
@hiranp
hiranp / replace_in_file.py
Created December 28, 2023 22:40
Simple replace word in place
import os
# https://github.com/first20hours/google-10000-english
CWD = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(CWD, "google-10000-english.txt")) as f:
words = [line.strip() for line in f]
# Convert single alphabet letters to their numeric values
for i in range(len(words)):
word = words[i]
@hiranp
hiranp / purge-sensitive-files.sh
Last active October 25, 2023 22:11
Purging sensitive files from GIT
#!/bin/bash env
# Purge sensitive files from a git repo
# Based on https://help.github.com/articles/remove-sensitive-data/
# Better option: https://rtyley.github.io/bfg-repo-cleaner/
# Get current repo from .git/config
CURRENT_REPO=$(git config --get remote.origin.url)
echo $CURRENT_REPO
CURRENT_REPO_NAME=$(basename $CURRENT_REPO)
echo $CURRENT_REPO_NAME
@hiranp
hiranp / log_process_writers.sh
Last active June 7, 2023 15:01
Create a report of what processes is writing to /var
#!/bin/bash
# Get list of processes writing to /var using lsof
# https://serverfault.com/questions/315091/find-out-which-process-is-writing-into-a-specific-directory
# output_file="processes.csv"
# if [ ! -f "$output_file" ]; then
# touch "$output_file"
# fi
@hiranp
hiranp / json_to_yaml.py
Created May 26, 2023 15:30
Python JSON to Yaml convertor
def convert_json_to_yaml(json_string: str) -> str:
"""Converts a JSON string to YAML format.
Handles both JSON objects and arrays.
Args:
json_string: The JSON string to convert.
Returns:
The YAML representation of the JSON string.