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 / gist:a708820a8fac470b1d59ccbcfd56c43d
Created February 17, 2022 02:12 — forked from Rafe/gist:3102414
AWK cheatsheet
HANDY ONE-LINE SCRIPTS FOR AWK 30 April 2008
Compiled by Eric Pement - eric [at] pement.org version 0.27
Latest version of this file (in English) is usually at:
http://www.pement.org/awk/awk1line.txt
This file will also be available in other languages:
Chinese - http://ximix.org/translation/awk1line_zh-CN.txt
USAGE:
@udhos
udhos / dynamodb partiql.md
Last active December 3, 2021 17:50
dynamodb partiql

Console:

SELECT * FROM "cb-events"."eventType-index"
	WHERE "eventType" = 'phone-updated'
    AND eventDate >= '2021-10-01'
    AND eventDate <= '2021-10-02'

CLI:

@udhos
udhos / service account permissions.md
Created November 22, 2021 21:50
service account permissions
@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")