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-docker-functions.sh
Last active February 24, 2021 04:24
docker-utils.sh - linter, jupyter, jenkins, dillinger, swagger, codeserver
# source this file or copy and paste to get the functions in your environment
docker-lint() {
# superlinter from github
# echo "count: $#"
[[ $1 != "-f" ]] && docker run --name superlinter -t --rm -e RUN_LOCAL=true "${@}" -v $PWD:/tmp/lint github/super-linter
[[ $1 == "-f" ]] && docker run --name superlinter -t --rm -e RUN_LOCAL=true "${@:3}" -v $PWD/"${2}":/tmp/lint/"${2}" github/super-linter
}
docker-jupyter() {
@xbalaji
xbalaji / oneliners-aws-ssm.sh
Last active September 20, 2024 05:30
aws ssm cli
export AWS_DEFAULT_PROFILE=""
# to display parameter store variables for aws latest linux
aws ssm get-parameters-by-path --path "/aws/service/ami-amazon-linux-latest" --region us-west-2
# get the list of parameter store variables in the account
aws ssm describe-parameters | jq '.Parameters[].Name'
# remove the last path and filter higher level path
aws ssm describe-parameters | jq '.Parameters[].Name' | sed -e 's,\(.*\)/.*,\1",g' | sort | uniq
@xbalaji
xbalaji / aws_cli_env
Created May 10, 2019 18:33
AWS CLI environment setup
#!/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
@xbalaji
xbalaji / aws_cdk_install.sh
Last active May 16, 2019 05:59
aws-cdk-notes
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
@xbalaji
xbalaji / gen_aws_account_no.py
Last active July 20, 2019 20:46
generate aws account numbers
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 -
@xbalaji
xbalaji / gist-get-public-gists.sh
Last active October 21, 2023 17:17
gist-access-download-bookmark
#! /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
@xbalaji
xbalaji / mount-help.sh
Last active June 27, 2020 03:05
mount-cdrom-vmplayershared-remotehost-directories
# 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
@xbalaji
xbalaji / github-download-file.sh
Last active October 10, 2022 04:05
download a single github file
# 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"
@xbalaji
xbalaji / walk_aws_cli.sh
Last active September 17, 2019 03:12
aws cli shell script handling next token
walk_aws_cli()
{
ToCombine="$1"
shift
AwsCliCmd="$@"
DirName="${FUNCNAME[0]}-$$"
mkdir $DirName
LoopCount=0
@xbalaji
xbalaji / oneliners-json2yml.sh
Last active October 10, 2022 04:03
json2yml one liner
# 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"