Skip to content

Instantly share code, notes, and snippets.

View denzhel's full-sized avatar
🇺🇦

Dennis Zheleznyak denzhel

🇺🇦
View GitHub Profile
@denzhel
denzhel / mongo_increase_screen_buffer.md
Created February 9, 2021 07:30
Increase Mongo shell screen buffer

If you're trying to query Mongo and get this message:

Type "it" for more

Run this command:

DBQuery.shellBatchSize = 200;
@denzhel
denzhel / unique_keys_mongo_query.md
Created February 11, 2021 06:37
Return only unique keys in Mongo query

If you want to return only unique keys/fields in mongo query while searching inside a collection:

db.users.distinct("name")

If you want to know how many entries were returned:

db.users.distinct("name").length
@denzhel
denzhel / generate_data_elasticsearch.md
Created February 15, 2021 01:34
Generate random data for elasticsearch

If you need to generate some random data, use this tool:

git clone https://github.com/oliver006/elasticsearch-test-data.git
cd elasticsearch-test-data
pip install -r requirements.txt

Pass in the required info:

/es_test_data.py --es-url=http://:9200
@denzhel
denzhel / delete_files_older_than.md
Last active April 22, 2021 04:34
delete files older than

To delete files older than a certain date, you can use the following:

sudo find . -mtime +<AmountOfDays> -type f -delete

#linux #bash

@denzhel
denzhel / travis_scala_sbt_error.md
Created April 22, 2021 04:39
fix travis scala download error

If you're getting the following error while using travis CI:

Downloading sbt launcher for 1.2.6:
221  From  https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/1.2.6/sbt-launch-1.2.6.jar
222    To  /home/travis/.sbt/launchers/1.2.6/sbt-launch.jar
223Downloading sbt launcher 1.2.6 md5 hash:
224  From  https://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/1.2.6/sbt-launch-1.2.6.jar.md5
225    To  /home/travis/.sbt/launchers/1.2.6/sbt-launch.jar.md5
226cat: /home/travis/.sbt/launchers/1.2.6/sbt-launch.jar.md5: No such file or directory
227md5sum: 'standard input': no properly formatted MD5 checksum lines found
@denzhel
denzhel / scheduled_ec2_shutdown.md
Last active April 22, 2021 09:01
scheduled_ec2_shutdown

To schedule the shutdown and startup of your EC2 instances, you can use this Lambda Python code. Please note that this code looks for EC2 instance by their Tag(line 8), e.g role = runner.

import boto3

# Define variables
client = boto3.client('ec2', region_name="us-east-1")
filters =[ { 'Name': 'tag:<KeyName>', 'Values': ['<ValueName>'] } ]

# Get the list of instances by searching for the tag configured above
@denzhel
denzhel / macos_specific_resolver.md
Created April 26, 2021 08:34
MacOS resolve specific domains

If you want to resolve a specific domain with a specific resolver/nameserver, add this:

sudo mkdir /etc/resolver
sudo echo "nameserver <IPAddress>" >> /etc/resolver/internal.domain.io

This was tested on Big Sur 11.2.3

@denzhel
denzhel / query_docker_rate_limit.md
Created April 29, 2021 19:41
Query Docker for rate limit

If you're using Docker Hub as a docker registry and using an anonymous account at some point you will hit the rate limit. To know where you stand use this:

IMAGE="ratelimitpreview/test"
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:$IMAGE:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/$IMAGE/manifests/latest

This will output:

@denzhel
denzhel / telepresence_private_registry.md
Created May 1, 2021 19:41
Pull telepresence from private registry

If you get this error while trying to launch Telepresence on your K8s env:

Failed to pull image "datawire/telepresence-k8s:0.109": 
rpc error: code = Unknown desc = Error response from daemon: 
toomanyrequests: You have reached your pull rate limit. 
You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit

Upload it to your registry, for example AWS ECR:

@denzhel
denzhel / verbose_mode_kafka_connect.md
Last active June 13, 2022 12:42
Debug mode for Kafka Connect

If you want to debug your deployment of kafka-connect, pass in the env variable or edit the K8s deployment:

- name: CONNECT_LOG4J_LOGGERS
  value: org.apache.kafka.connect=DEBUG

You can also use multiple loggers:

- name: CONNECT_LOG4J_LOGGERS
 value: "log4j.logger.io.confluent.inbound-kafka-to-s3=DEBUG,org.apache.kafka.connect=DEBUG"