This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # list all regions | |
| aws ec2 describe-regions --output text | cut -f3- | |
| # the use resourcegrouptaggingapi to list resources in each region | |
| aws resourcegroupstaggingapi get-resources --region ${REG_NAME} | jq -r '.[][] | .ResourceARN' | |
| aws resourcegroupstaggingapi get-resources --tag-filters "Key=XYZ" | jq -r '.[][] | .ResourceARN as $res | .Tags[] | select(.Key == "XYZ") | [$res, .Value ] | @csv ' | |
| # display all non-us regions | |
| aws ec2 describe-regions | jq -r '.Regions[] | select(.RegionName | test("^(?!(us-).*)")) | .RegionName' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| aws iam list-users | jq '.Users[].UserName' | xargs -t -L 1 -I {} aws iam list-user-tags --user-name {} | jq '.Tags' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # oneliners-json2yml.sh | |
| cat "json-file" | python -c 'import sys,yaml; yaml.dump(yaml.safe_load(sys.stdin),sys.stdout)' | |
| python -c 'import sys,yaml; yaml.dump(yaml.safe_load(sys.stdin),sys.stdout)' < "json-file" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| walk_aws_cli() | |
| { | |
| ToCombine="$1" | |
| shift | |
| AwsCliCmd="$@" | |
| DirName="${FUNCNAME[0]}-$$" | |
| mkdir $DirName | |
| LoopCount=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # github-download-file.sh | |
| github_download_file() | |
| { | |
| fileurl=$(echo ${2} | sed -e 's,github.com,api.github.com/repos,;s,blob/master,contents,') | |
| curl -sqk -H "Authorization: token ${1}" -H "Accept: application/vnd.github.v3.raw" -O -L "${fileurl}" | |
| } | |
| # call like: github_download_file $MY_TOKEN "https://github.com/xbalaji/xbenv/blob/master/gvimrc.html" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # mount ubuntu cdrom - | |
| sudo mount /dev/sr0 /mnt/cdrom | |
| sudo mount /dev/cdrom /mnt/cdrom # older systems | |
| # mount vmplayer shared directory | |
| sudo mkdir -p /mnt/hgfs | |
| sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other | |
| # mount remote machine windows or samba share | |
| sudo mkdir -p $HOME/remote |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env bash | |
| function get_public_gists() | |
| { | |
| for uid in ${@} | |
| do | |
| curl -sk -o - "https://api.github.com/users/${uid}/gists?per_page=200" | jq -r --arg dx $uid '.[].files[]| "-sk --create-dirs -o \($dx)/\(.filename) \(.raw_url)"' | xargs -t -L 1 curl | |
| done | |
| } | |
| get_public_gists xbalaji xbalajipge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| for ix in range(10): | |
| print('"{}"'.format("".join([str(random.randrange(10)) for ix in range(12)]))) | |
| # execute this program like: | |
| # wget -q -O - "https://gist.githubusercontent.com/xbalaji/26f0e8ec95ab6259a70b1762f33da948/raw/gen_aws_account_no.py" | python - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo apt -y install nodejs npm | |
| node --version | |
| npm --version | |
| sudo npm i -g aws-cdk | |
| cdk --version | |
| # follow example from: https://docs.aws.amazon.com/cdk/latest/guide/getting_started.html#hello_world_tutorial | |
| mkdir simple-s3 && cd simple-s3 | |
| cdk init app --language typescript |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # To encrypt | |
| # 1. save the unencrypted data in file called clear.txt | |
| # 2. execute | |
| # gpg -o ./pass.gpg -c ./clear.txt 2>/dev/null | |
| # 3. remove clear.txt | |
| # To decrypt | |
| # 1. gpg -o clear2.txt -d ./pass.gpg 2>/dev/null | |
| # 2. cat clear2.txt |