Skip to content

Instantly share code, notes, and snippets.

@adenosinew
adenosinew / checkClusterStatus.sh
Last active October 3, 2019 20:13
[Elasticsearch curl]
curl -X GET http://<SEARCH_NODE_FQDN>:9200/_cluster/health?pretty
@adenosinew
adenosinew / awkEndStatement.sh
Last active October 2, 2019 20:30
[AWK intro] #linux #cmd
awk '{a+=$(NF-2)}END{print "Total:", a}' logs.txt
# Output:
# Total: 504
@adenosinew
adenosinew / gitPullError.sh
Last active December 13, 2019 01:54
[Git Commands]
# If you are getting below error
# error: Untracked working tree file '***' would be overwritten by merge.
git reset --hard HEAD
git clean -f -d
git pull
@adenosinew
adenosinew / nginx.conf
Created September 18, 2019 23:20
[Bypass nginx security]
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://6.6.6.6:80;
proxy_set_header Authorization "Basic a2luZzppc25ha2Vk";
}
@adenosinew
adenosinew / logstash.sh
Created September 17, 2019 01:35
[Logstash]
# Logstash Dir Layout
# https://www.elastic.co/guide/en/logstash/current/dir-layout.html
/usr/share/logstash
/usr/share/logstash/bin
@adenosinew
adenosinew / PrintQuoted.go
Last active August 25, 2019 03:13
[Go string] Work with strings #go
// The %q (quoted) verb will escape any non-printable byte sequences in a string so the output is unambiguous.
fmt.Printf("%q\n", sample)
@adenosinew
adenosinew / createSession.go
Created August 24, 2019 04:16
[AWS Go] Use aws go sdk
sess, err := session.NewSession(&aws.Config{
Region: aws.String("us-west-2"),
Credentials: credentials.NewStaticCredentials(conf.AWS_ACCESS_KEY_ID, conf.AWS_SECRET_ACCESS_KEY, ""),
})
@adenosinew
adenosinew / s3Sync.sh
Last active February 20, 2024 23:57
[aws s3] #cloud
aws s3 sync backup s3://tgsbucket
aws s3 sync s3://tgsbucket/backup /tmp/backup
aws s3 sync s3://tgsbucket s3://backup-bucket
aws s3 sync --exclude=* --include=a* . s3://bucket/
@adenosinew
adenosinew / readFileLine.go
Last active August 14, 2019 03:45
[Go Snippets]
file, err := os.Open("file.txt")
if err != nil {
log.Fatal(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
@adenosinew
adenosinew / goCommands.sh
Created August 13, 2019 21:25
[Go Commands] Useful Go commands
# Check the gopath and goroot
go env