Skip to content

Instantly share code, notes, and snippets.

View udhos's full-sized avatar
👾
Wondering

udhos

👾
Wondering
  • São Paulo, Brazil
View GitHub Profile
@udhos
udhos / nginx.conf.md
Created November 22, 2021 18:22
nginx reverse proxy: http -> https
nginx -v
nginx version: nginx/1.20.0

more /etc/nginx/nginx.conf
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/
@udhos
udhos / mongodb_index.md
Created November 18, 2021 15:27
mongodb_index.md
db.person.getIndexes()

db.person.createIndex( { "personId": 1 }, { unique: true } )

	Index already exists with different options

db.person.dropIndex("personId_1")
@udhos
udhos / cloudwatch_logs_insights_parse_fields.md
Last active November 18, 2021 12:20
cloudwatch_logs_insights_parse_fields.md
fields @timestamp, @message
| filter (@message like /records=/)
| parse @message /records=(?<records>\S+)/
| filter records >= 200
| sort @timestamp desc
| limit 2000
@udhos
udhos / decorator.py
Created November 16, 2021 15:07
decorator.py
#!/usr/bin/env python3
#
# https://realpython.com/primer-on-python-decorators/
import functools
import math
# a decorator:
# - takes a function f1 as argument
# - returns a new function f2
@udhos
udhos / mongodb_last_inserted.txt
Last active November 12, 2021 18:56
mongodb_last_inserted.txt
You can run the operation in the web shell below:
https://docs.mongodb.com/manual/tutorial/query-arrays/
# to find(query) with two conditions on the same field, use $and:
db.inventory.find(
{$and:
[
{tags: {$size:3}},
@udhos
udhos / go_port_forwarding.go
Created October 21, 2021 00:28 — forked from qhwa/go_port_forwarding.go
network port forwarding in go lang
package main
import (
"fmt"
"io"
"net"
)
func main() {
ln, err := net.Listen("tcp", ":8080")
@udhos
udhos / prometheus_scrape_pod.md
Created September 30, 2021 21:37
prometheus_scrape_pod

Add annotations to pod:

metadata:
  annotations:
   prometheus.io/scrape: 'true'
   prometheus.io/path: '/data/metrics'
   prometheus.io/port: '80'
@udhos
udhos / ssm_ssh.md
Last active September 27, 2021 21:16
ssm ssh
@udhos
udhos / curl_cacert.md
Last active September 20, 2021 18:28
curl_cacert

get ca cert

openssl s_client -showcerts -servername servername -connect servername:443 > /tmp/cacert.pem

show

openssl x509 -in /tmp/cacert.pem -text

use ca cert