Skip to content

Instantly share code, notes, and snippets.

View palashkulsh's full-sized avatar
💔
delusion of reprieve

palash kulshreshtha palashkulsh

💔
delusion of reprieve
View GitHub Profile
@palashkulsh
palashkulsh / ebs snapshot data
Last active March 18, 2024 08:49
ebs snapshots
aws ec2 describe-snapshots --region ap-south-1 --query 'Snapshots[*].[SnapshotId,StartTime,VolumeSize,VolumeId,StorageTier,State,Tags[?Key==`Techteam`].Value | [0],Tags[?Key==`Project`].Value | [0],Description]' --output json | jq -r '.[] | @csv'
@palashkulsh
palashkulsh / Calculating network bandwidth usage
Last active February 2, 2024 07:33
how to check network bandwidth usage of a port via tcpdump
# documented in https://superuser.com/questions/356907/how-to-get-real-time-network-statistics-in-linux-with-kb-mb-bytes-format-and-for
Your application is probably sending packets to a specific UDP or TCP port number or to a specific IP-address.
You can therefore use something like TCPdump to capture that traffic.
TCPdump doesn't give you the real-time stats you desire but you can feed it's output to something that does (I'll try to update this answer with an answer later).
Update:
@palashkulsh
palashkulsh / auto scaling group filtering
Created April 6, 2020 15:31
filtering auto scaling group on the basis of tags
sudo aws autoscaling describe-auto-scaling-groups --region=ap-south-1 --query 'AutoScalingGroups[] | [?contains(Tags[?Key==`Techteam`].Value, `mall-cart`)]' | jq '.[] | "\(.AutoScalingGroupName),\(.TerminationPolicies[])"'
@palashkulsh
palashkulsh / aws_tag_by_ip.sh
Created November 24, 2017 10:20
get aws tags of private ip address using aws cli and jq
#ip.csv file should have single column of private ip
cat ip.csv | xargs -I {} aws ec2 describe-instances --filter Name=private-ip-address,Values={} | jq --arg tag1 "Service" --arg tag2 "Team" '.Reservations[].Instances[] | "\(.PrivateIpAddress) , \(.Tags[]| select(.Key==$tag1) | .Value) , \(.Tags[]| select(.Key==$tag2) | .Value)"' > ip_service_team.csv
If you want to find last value of the column
K1 is start of upper header, U6 is end of current row
we want to find header of last non empty column in a row (for K to U columns)
=ifna(index(filter($K$1:U6,not(ISBLANK(K6:U6))),1,counta(K6:U6)),"TBD")
This selects subset of non empty cells from K1 to U6 (from first row to current row)
FILTER AREA
=filter($K$1:U6,not(ISBLANK(K6:U6)))
@palashkulsh
palashkulsh / gist:0e750490b0bd2767fc0267c16cb9e744
Created May 18, 2020 10:38
mitmproxy for intercepting https request
./mitmproxy --ssl-insecure --mode reverse:https://url_you_want_to_ultimately_hit:443 -p 1234
@palashkulsh
palashkulsh / excel option generator
Created November 20, 2022 14:27
generate excel worksheet with merged cell for each option
import xlsxwriter
from functools import reduce
# Create an new Excel file and add a worksheet.
workbook = xlsxwriter.Workbook('merge1.xlsx')
worksheet = workbook.add_worksheet()
# Create a format to use in the merged range.
merge_format = workbook.add_format({
@palashkulsh
palashkulsh / ebs snapshot
Created September 8, 2022 12:15
ebs snapshot
aws ec2 describe-snapshots --filters Name=tag:Techteam,Values=mall-cart | jq '.Snapshots[] | "\(.SnapshotId),\(.VolumeId),\(.StartTime),\(.VolumeSize),\(.Tags[] | select(.Key=="Hostname") | .Value),\(.Description)"'
@palashkulsh
palashkulsh / org2png
Last active September 4, 2022 20:26
org file to plantuml mindmap or work break down structure wbs diagram creator
#!/bin/bash
#identify is part of imagemagick suite
echo "@startmindmap" > /tmp/.org2file.uml
cat $1 >> /tmp/.org2file.uml
echo "@endmindmap" >> /tmp/.org2file.uml
#if -DPLANTUML_LIMIT_SIZE=18192 is not provided then image gets cropped off
java -jar /home/palashkulshreshtha/bin/plantuml.jar -DPLANTUML_LIMIT_SIZE=18192 -o /tmp/ /tmp/.org2file.uml
@palashkulsh
palashkulsh / jq_map_creation
Last active July 30, 2022 18:46
jq new usages
[{pincode:1,value:1},{pincode:2,value:2}]
to
{1:{pincode:1,value:1},2:{pincode:2,value:2}}
jq '.| map({(.pincode|tostring): .}) | add' IN.json > pincode_wise.json