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
wget percona.com/get/pt-query-digest
chmod 755 pt-query-digest
tcpdump -s 65535 -x -nn -q -tttt -i any -c 400000 port 3306 | pt-query-digest --type tcpdump --output slowlog
@palashkulsh
palashkulsh / Kafka commands.md
Created March 8, 2018 09:43 — forked from vkroz/Kafka commands.md
Kafka frequent commands

Kafka frequent commands

Assuming that the following environment variables are set:

  • KAFKA_HOME where Kafka is installed on local machine (e.g. /opt/kafka)
  • ZK_HOSTS identifies running zookeeper ensemble, e.g. ZK_HOSTS=192.168.0.99:2181
  • KAFKA_BROKERS identifies running Kafka brokers, e.g. KAFKA_BROKERS=192.168.0.99:9092

Server

Start Zookepper and Kafka servers

@palashkulsh
palashkulsh / syncing with grive
Last active September 20, 2019 09:15
grive sync list
#we need to find a better way to sync
grive -d -u
###now using
https://pypi.org/project/drive-cli/
@palashkulsh
palashkulsh / backup_database.sh
Created April 2, 2018 05:32
backup database in zipped file
mysqldump -v -hlocalhost -pstocks_pass -ustocks_user stocks| pv | gzip > stocks_database.sql.gz
@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));
@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 / 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 / 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 / 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 / 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