Skip to content

Instantly share code, notes, and snippets.

View xbalaji's full-sized avatar

Balaji (xbalaji) V xbalaji

View GitHub Profile
@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 / firefox-delete-temporary-containers.sh
Last active September 21, 2025 06:31
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
# only have the non-tmp containers
jq '.' containers.json > c01.json
jq '.identities |= map(select(.name | test("^tmp") | not)) | .identities |= sort_by(.name) | .' c01.json > containers.json
# Construct the grep pattern with 'userContextId=' for each userContextId from JSON for just the tmp containers
@xbalaji
xbalaji / jenkins-utils-functions.sh
Last active October 28, 2022 00:46
jenkins-utils-functions.sh
# source this file and use the functions, download the jenkins-cli.jar first
export JENKINS_SERVER=localhost
export JENKINS_PORT=8080
export JENKINS_USER='admin'
export JENKINS_PASS='admin'
export JENKINS_PROTO='http'
export JENKINS_JOBDIR="jenkins-jobs"
jenkins_urlhelp() {
echo "copy, change and paste for customization"
@xbalaji
xbalaji / jenkins-groovy-notes.md
Created July 11, 2020 06:34
jenkins-groovy-notes.md

execute the scripts http://jenkins-server/script

For simple jobs

def jobName = "xb-nodetest"
def job = Jenkins.instance.getItem(jobName)
job.getBuilds().each { it.delete() }
job.nextBuildNumber = 1
job.updateNextBuildNumber(1)
job.save()
@xbalaji
xbalaji / python_random_strings.sh
Last active October 8, 2020 06:26
python_random_strings.sh
# generate string list
python3 -c 'import random,json,string; print([ "".join([random.choice(string.ascii_letters) for ix in range(15)]) for jx in range(10)])'
# print one each line, logic is to create a list first and use print with * and separator
python3 -c 'import random,string; sx = ["".join([random.choice(string.ascii_letters) for ix in range(15)]) for jx in range(10)]; print(*sx, sep="\n")'
# generate a csv file, the one below generates a csv file with random people name and age, change the tuple to more than 2, you could create address
python3 -c 'import random,string; ppl = [("".join(random.choice(string.ascii_letters) for ix in range(6)), random.randrange(20,90)) for jx in range(10)]; [print(f"{name}, {age}") for name, age in ppl]'
# generate AWS account numbers, random 12 digit number, primarily used for testing
@xbalaji
xbalaji / create-macos-vm.txt
Last active June 25, 2023 01:50
create-macos-vm
# create a volume, attach it, erase the disk, save the install app to it
hdiutil create -o macos/Catalina -size 10g -volname Catalina -layout SPUD -fs HFS+J
hdiutil attach macos/Catalina.dmg -noverify -mountpoint /Volumes/Catalina
DISKNUM=$(df -h /Volumes/Catalina | tail -1 | cut -c6-10)
diskutil eraseDisk JHFS+ Catalina ${DISKNUM}
# now install the macos on to the mounted volume
"/Applications/Install macOS Catalina.app/Contents/Resources/createinstallmedia" --volume /Volumes/Catalina/ --nointeraction
# convert to img
@xbalaji
xbalaji / oneliners-aws-organizations.sh
Last active November 9, 2024 21:08
aws organizations cli
#list all accounts
aws organizations list-accounts
#list all active accounts
aws organizations list-accounts | jq -r '.Accounts[] | select(.Status == "ACTIVE") | "\(.Id) \(.Name)"'
# create a key value pair of account number to name
aws organizations list-accounts | jq -M '[.Accounts[] | select(.Status == "ACTIVE") | {(.Id): .Name}] | add | to_entries | sort_by(.key) | from_entries'
#list all in-active accounts
@xbalaji
xbalaji / xml2yaml.sh
Last active September 5, 2019 22:54
xml to yaml python one-liner
cat "xml-file" | python3 -c 'import sys,xmltodict,yaml,json; print(yaml.dump(json.loads(json.dumps(xmltodict.parse(sys.stdin.read())))))'
aws ec2 describe-vpn-connections | jq -r '.VpnConnections[].CustomerGatewayConfiguration' | python3 -c 'import sys,xmltodict,yaml,json; print(yaml.dump(json.loads(json.dumps(xmltodict.parse(sys.stdin.read())))))'
@xbalaji
xbalaji / oneliners-aws-config.sh
Last active February 24, 2021 04:22
aws cli config display defaults
aws configservice --region us-west-1 describe-delivery-channels
aws configservice --region us-west-2 describe-delivery-channels
aws configservice --region us-east-1 describe-delivery-channels
aws configservice --region us-east-2 describe-delivery-channels
aws configservice --region us-west-1 delete-delivery-channel --delivery-channel-name default
aws configservice --region us-west-2 delete-delivery-channel --delivery-channel-name default
aws configservice --region us-east-1 delete-delivery-channel --delivery-channel-name default
aws configservice --region us-east-2 delete-delivery-channel --delivery-channel-name default
@xbalaji
xbalaji / oneliners-aws-ec2.sh
Last active February 24, 2021 04:22
aws ec2 cli one liners
aws ec2 describe-instances | jq -c '.Reservations[].Instances[] | { InstanceId: .InstanceId, IP:.PrivateIpAddress, State: .State.Name} '
aws ec2 describe-instances | jq -c '.Reservations[].Instances[] | [ .InstanceId, .PrivateIpAddress, .State.Name] '
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId]' --filters Name=instance-state-name,Values=running --output text
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId,PrivateIpAddress,State.Name]' --filters Name=instance-state-name,Values=running --output text
aws ec2 describe-instances --filters Name=instance-state-name,Values=running --query 'Reservations[*].Instances[*].[InstanceId,PrivateIpAddress]' --output text