Skip to content

Instantly share code, notes, and snippets.

@anton-yurchenko
anton-yurchenko / script.py
Created November 4, 2024 19:03
Redis Shards Distribution
import binascii
# Define nodes with precise slot ranges based on Redis cluster configuration
nodes = [
{"name": "node-0001", "ranges": [range(2730, 8192)]},
{"name": "node-0002", "ranges": [range(8192, 9767), range(12498, 16384)]},
{"name": "node-0003", "ranges": [range(0, 2730), range(9767, 12498)]}
]
# Define the keys to calculate hash slots
@anton-yurchenko
anton-yurchenko / docker-compose.yml
Created October 30, 2024 11:16
Redis Cluster Docker Compose
services:
cache-node-1:
image: docker.io/bitnami/redis-cluster:7.4
container_name: cache-node-1
hostname: cache-node-1
ports:
- 6379:6379
environment:
- ALLOW_EMPTY_PASSWORD=yes
- REDIS_NODES=cache-node-1 cache-node-2 cache-node-3 cache-node-4 cache-node-5 cache-node-6
@anton-yurchenko
anton-yurchenko / jenkins-create-token.groovy
Created October 30, 2022 10:27
Jenkins Console Groovy Script to Generate New User Token
// Source: https://docs.cloudbees.com/docs/cloudbees-ci-kb/latest/client-and-managed-masters/how-to-generate-change-an-apitoken
import hudson.model.*
import jenkins.model.*
import jenkins.security.*
import jenkins.security.apitoken.*
// script parameters
def userName = 'admin'
def tokenName = 'token'
@anton-yurchenko
anton-yurchenko / golang-generic-struct.md
Created April 16, 2022 08:14
GoLang Generic Struct

The following snippet contains an example for GoLang Generics for Structs:

package main

import "fmt"

// Structs definition
type ObjectOne struct {
	Name string      `json:"name"`
@anton-yurchenko
anton-yurchenko / curl-performance.md
Created March 21, 2022 21:01
Simple perfomance testing using curl
  1. Create a format.txt file with the following content:
time_namelookup:      %{time_namelookup}s\n 
time_connect:         %{time_connect}s\n
time_appconnect:      %{time_appconnect}s\n 
time_pretransfer:     %{time_pretransfer}s\n
time_redirect:        %{time_redirect}s\n 
time_starttransfer:   %{time_starttransfer}s\n
 ----------\n 
@anton-yurchenko
anton-yurchenko / mirror_bitbucket_repos.py
Created February 26, 2022 11:00
Mirror BitBucket Repositories
#!/usr/bin/python
import os
import stashy
projects = [
"PROJ-1",
"PROJ-2",
"PROJ-3",
]
@anton-yurchenko
anton-yurchenko / github_string_search.py
Last active April 28, 2023 16:19
String search on GitHub organization
from requests import get
from sys import argv, exit
from os import environ
from requests.models import HTTPBasicAuth
def main():
if len(argv) < 3:
print('invalid input, expected arguments: `python3.9 script.py <account-name> <search-string>`')
exit(1)
@anton-yurchenko
anton-yurchenko / aws-org-cloudtrail.md
Last active April 16, 2022 08:17
Query AWS Organization CloudTrail Logs Using Athena

Notice: if you want to query logs for multiple days (week or so), you might need to transform them to pargquet first

Table Creation DDL:

CREATE EXTERNAL TABLE cloudtrail_logs(
    eventVersion STRING,
    userIdentity STRUCT<
        type: STRING,
        principalId: STRING,
@anton-yurchenko
anton-yurchenko / jenkins-print-credentials.groovy
Created July 19, 2021 11:16
Jenkins Console Groovy Script to Print Credentials username/password
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
def jenkinsCredentials = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.Credentials.class,
Jenkins.instance,
null,
null
@anton-yurchenko
anton-yurchenko / list-active-github-repositories.md
Last active April 16, 2022 08:30
List Active Repositories with GitHub Actions Flows

This script will list all active repositories in an organization with GitHub Actions workflows.

  1. Generate Access Token with repo scope and replace <TOKEN>
  2. Replace <ORGANIZATION> with your organizaiton name
  3. Save to file and run the script
#!/bin/sh

token="<TOKEN>"