Skip to content

Instantly share code, notes, and snippets.

View riteshshrv's full-sized avatar
🎯
Focusing

Ritesh Shrivastav riteshshrv

🎯
Focusing
  • Zerodha
  • Bangalore
View GitHub Profile
@knadh
knadh / nats-cluster-multiple-publisher-failover.md
Created March 21, 2019 08:02
Running multiple active publishers on a NATS cluster for failover avoding message duplication

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.

@bgadrian
bgadrian / set.go
Last active June 4, 2024 16:29
How to implement a simple set data structure in golang
type Set struct {
list map[int]struct{} //empty structs occupy 0 memory
}
func (s *Set) Has(v int) bool {
_, ok := s.list[v]
return ok
}
@boreycutts
boreycutts / i3-gaps_installation_guide.md
Last active January 30, 2024 19:05
A simple installation guide for i3-gaps

Installing i3-gaps

Dependencies

i3-gaps has some packages that are required for it to work so install these things:

sudo apt install libxcb1-dev libxcb-keysyms1-dev libpango1.0-dev libxcb-util0-dev libxcb-icccm4-dev libyajl-dev libstartup-notification0-dev libxcb-randr0-dev libev-dev libxcb-cursor-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev libxkbcommon-x11-dev autoconf xutils-dev libtool automake

You also need to install libxcb-xrm-dev, but I got Unable to locate package libxcb-xrm-dev when trying to install from the apt repositories on Ubuntu 16.04. If this happens to you, just install it from source using these commands:

mkdir tmp
@vividvilla
vividvilla / mailer.py
Last active August 5, 2022 20:14
Mailer - Simple Python wrapper to send email via SMTP
from smtplib import SMTP # Use this for standard SMTP protocol (port 25, no encryption)
# from smtplib import SMTP_SSL as SMTP # This invokes the secure SMTP protocol (port 465, uses SSL)
from email.mime.text import MIMEText
class Email(object):
SMTP_CONFIG = dict(
server="your_smtp_server_hostname",
username="your_smtp_server_username",
password="your_smtp_server_password"
@hackedunit
hackedunit / install-redis.md
Last active October 11, 2023 12:37
Install and configure Redis on Ubuntu 16.04 with systemd
  1. Install pre-requisities

sudo apt-get install build-essential tcl

  1. Install Redis
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@michaellihs
michaellihs / devops-days-kiel-messaging.md
Last active November 26, 2022 16:57
DevOps Days Kiel: Message Queues as an Integration Approach for Micro Services

DevOps Days Kiel: Message Queues as an Integration Approach for Micro Services

Micro Services seem to be a trendy topic in software development nowadays and often they go hand in hand with message queues as an integration approach. So the question arises, whether message queues become the replacement for relational databases as an integration scenario and whether it is a better approach or not.

So here are some questions:

Are you using message queues in your (micro service) projects?

  • Yes, for emails --> RabbitMQ, 10,000 requests / seconds
@kristopolous
kristopolous / hn_seach.js
Last active July 24, 2023 04:12
hn job query search
// Usage:
// Copy and paste all of this into a debug console window of the "Who is Hiring?" comment thread
// then use as follows:
//
// query(term | [term, term, ...], term | [term, term, ...], ...)
//
// When arguments are in an array then that means an "or" and when they are seperate that means "and"
//
// Term is of the format:
// ((-)text/RegExp) ( '-' means negation )
@staltz
staltz / introrx.md
Last active June 26, 2024 10:24
The introduction to Reactive Programming you've been missing
#!/bin/bash
#
# Bash script to setup headless Selenium (uses Xvfb and Chrome)
# (Tested on Ubuntu 12.04) trying on ubuntu server 14.04
# Add Google Chrome's repo to sources.list
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
# Install Google's public key used for signing packages (e.g. Chrome)
# (Source: http://www.google.com/linuxrepositories/)