Skip to content

Instantly share code, notes, and snippets.

@marwei
marwei / how_to_reset_kafka_consumer_group_offset.md
Created November 9, 2017 23:39
How to Reset Kafka Consumer Group Offset

Kafka 0.11.0.0 (Confluent 3.3.0) added support to manipulate offsets for a consumer group via cli kafka-consumer-groups command.

  1. List the topics to which the group is subscribed
kafka-consumer-groups --bootstrap-server <kafkahost:port> --group <group_id> --describe

Note the values under "CURRENT-OFFSET" and "LOG-END-OFFSET". "CURRENT-OFFSET" is the offset where this consumer group is currently at in each of the partitions.

  1. Reset the consumer offset for a topic (preview)
;; Stolen from:
;; http://mikehucka.postach.io/post/modifying-emacss-vc-diff-for-word-oriented-diffs
;;
;; Improvements:
;; - Be smarter about adding --word-diff to `vc-git-diff-switches' and
;; not clobbering any existing settings.
;; - Use `defface' as the docstring for `make-face' recommends.
;; - Base face defaults on `diff-added' and `diff-removed'.
;; - Rename `vc-diff-deleted-face' to `vc-diff-removed-face' for
;; consistency with existing face naming conventions.
@josephspurrier
josephspurrier / sshclient.go
Last active September 10, 2022 02:23
Golang SSH Client
package main
import (
"bufio"
"io/ioutil"
"os/signal"
//"syscall"
"fmt"
"log"
"os"
@acdvorak
acdvorak / tmux-all-panes.sh
Last active August 6, 2021 17:09 — forked from yubink/inall.sh
tmux: run a command in all panes
#!/bin/bash
# Runs the specified command (provided by the first argument) in all tmux panes
# in every window. If an application is currently running in a given pane
# (e.g., vim), it is suspended and then resumed so the command can be run.
all-panes()
{
all-panes-bg_ "$1" &
}
@Integralist
Integralist / 0. description.md
Last active June 17, 2023 21:49
Clojure deftype, defrecord, defprotocol
  • defprotocol: defines an interface
  • deftype: create a bare-bones object which implements a protocol
  • defrecord: creates an immutable persistent map which implements a protocol

Typically you'll use defrecord (or even a basic map);
unless you need some specific Java inter-op,
where by you'll want to use deftype instead.

Note: defprotocol allows you to add new abstractions in a clean way Rather than (like OOP) having polymorphism on the class itself,

@rabbitt
rabbitt / schema_clone.py
Last active October 8, 2020 12:56
PostgreSQL schema cloner (including data).
import psycopg2 as pg
from io import BytesIO
from collections import defaultdict
from contextlib import contextmanager
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT, ISOLATION_LEVEL_READ_COMMITTED
READ_COMMIT = ISOLATION_LEVEL_READ_COMMITTED
AUTO_COMMIT = ISOLATION_LEVEL_AUTOCOMMIT
[bigq_buffer]
type = "SandboxFilter"
ticker_interval = 30
script_type = "lua"
filename = "<path_to_lua>"
preserve_data = true
message_matcher = 'Logger == "boundary_haproxy"'
[bigq_buffer.config]
num_buff_rows = 100
preservation_version = 1
@tamastimar
tamastimar / nextWindow.lua
Last active April 12, 2021 12:51
Hammerspoon (http://hammerspoon.org) script to switch to next window of frontmost app in OS X
-- Window Manipulation
-- Bind alt-Tab to show next window of current application
hs.hotkey.bind({"alt"}, "Tab", function()
local app = hs.application.frontmostApplication()
local windows = app:allWindows()
local nextWin = nil
@gubatron
gubatron / multiple-deploy-keys-multiple-private-repos-github-ssh-config.md
Last active March 12, 2024 07:34
How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

How to configure multiple deploy keys for different private github repositories on the same computer without using ssh-agent

Let's say alice is a github.com user, with 2 or more private repositories repoN. For this example we'll work with just two repositories named repo1 and repo2

https://github.com/alice/repo1

https://github.com/alice/repo2

You need to be to pull from these repositories without entering a passwords probably on a server, or on multiple servers.