Skip to content

Instantly share code, notes, and snippets.

View xbalaji's full-sized avatar

Balaji (xbalaji) V xbalaji

View GitHub Profile
@xbalaji
xbalaji / firefox-delete-temporary-containers.sh
Last active August 1, 2020 19:41
firefox-delete-temporary-containers.sh
#!/bin/bash
# cleanup containers.json (remove tmp containers, sort them by name)
# open command prompt in profiles directory and execute
cp containers.json c01.json
jq -r '.' c01.json | tr -d '\r' | tac | sed '/name.*tmp/{n;N;N;N;N;d}' | tac | sed '/name.*tmp/,+1d' | yq '.' | jq '.identities|=sort_by(.name)' > containers.json
preserve=""
for id in $(jq -r '.identities[] | .userContextId' containers.json | tr -d '\r' | sort -rn); do
preserve="$id\|$preserve"
@xbalaji
xbalaji / oneliners-bash.sh
Last active March 7, 2024 01:15
oneliners-bash
# split a file (sp500.csv) with 101 lines each with numeric suffixes and additional extension suffixes
split --numeric-suffixes=1 -l 101 sp500.csv stock --additional-suffix=".csv"; ls stock*.csv
# the output is as below
stock01.csv stock02.csv stock03.csv stock04.csv stock05.csv
# gnome graphical font size
# fontsize 1.5 <-- to make it bigger
# fontsize <-- to reset to normal
# fontsize 0.7 <-- to make it smaller
@xbalaji
xbalaji / oneliners-twilio.sh
Last active February 24, 2021 04:20
oneliners-twilio.sh
# https://support.twilio.com/hc/en-us/articles/223136027-Auth-Tokens-and-How-to-Change-Them
export TWILIO_ACCOUNT_SID="AC..."
export TWILIO_AUTH_TOKEN="e3.."
twilio-phone-get()
{
num=$(echo ${*} | tr -d [:space:])
[[ "$num" =~ ^[0-9].* ]] && num="+1${num}"
echo $num
@xbalaji
xbalaji / wsl-notes.md
Last active December 15, 2024 07:09
wsl-notes.md
@xbalaji
xbalaji / brew-packages-list.sh
Created March 24, 2021 04:16
brew-packages-list.sh
# generated using: $(brew leaves; brew list --cask) | sort > packages-list
# install:
# curl -skL "https://gist.github.com/xbalaji/b4902d26d7740b61947c7d6af6196412/raw/brew-packages-list.sh" | grep -v '^#' | xargs brew install
adoptopenjdk
awscli
bash
brew-gem
ccleaner
cloudfoundry/tap/cf-cli
cmake
# files modified in the last commit
git diff --name-only HEAD HEAD~1
# files modified in the last 5 commits
git diff --name-only HEAD HEAD~5
# files modified in the last 6 commits in a specific directory
git diff --name-only HEAD HEAD~6 | grep modules
# directories modified in the last 6 commits in a specific sub-folder in a specific directory
@xbalaji
xbalaji / conditional.tf
Created March 11, 2022 07:14
execute conditional logic and exit terraform execution - exception
#
# Filename : condition.tf
# Date : 04 Mar 2022
# Author : Balaji Venkataraman ([email protected])
# Description : terraform script to push updated modules to registry
#
#
# case 1:
# $terraform plan
#
@xbalaji
xbalaji / TorrentFileMassage.sh
Last active July 24, 2022 03:19
TorrentFileMassage.sh
#! /usr/bin/env bash
SEQ_NUM="01"
# generate directories list
ORG_DIRS="./org-dirs${SEQ_NUM}.txt" # original dirs list
GEN_DIRS="./gen-dirs${SEQ_NUM}.txt" # generated dirs list
MV_DIRSH="./move-dirs${SEQ_NUM}.sh"
#find TorrentDownload/ -maxdepth 1 -type d -name "* *" > "${ORG_DIRS}"
@xbalaji
xbalaji / create-dir-rename-find.sh
Created July 25, 2022 06:21
create-dir-rename-find.sh
#! /usr/bin/bash
mkdir -p Torrent/Self\ help_Pack\ {00..04}/{,{English,German}\ Author{01..3}}
touch Torrent/Self\ help_Pack\ {00..04}/{,{English,German}\ Author{01..3}}/book.pdf
mkdir -p Torrent/python\ for_datascience
touch Torrent/python\ for_datascience/python\ for_datascience.pdf
mkdir -p Torrent/yoga_the_art-of-science
touch Torrent/yoga_the_art-of-science/yoga_the_art-of-science-files{01..03}.pdf
@xbalaji
xbalaji / vm-custom.sh
Last active August 22, 2022 03:28
vm-custom.sh
# create the vm - vmx config
$grep -i "sharedfolder[0-9]" /mnt/g/Virtual\ Machines/xb-tfe/*.vmx
sharedFolder0.present = "TRUE"
sharedFolder0.enabled = "TRUE"
sharedFolder0.readAccess = "TRUE"
sharedFolder0.writeAccess = "TRUE"
sharedFolder0.hostPath = "E:\Balaji\home"
sharedFolder0.guestName = "xbhome"
sharedFolder0.expiration = "never"
sharedFolder1.present = "TRUE"