Skip to content

Instantly share code, notes, and snippets.

View d4rkb1ue's full-sized avatar
🎯
Focusing

Sheng Su d4rkb1ue

🎯
Focusing
View GitHub Profile
  • 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.
@d4rkb1ue
d4rkb1ue / albert_translate.py
Created August 21, 2018 02:13
albert translate 中文 <-> English
# -*- coding: utf-8 -*-
"""Translate text using Google Translate.
Usage: tr <src lang> <dest lang> <text>
Example: tr en fr hello
Check available languages here: https://cloud.google.com/translate/docs/languages"""
import json
import urllib.parse
@d4rkb1ue
d4rkb1ue / SimpleHTTPRequestHandler_Specific_Dir_with_204.py
Created July 25, 2018 20:49
Python SimpleHTTPServer: Serve specific directory and send 204 instead of 404 when file not found
# #!/usr/bin/env python2
import posixpath
import argparse
import urllib
import os
from SimpleHTTPServer import SimpleHTTPRequestHandler
from BaseHTTPServer import HTTPServer
class RootedHTTPServer(HTTPServer):
@d4rkb1ue
d4rkb1ue / update_gfwlist.sh
Last active October 13, 2016 15:31 — forked from VincentSit/update_gfwlist.sh
Usage(On Mac) `sudo -H ./update_gfwlist.sh`
#!/bin/bash
# update_gfwlist.sh
# Author : VincentSit
# Copyright (c) http://xuexuefeng.com
# ---Modified by d4rkb1ue drkbl.com---
# Trouble shooting
# `sudo: ./update_gfwlist.sh: command not found`
# run `chmod +x update_gfwlist.sh`