Skip to content

Instantly share code, notes, and snippets.

  • What do Etcd, Consul, and Zookeeper do?
    • Service Registration:
      • Host, port number, and sometimes authentication credentials, protocols, versions numbers, and/or environment details.
    • Service Discovery:
      • Ability for client application to query the central registry to learn of service location.
    • Consistent and durable general-purpose K/V store across distributed system.
      • Some solutions support this better than others.
      • Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
  • Centralized locking can be based on this K/V store.
@arypurnomoz
arypurnomoz / gist:8d24155f024f8d4b6bee6b053c6e47d9
Last active December 20, 2016 07:44
running es 5.0.0 on docker workaround
apt-get update && apt-get install -y nginx;
echo '
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
server {
@wojteklu
wojteklu / clean_code.md
Last active August 19, 2025 16:46
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@subfuzion
subfuzion / empty-example.md
Last active February 26, 2024 20:39
Protocol Buffer example of importing and using empty

How to import and indicate empty request or reply messages:

import "google/protobuf/empty.proto";

service SomeService {
    rpc SomeOperation (google.protobuf.Empty) returns (google.protobuf.Empty) {}
}
@Paradoxis
Paradoxis / http-to-ws.js
Last active December 31, 2024 15:07
Convert WS/HTTP links with JavaScript
/**
* Converts an HTTP(S) url to a WS(S) URL
* Example:
* httpUrlToWebSockeUrl("http://www.example.com/") -> ws://www.example.com/
* httpUrlToWebSockeUrl("https://www.example.com/") -> wss://www.example.com/
*
* @param {string} url
* @return {string}
*/
function httpUrlToWebSockeUrl(url)
@henriquemenezes
henriquemenezes / postgresql-set-id-seq.sql
Created March 31, 2016 12:23
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));

Intercom user_hash

Remember that your secret key should never be exposed to the public

  • So Javascript code below should only be used for testing unless modified and used to run on a server
@patik
patik / how-to-squash-commits-in-git.md
Last active July 24, 2025 08:48
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

#!/bin/bash
JQPATH=$(which jq)
if [ "x$JQPATH" == "x" ]; then
echo "Couldn't find jq executable." 1>&2
exit 2
fi
set -eu
shopt -s nullglob
@Qt-dev
Qt-dev / backendData.js
Created July 3, 2014 09:55
An accordion in ReactJS/CSS3
var backendData = [
{
"title":"Section 1",
"content":"Our content for the section 1"
},
{
"title":"Section 2",
"content":"Our content for the section 2"
},
{