Skip to content

Instantly share code, notes, and snippets.

Kailash Nadh knadh

Block or report user

Report or block knadh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@knadh
knadh / nats-cluster-multiple-publisher-failover.md
Created Mar 21, 2019
Running multiple active publishers on a NATS cluster for failover avoding message duplication
View nats-cluster-multiple-publisher-failover.md

Running multiple active publishers on a NATS cluster for failover while avoding message duplication

NATS is an excellent, clustered, full-mesh PubSub messaging system, highly performant and a cakewalk to setup. Full mesh means every node (servers and clients) knows about every other node, which is great, but makes it tricky to have multiple publishers on hot standby, for high availability of publishers (not the NATS network), while avoiding duplicate pubs.

Here --no-advertise comes in handy if we're willing to sacrifice the automatic meshing and discovery mechanism. This may be acceptable in setups where only a fixed set of NATS servers run in a cluster and whose addresses (either IPs or hostnames) are known.

--no-advertise

The gnatsd --no-advertise flag makes a NATS server not advertise itself automatically to the mesh. For other nodes to discover --no-advertise nodes, the --routes have to be explicitly specified. If there are N servers, there should be N routes.

@knadh
knadh / redis-protocol.go
Created Feb 16, 2019
Go function for generation Redis raw protocol for importing with redis-cli --pipe
View redis-protocol.go
package main
import (
"fmt"
"bytes"
"strconv"
)
// toRedisProto converts a Redis command, represented by a slice of
// bytes, where each element of the slice represents a chunk of the
@knadh
knadh / voltdb-direct-download.md
Created Aug 28, 2018
VoltDB Community Edition direct download
View voltdb-direct-download.md
@knadh
knadh / netstat-conn-group.sh
Created Sep 10, 2017
Group and list all TCP connections (local address) by port and number of connections
View netstat-conn-group.sh
netstat -ntu | awk ' $4 ~ /^[0-9]/ {print $4}' | sort | uniq -c | sort -n
# Rehashed from http://www.commandlinefu.com/commands/view/8767/netstat-with-group-by-ip-adress
@knadh
knadh / zsh-elapsed-time.md
Last active Aug 13, 2019
Elapsed and execution time for commands in ZSH
View zsh-elapsed-time.md

Elapsed and execution time display for commands in ZSH

Append this to your ~/.zshrc file.

function preexec() {
  timer=$(($(date +%s%0N)/1000000))
View gist:1248924
/*
Kailash Nadh (http://kailashnadh.name)
localStorageDB
September 2011
A simple database layer for localStorage
License : MIT License
*/
You can’t perform that action at this time.