Skip to content

Instantly share code, notes, and snippets.

View nguyenthang98's full-sized avatar
😀
Working

Nguyễn Đức Thắng nguyenthang98

😀
Working
  • Viet Nam
View GitHub Profile
@nguyenthang98
nguyenthang98 / envoy.hcl
Created May 19, 2021 14:28
envoy-testing
job "envoy" {
datacenters = ["dc1"]
type = "service"
group "envoy" {
constraint {
attribute = "${node.unique.name}"
value = "node-1"
}
count = 1
package main
import stan "github.com/nats-io/stan.go"
import "github.com/nats-io/nats.go"
import "fmt"
func main() {
nc, err := nats.Connect("tls://localhost:4443", nats.ClientCert("/client-cert.pem", "/client-key.pem"), nats.RootCAs("/client-cert.pem"))
if err != nil {
fmt.Printf("Error connect to nats %v", err)
#!/bin/bash
LIST_INDICES=$(curl -s http://localhost:9200/_cat/indices/logstash-\* | awk '$2=="open"{print $3}' | sort)
echo "Current opening indices: "
for index in $LIST_INDICES
do
echo -e "\t$index"
done
#!/bin/sh
# dump schema
cqlsh -u cassandra -p cassandra -e 'DESC KEYSPACE lwadb' >/scripts/schema_lwadb.cql
# dump data
cqlsh -k lwadb -u cassandra -p cassandra -e "COPY users to '/scripts/data_users.csv' with header=true"
@nguyenthang98
nguyenthang98 / client.hcl
Created April 21, 2021 05:48
Keepalived with Nomad
client {
enabled = true
node_class = ""
no_host_uuid = false
servers = ["10.253.155.163","10.253.155.17","10.253.155.102"]
max_kill_timeout = "30s"
package main
import (
"fmt"
"strings"
"strconv"
)
func makeSeq(min, max int) []int {
a := make([]int, max-min+1)
job "echo" {
datacenters = ["dc1"]
type = "service"
group "web" {
count = 1
constraint {
attribute = "${attr.unique.hostname}"
FROM python:3.6.12-alpine
RUN pip install beautifulsoup4
WORKDIR /opt/python
CMD ["python"]
@nguyenthang98
nguyenthang98 / Jenkinsfile
Last active October 25, 2020 10:29
Practical example with Jenkins scripted pipeline and shared library
@Library('gitlab_lib') _
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
final project_id = "nguyenthang98%2Fexample-project-jenkins"
node("Slave") {
checkout scm
final latest_commit = sh(script: 'git rev-parse --verify HEAD', returnStdout: true)
final sha = env.gitlabAfter ?:latest_commit;
#!/bin/bash
ISMASTER=$(/usr/bin/mongo --quiet --eval 'db.isMaster().ismaster')
if [ "$ISMASTER" = "true" ]
then
exit 0
else
exit 2
fi