Skip to content

Instantly share code, notes, and snippets.

View thanhpk's full-sized avatar

Thanh thanhpk

View GitHub Profile
# list all topic
bin/kafka-topics.sh --list --zookeeper zookeeper:2181
# count topic message
bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic AccountSynced2 --time -1
# alter topic config
bin/kafka-topics.sh --zookeeper zookeeper:2181 --alter --topic AccountSynced2 --config cleanup.policy=compact
server {
# listen 443 default_server ssl;
listen 80;
client_max_body_size 16M;
server_name app.subiz.net;
keepalive_timeout 10;
proxy_max_temp_file_size 0;
# ssl_certificate /ssl/subiz.net.pem;
# ssl_certificate_key /ssl/subiz.net-key.pem;
server {
listen 80;
server_name ~^...\-app\.subiz\.net$ app.subiz.net app.subiz.com;
keepalive_timeout 60;
proxy_max_temp_file_size 0;
access_log /var/log/nginx/dashboard_access.log main;
error_log /var/log/nginx/dashboard_error.log warn;
var store = require('store')
var ajax = require('@subiz/ajax')
const DEAD = 'dead'
const REFRESHING = 'refreshing'
const NORMAL = 'normal'
const JUST_REFRESHED = 'just_refreshed'
function loop (cb) {
new Promise(cb).then(cont => {
class Channel {
constructor () {
this.csm = []
this.msg = []
}
enqueue (data) {
this.msg.push(data)
this.pass()
}
@thanhpk
thanhpk / resolve.js
Created September 8, 2018 05:50
resolver state machine
var store = require('store')
var ajax = require('@subiz/ajax')
var api = ajax.post()
const DEAD = 'dead'
const REFRESHING = 'refreshing'
const NORMAL 'normal'
const JUST_REFRESHED = 'just_refreshed'
@thanhpk
thanhpk / zookeeper.md
Created July 13, 2018 04:01
Get insight about zookeer cluster

echo stat | nc localhost 2181

Zookeeper version: 3.4.8-1--1, built on Fri, 26 Feb 2016 14:51:43 +0100
Clients:
 /10.128.0.10:23356[1](queued=0,recved=1612644,sent=1612660)
 /10.128.0.9:55534[1](queued=0,recved=400,sent=400)
 /10.128.0.8:25044[1](queued=0,recved=400,sent=400)
 /127.0.0.1:27466[0](queued=0,recved=1,sent=0)

Latency min/avg/max: 0/0/444
@thanhpk
thanhpk / gist:782d665e379516f8f729b6d5fd599376
Created February 12, 2018 05:36
watch kubernetes get pod
watch -n 1 'echo "GKE===================" && kubectl get pod --context="gke_subiz-version-4_us-central1-a_app-cluster-1" && echo "DEV===================" && kubectl get pod'
@thanhpk
thanhpk / Vagrantfile
Last active November 6, 2017 12:07
Vagranfile to run kubenetes locally
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.network "public_network"
config.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
config.vm.hostname = "kube"
config.vm.provision "shell", inline: <<-SHELL
*1 A die at 2
B cant send message 5 -> tell C to discard the previous package
message is stored in B, if A is the root -> B discard the message
else
2 B down at 2
A wait for ACK and retry on new B
*3 A down at 3