Skip to content

Instantly share code, notes, and snippets.

View baradhiren's full-sized avatar
👨‍💻
Working on the next adventure

Hiren Barad baradhiren

👨‍💻
Working on the next adventure
View GitHub Profile
@baradhiren
baradhiren / extractDir_Python
Created May 17, 2021 04:59
Extract directory from a zip file Python
def extractDirectory(zipName, directoryName, destFilePath):
try:
with zipfile.ZipFile(zipName) as z:
for file in z.namelist():
if file.startswith(directoryName) and file != directoryName + '/':
path = os.path.join(destFilePath, 'Any/subsequent/dirs')
dirtemp = '/'.join(path.split('/')[0:-1])
Path(dirtemp).mkdir(parents=True, exist_ok=True)
with z.open(file) as zf, open(path, 'wb') as f:
shutil.copyfileobj(zf, f)
@baradhiren
baradhiren / script-template.sh
Created December 15, 2020 13:38 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
trap cleanup SIGINT SIGTERM ERR EXIT
usage() {
cat <<EOF
@baradhiren
baradhiren / .bashrc
Created August 28, 2019 14:38
Termux bashrc with common aliases and functions
#########
# Aliases
#########
# Always copy contents of directories (r)ecursively and explain (v) what was done
alias cp='cp -rv'
# List contents with colors for file types, (A)lmost all hidden files (without . and ..), in (C)olumns, with class indicators (F)
alias ls='ls --color=auto -ACF'
# List contents with colors for file types, (a)ll hidden entries (including . and ..), use (l)ong listing format, with class indicators >
alias ll='ls --color=auto -alF'
@baradhiren
baradhiren / VM_Deployer.ps1
Last active December 21, 2020 18:58
A PowerShell script to deploy VMs, Rename them, Power them off etc. etc. It can also download builds from your distribution site and extract them from gzipped or tar formats. You might need to tweak a little for your setup. :)
####################################################################################################################
#   #
#    SCRIPT NAME        : Handle_VMs.ps1 #
# #
#    DESCRIPTION        : Here are the things that this script can do: #
# 1. Download build for given version, Extract it and delete the compressed files #
# 2. Generate log file #
# 3. Deploy VM with Given IP and downloaded OVF File #
# 4. Force parameter to power off and rename any existing VMs wit
@baradhiren
baradhiren / README.md
Created August 27, 2018 04:16 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@baradhiren
baradhiren / Termux_Youtube_Downloader.sh
Last active September 10, 2022 16:51
This script will automatically create necessary environment to download videos using Termux+YoutubeDL.
#!/bin/bash
###############################################################################################################
######
###### Author : Hiren Barad
###### Date : 22-Aug-2018
###### Version : 1.0
###### FileName : Termux_Youtube_Downloader.sh
###### Description : This script will create a folder with name as Youtube in your Phone's main memory,
@baradhiren
baradhiren / Windows10-Setup.ps1
Last active August 18, 2018 17:31 — forked from NickCraver/Windows10-Setup.ps1
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
@baradhiren
baradhiren / chocolatey-env-setup.ps1
Last active August 18, 2018 17:39 — forked from amogram/chocolatey-env-setup.ps1
A Powershell Script to install all the necessary softwares in your newly formatted windows Machine. Take the script and run in Powershell as Administrator. (Note: Run at your own Risk.)
#Installing chocolatey if it is not Installed
if($(choco | grep 'Chocolatey v' | wc -l) -ne 1)
{
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
# Simple environment setup script
# Install Applications
choco install 7zip