Skip to content

Instantly share code, notes, and snippets.

@devasat
devasat / git.sh
Created November 25, 2018 04:52
Git
# Launches the diff between two branches in kdiff3
gitcomparebranches () {
git difftool --tool=kdiff3 --dir-diff ${1}..${2}
}
@devasat
devasat / Dockerfile
Created November 25, 2018 00:58
Dockerfile for aws-cli
FROM centos:7.5.1804
RUN yum install epel-release -y && \
yum -y update && \
yum install -y python-pip && \
pip install awscli --upgrade
# docker build -t username/aws-cli -f Dockerfile .
# docker push username/aws-cli
@devasat
devasat / awsSecretAccessKey2SesPassword.sh
Created November 15, 2018 20:42
Convert AWS Secret Access Key to SES Password
# Ref: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html
function awsSecretAccessKey2SesPassword () {
sesPassword=$((echo -en "\x02"; echo -n 'SendRawEmail' \
| openssl dgst -sha256 -hmac "$1" -binary) \
| openssl enc -base64);
encodedSesPassword=$(python -c "import urllib; print urllib.quote('''$sesPassword''','')");
echo $encodedSesPassword;
}
# usage: awsSecretAccessKey2SesPassword $AWS_SECRET_ACCESS_KEY
@devasat
devasat / aws-cli.sh
Last active June 9, 2024 04:18
AWS CLI Examples
# ********** EC2 ***********
# describe ec2 instances
aws ec2 describe-instances \
--query 'Reservations[*].Instances[*].[InstanceId,Tags[?Key==`Name`].Value|[0],State.Name,
PrivateIpAddress,PublicIpAddress]' \
--output table
# stopped instances
@devasat
devasat / chart.yaml
Last active May 30, 2018 17:35
K8s - process chart.yaml
apiVersion: v1
version: 0.1.1
name: ${APP_NAME}
appVersion: ${APP_VERSION}
description: ${APP_DESCRIPTION}
@devasat
devasat / sum-numbers-in-column.sh
Created May 22, 2017 05:27
Sum a column of numbers
for i in `seq 1 100`; do echo $i; done | paste -sd+ - | bc
@devasat
devasat / event-year-month.json
Last active May 22, 2017 05:22
Querying JSON data using Spark SQL
{ "id" : { "year" : 2024, "month" : 10 }, "total" : 148 }
{ "id" : { "year" : 2037, "month" : 1 }, "total" : 2 }
{ "id" : { "year" : 2125, "month" : 7 }, "total" : 46 }
{ "id" : { "year" : 2033, "month" : 3 }, "total" : 7 }
{ "id" : { "year" : 2027, "month" : 1 }, "total" : 8 }
{ "id" : { "year" : 2026, "month" : 10 }, "total" : 5 }
{ "id" : { "year" : 2066, "month" : 3 }, "total" : 28 }
{ "id" : { "year" : 1980, "month" : 1 }, "total" : 5 }
{ "id" : { "year" : 2023, "month" : 1 }, "total" : 1 }
{ "id" : { "year" : 2095, "month" : 9 }, "total" : 1 }
@devasat
devasat / solr-collection-documents-count.sh
Created May 22, 2017 05:13
Apache Solr - query the number of documents in different collections
for i in collname1 collname2 collname3; do
curl -s "http://server/solr/${i}/select?q=*:*" 2>&1 | grep -o "numF.*" | cut -d' ' -f1 | cut -d\" -f2 | (read count; printf "%-20s %15s\n" $i $count;);
done;
@devasat
devasat / git.sh
Created May 21, 2017 01:37
Helpful Git commands
# view commits that are on a release branch but not on master
git log --pretty=oneline --abbrev-commit origin/release/16.12.14 --not origin/master
# view commits that are on master but not on a release branch
git log --pretty=oneline --abbrev-commit origin/master --not origin/release/16.12.14
# view unique JIRA IDs mentioned in commit messages on a release branch
git log --pretty=oneline --abbrev-commit origin/release/17.1.12 --not origin/master | grep -o "PROJNAME.*" | sed -e "s/'/:/g" | cut -d: -f1 | tr ',' '\n' | sed -e 's/ //g' | sort | uniq
@devasat
devasat / gist:777397934f565df6264016098049f3fc
Created May 21, 2017 01:23
Call login protected (Java) services using curl
# JSESSIONID is used by the server to identify if the user is logged in. Manually login via the browser in the application,
# use Chrome developer tool or Firebug to get JSESSIONID and use that in the curl command to invoke the service endpoints.
curl --cookie "JSESSIONID=REPLACE_THIS" http://localhost.xom/api/resourcename/id
#Example:
for i in `seq 1 100` ; do
curl --cookie "JSESSIONID=12345678901234567890" http://localhost.xom/api/resourcename/${i}/; echo "";
done