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 / aws_icons_plantuml
Last active June 14, 2019 18:18
how to use aws icons in plantuml
#https://github.com/milo-minderbinder/AWS-PlantUML
##to extract all the alias for usable format use
find dist/ -iname "*.puml" -exec grep -H "\!define " {} \; | sed 's_dist/\(.*\).puml:!define \([A-Z0-9a-z_]*\).*_!include <aws/\1>\n\2(varname,"icon heading")\n\n_g'
##along with file name
find dist/ -iname "*.puml" -exec grep -H "\!define " {} \; | sed 's_dist/\(.*\)/\(.*\).puml:!define \([A-Z0-9a-z_]*\).*_\2\n!include <aws/\1/\2>\n\3(var-name,"icon heading")\n\n_g'
#more good table
echo "" > /tmp/awstest.html && echo "<table><thead><th>name</th><th>Include Statement</th><th>Usage</th></thead><tbody>" >> /tmp/awstest.html && find dist/ -iname "*.puml" -type f \( ! -iname "*common.puml" \) -exec grep -H "\!define " {} \; | sed 's_dist/\(.*\)/\(.*\).puml:!define \([A-Z0-9a-z_]*\).*_<tr>\n<td>\2</td>\n<td>!include \&ltaws/\1/\2\&gt</td>\n<td>\3(var-name,"icon heading")</td></tr>\n\n_g' >> /tmp/awstest.html && echo "</tbody></table>" >> /tmp/awstest.html
@palashkulsh
palashkulsh / using_devicons_plantuml
Created June 14, 2019 17:24
how to use devicons in plantuml
#link to devicons https://github.com/tupadr3/plantuml-icon-font-sprites/blob/master/devicons/index.md
@startuml
' We only include the icon files.
!include <devicons/github>
!include <font-awesome/gitlab>
!include <devicons/redis>
frame redis [
@palashkulsh
palashkulsh / backup_mysql
Created June 6, 2019 05:26
backup mysql database
#how to backup database
mysqldump -v -hlocalhost -pstocks_pass -ustocks_user stocks| pv | gzip > stocks_database.sql.gz
@palashkulsh
palashkulsh / tshark_details
Last active February 20, 2019 12:50
using tshark to debug late server hello packets
tshark -E separator=: -r capture.cap -Tfields -e tcp.srcport -e tcp.dstport -e frame.time_epoch -e frame.number -e _ws.col.Info ssl.record.version==0x0303 or ssl.record.version==0x0301 | grep "Hello" | grep -v "Done" > ~/Downloads/tls.csv
@palashkulsh
palashkulsh / epub_to_pdf
Last active August 11, 2021 22:35
how to convert epub to pdf
sudo apt-get install calibre
ebook-convert file.epub file.pdf
@palashkulsh
palashkulsh / prepare-commit-msg
Created June 27, 2018 08:04
prepend the branch name in commit msg
put this file in .git/hooks/prepare-commit-msg file and run chmod 755 .git/hooks/prepare-commit-msg file . this prepends the branch name in the commit msg. it is useful when you have to mention jira id in every commit. then you can make a branch name with jira id in it and branch name would be prepended in every commit msg.
#!/bin/sh
BRANCH=`git branch | grep '^\*' | cut -b3-`
FILE=`cat "$1"`
echo "$BRANCH $FILE" > "$1"
@palashkulsh
palashkulsh / elasticsearch nodes stats api
Last active May 19, 2018 11:59
elasticsearch monitoring script
echo -e "\\n\"start,name,qry_rtio,http_opn,srch_rej,bulk_rej,heap_usd_pcnt,heap_cmmt_diff,old_gc_count,ld1,fd_evic,disk_q,disk_time,net_out2_retrans_ratio,net_in2_err_ratio,end\"" && curl -s -XGET localhost:9200/_nodes/stats?pretty | jq '.nodes[] | "start\",\(.name),\(.indices.search.query_time_in_millis/(.indices.search.query_total+1)|floor),\(.http.total_opened),\(.thread_pool.search.rejected),\(.thread_pool.bulk.rejected),\(.jvm.mem | .heap_used_percent),\(.jvm.mem|.heap_committed_in_bytes - .heap_max_in_bytes),\(.jvm.gc.collectors.old.collection_count),\(.os.load_average[1]),\(.indices.fielddata.evictions),\(.fs.total.disk_queue),\(.fs.total.disk_service_time),\((.network.tcp.retrans_segs /.network.tcp.out_segs)*100|floor),\((.network.tcp.in_errs / .network.tcp.in_segs)*100|floor),\"end"' | column -t -s,
@palashkulsh
palashkulsh / describe instaces of a given Service tag
Last active February 17, 2022 06:11
aws cli describe instance scripts
aws ec2 describe-instances --filters "Name=tag:Service,Values=marketplace-esclus" | jq '.Reservations[].Instances[] | "\(.PrivateIpAddress) , \(.EbsOptimized) , \(.SubnetId) , \(.Placement.AvailabilityZone) , \(.Tags[]| select(.Key == "Hostname") | .Value) , \(.InstanceType)"'
@palashkulsh
palashkulsh / curl unmatched pattern
Last active April 18, 2018 13:47
find unmatched patterns
curl -s 'https://endpoint/orders/mktorders-49*/_mapping' | jq '.' | jq '.[].mappings.items.properties |keys[]' | sort|uniq | sed 's/"//g' | xargs -I {} sh -c "if ! grep -q {} config/staging/elasticsearch_mapping.txt ; then echo {} ;fi;" \;
@palashkulsh
palashkulsh / codemod_function_name.js
Created April 18, 2018 02:43
jscodeshift codemod for function names in debugFlow logs
//http://astexplorer.net/#/84e8ZqEAwQ/6
//http://www.datasciencecentral.com/profiles/blogs/write-code-to-rewrite-your-code-jscodeshift?utm_content=buffer598df&utm_medium=social&utm_source=linkedin.com&utm_campaign=buffer
//https://github.com/reergymerej/jscodeshift-article
//https://vramana.github.io/blog/2015/12/21/codemod-tutorial/
//https://github.com/benjamn/recast
function extractNodes(node){
if (node.type === 'FunctionDeclaration') {
var arr=[];
arr.concat(extractNodes(node.left));