Skip to content

Instantly share code, notes, and snippets.

View MalKeshar's full-sized avatar

Alexander Pereyaslavets MalKeshar

View GitHub Profile
@MalKeshar
MalKeshar / gist:2443a9498d874ad659a728c3025ce8d0
Created January 9, 2022 17:17 — forked from williballenthin/gist:ee0335a6826ce55ece2d
Methods for fetching structure fields in Go (golang)
package main
import "log"
import "time"
import "reflect"
// suggested via http://stackoverflow.com/a/8363629/87207
func trace(s string) (string, time.Time) {
log.Println("START:", s)
return s, time.Now()
@MalKeshar
MalKeshar / kafka-move-leadership.sh
Created February 16, 2021 21:40 — forked from miguno/kafka-move-leadership.sh
A simple Ops helper script for Apache Kafka to generate a partition reassignment JSON snippet for moving partition leadership away from a given Kafka broker. Use cases include 1) safely restarting a broker while minimizing risk of data loss, 2) replacing a broker, 3) preparing a broker for maintenance.
#!/usr/bin/env bash
#
# File: kafka-move-leadership.sh
#
# Description
# ===========
#
# Generates a Kafka partition reassignment JSON snippet to STDOUT to move the leadership
# of any replicas away from the provided "source" broker to different, randomly selected
# "target" brokers. Run this script with `-h` to show detailed usage instructions.
@MalKeshar
MalKeshar / bash.generate.random.alphanumeric.string.sh
Created February 14, 2021 21:02 — forked from earthgecko/bash.generate.random.alphanumeric.string.sh
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1