Skip to content

Instantly share code, notes, and snippets.

adenosinew

Block or report user

Report or block adenosinew

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View findLatestCommit.sh
# https://stackoverflow.com/questions/5188320/how-can-i-get-a-list-of-git-branches-ordered-by-most-recent-commit
git for-each-ref --sort=-committerdate refs/heads/
# Or using git branch (since version 2.7.0)
git branch --sort=-committerdate # DESC
git branch --sort=committerdate # ASC
@adenosinew
adenosinew / checkClusterStatus.sh
Last active Oct 3, 2019
[Elasticsearch curl]
View checkClusterStatus.sh
curl -X GET http://<SEARCH_NODE_FQDN>:9200/_cluster/health?pretty
@adenosinew
adenosinew / awkEndStatement.sh
Last active Oct 2, 2019
[AWK intro] #linux #cmd
View awkEndStatement.sh
awk '{a+=$(NF-2)}END{print "Total:", a}' logs.txt
# Output:
# Total: 504
View gitPullError.sh
# 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 Sep 18, 2019
[Bypass nginx security]
View nginx.conf
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";
}
View logstash.sh
# 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 Aug 25, 2019
[Go string] Work with strings #go
View PrintQuoted.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 Aug 24, 2019
[AWS Go] Use aws go sdk
View createSession.go
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
Created Aug 19, 2019
[aws s3] #cloud
View s3Sync.sh
aws s3 sync backup s3://tgsbucket
aws s3 sync s3://tgsbucket/backup /tmp/backup
aws s3 sync s3://tgsbucket s3://backup-bucket
View readFileLine.go
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())
}
You can’t perform that action at this time.