Skip to content

Instantly share code, notes, and snippets.

View denzhel's full-sized avatar
🇺🇦

Dennis Zheleznyak denzhel

🇺🇦
View GitHub Profile
@denzhel
denzhel / kafka_urp.md
Created May 28, 2025 06:09
kafka: list topics with under replicated partitions

To get the list of topics that has under replicated paritiions, use the following command:

kafka-topics.sh --bootstrap-server <broker> --describe | \
awk '/Topic:/ && /Partition:/ && /Isr:/ {
  n=split($0,a,"Replicas: "); split(a[2],b," "); r=split(b[1],_,",");
  n=split($0,a,"Isr: "); split(a[2],b," "); i=split(b[1],_,",");
  if (r != i) print $2
}' | sort | uniq

To describe the topic use:

@denzhel
denzhel / es_slow_queries.md
Last active May 28, 2025 06:05
elasticsearch: get slow queries

To get the slow queries in Elasticsearch, use the following command:

curl -s 'http://<hostNameorIP>:9200/_tasks?detailed&pretty' | jq '.nodes[] | .tasks[] | select(.running_time_in_nanos > 10000000000) | {task_id, action, running_time_in_nanos, description}'
@denzhel
denzhel / frigate_telegram_notification.yaml
Last active February 21, 2024 10:32 — forked from NdR91/frigate_telegram_notification.yaml
Frigate - Telegram Notification
blueprint:
name: Frigate - Telegram Notification
description: Create automations to receive Snapshots and Clips from Frigate
domain: automation
input:
camera:
name: Frigate Camera
description: The name of the camera as defined in your frigate configuration (/conf.yml).
target_chat:
name: Target
@denzhel
denzhel / atlassian_ip_ranges.md
Created December 25, 2022 20:50
get IP addresses of atlassian services

To get the IP ranges for a specific service in Atlassian cloud, use this:

curl -s https://ip-ranges.atlassian.com | jq -r '.items[] | select(.product[]=="statuspage") | select (.mask_len<32) | .cidr'
@denzhel
denzhel / aws_ip_addresses.md
Created December 25, 2022 20:48
aws IP addresses for a specific server

To get the IP ranges for a specific service in a specific region, use this:

curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.region=="us-west-1") | select(.service=="S3") | .ip_prefix'
@denzhel
denzhel / snowflake_delete_table.md
Created December 11, 2022 22:08
snowflake delete table privilege

To allow roles to delete talbes in a specific database.schema:

grant DELETE TABLE on <dbName>.<schmeaName> to role <roleName>;
@denzhel
denzhel / snowflake_create_db.md
Created December 11, 2022 22:06
snowflake create database privilege

To grant other roles to be able to create databases privilege:

grant CREATE DATABASE on account to role <roleName>;
@denzhel
denzhel / snowflake_execute_task.md
Created December 11, 2022 22:04
snowflake execute task privilege

If you're getting this error:

Cannot execute task , EXECUTE TASK privilege must be granted to owner role`

You should grant the following privilege using an ACCOUNTADMIN role or similar:

GRANT EXECUTE TASK ON ACCOUNT TO ROLE <roleName>;
@denzhel
denzhel / aws_decode_err_msg.md
Created August 17, 2022 21:51
decode AWS encoded error message

When you get this kind of message:

"code": "UnauthorizedOperation",
       "message": "You are not authorized to perform this operation. Encoded authorization failure message: Q92aQ6....

Make sure you have the proper set of IAM rights, I simply use an assumable administrator role:

eval $(aws sts assume-role \
--role-arn arn:aws:iam::1234567:role/mgmt-assumable-role \
--role-session-name test | \
@denzhel
denzhel / tf_iam_user_rotate.md
Created August 10, 2022 17:52
rotate iam user key with terraform
# create a pair of access key id and access secret key for the user above
resource "aws_iam_access_key" "active" {
  user   = aws_iam_user.travis_ci.name
  status = "Active"
}
# create a pair of rotated access key id and access secret key for the user above
resource "aws_iam_access_key" "rotated" {
  count = var.key_rotation ? 1 : 0
  user  = aws_iam_user.travis_ci.name