Skip to content

Instantly share code, notes, and snippets.

View mr-karan's full-sized avatar
🎯
Focusing

Karan Sharma mr-karan

🎯
Focusing
View GitHub Profile
@mr-karan
mr-karan / repo2text.sh
Created June 28, 2024 11:04
Script to output a git repo's content to a single text file. Useful for prompting with LLMs where large volume of input is supported
#!/bin/bash
set -euo pipefail # Exit on error, unset variables, and prevent errors in pipelines
# Usage information
usage() {
echo "Usage: $0 <path-to-git-repo> <output-file>"
exit 1
}
# Check for mandatory arguments
@mr-karan
mr-karan / network-rate-convert.md
Last active January 26, 2024 04:07
Convert bandwidth data rate(s) to standardized units for easier comparison

What

This Python script is designed to compare bandwidth data rates from different sources and output a uniform unit format.

Example

❯ python3 network-rate-convert.py 400MB/s 
3200.00 Mb/s
@mr-karan
mr-karan / docker-compose.yml
Created August 4, 2023 04:20
Kafka cluster with kraft
version: "2"
services:
kafka-0:
container_name: kafka-0
image: docker.io/bitnami/kafka:3.5
ports:
- "9092:9092"
environment:
- KAFKA_PROCESS_ROLES=broker,controller
@mr-karan
mr-karan / nomad-tasks-namespace.hcl
Created July 6, 2023 08:19
Simple job to demonstrate Nomad tasks sharing namespace network
job "http_servers" {
datacenters = ["dc1"]
group "group" {
network {
mode = "bridge"
port "taskA" {
static = 6000
}
port "taskB" {
@mr-karan
mr-karan / issue.md
Created December 16, 2022 07:51
Nomad template reload with raw_exec

This issue is described in hashicorp/nomad#5459 but this is a really simple to reproduce version of the same.

nomad_sighup is a really simple Go program, which listens for SIGHUP signal to be sent and prints "Received SIGHUP signal". It listens for this signal in an infinite for-loop.

The nomad deployment specs, deploys the same binary with raw_exec driver. There's a template block defined, which is a dummy configuration template. It watches for a Nomad service object doggo-web and updates whenever the Address/IP of this service updates. When that happens, Nomad is configured to send a SIGHUP signal to the underlying process. image

@mr-karan
mr-karan / test_data.txt
Created November 17, 2022 12:39
Maths sux
Query id: 583d15b7-e488-4876-88bf-c8b0b4246f5c
┌─symbol────────┬──────return_percent─┬─────────new.close─┬──────────────close─┐
│ CGCL.NS │ 1.5731874145006763 │ 742.5 │ 731 │
│ CHOLAHLDNG.NS │ -5.385943910536817 │ 604.2999877929688 │ 638.7000122070312 │
│ GUJGASLTD.NS │ 7.777898149642426 │ 513.4000244140625 │ 476.3500061035156 │
│ NAM-INDIA.NS │ -1.7775422037903055 │ 260.6499938964844 │ 265.36700439453125 │
│ NCC.NS │ 9.978915420737767 │ 78.25 │ 71.1500015258789 │
└───────────────┴─────────────────────┴───────────────────┴────────────────────┘
┌─symbol────────┬───────return_percent─┬──────────new.close─┬──────────────close─┐
@mr-karan
mr-karan / README.md
Created May 24, 2022 04:10
Format Nomad Job Files

VSCode

  • Install this extension.
  • Add the following lines to your settings.json:
    "files.associations": {
        "*.nomad": "hcl",
        "*.nomad.tpl": "hcl",
 "*.tf": "terraform",
@mr-karan
mr-karan / deployment.hcl
Last active December 26, 2023 10:30
Single Node nomad and consul
job "hello-world" {
datacenters = ["dc1"]
namespace = "default"
type = "service"
group "redis" {
# Specify number of replicas of redis needed.
count = 1
# Specify networking for the group, port allocs.
@mr-karan
mr-karan / vector_debug.txt
Created August 26, 2021 10:25
Debug Logs for vector 0.16.0 on EKS
thread 'vector-worker' panicked at 'Tried to ack beyond read offset', /project/lib/vector-core/buffers/src/disk/leveldb_buffer/reader.rs:184:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'vector-worker' panicked at 'Tried to ack beyond read offset', /project/lib/vector-core/buffers/src/disk/leveldb_buffer/reader.rs:184:13
stack backtrace:
thread 'vector-worker' panicked at 'Tried to ack beyond read offset', /project/lib/vector-core/buffers/src/disk/leveldb_buffer/reader.rs:184:13
thread 'vector-worker' panicked at 'Tried to ack beyond read offset', /project/lib/vector-core/buffers/src/disk/leveldb_buffer/reader.rs:184:13
0: 0x55df1f0de430 - std::backtrace_rs::backtrace::libunwind::trace::h34055254b57d8e79
at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
1: 0x55df1f0de430 - std::backtrace_rs::backtrace::trace_unsynchronized::h8f1e3fbd9afff6ec
@mr-karan
mr-karan / Dockerfile
Last active October 1, 2019 12:59
Passing arbitary arguments to containers in K8s
FROM alpine:latest
COPY ./arg.sh /
ENTRYPOINT ["/arg.sh"]