Skip to content

Instantly share code, notes, and snippets.

@afarid
afarid / nginx.conf
Created August 29, 2024 11:45
nginx-ssl-passthrough
stream {
server {
listen 443;
resolver 1.1.1.1;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass $ssl_preread_server_name:443;
ssl_preread on;
}
}
@afarid
afarid / collector1.yaml
Last active August 15, 2024 10:45
collector1
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
exporters:
loadbalancing:
@afarid
afarid / update.go
Last active October 2, 2022 13:36
update.go
var updateCmd = &cobra.Command{
....
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 1 {
todoName := args[0]
for index, todo := range todos.Todos {
if todo.Name == todoName {
// check if --descriptions is passed as flag or not
if cmd.Flags().Lookup("description").Changed {
description, _ := cmd.Flags().GetString("description")
var removeCmd = &cobra.Command{
....
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 1 {
todoName := args[0]
for i := 0; i < len(todos.Todos); i++ {
if todos.Todos[i].Name == todoName {
todos.Todos = append(todos.Todos[0:i], todos.Todos[i+1:]...)
break
}
@afarid
afarid / root.go
Last active October 2, 2022 12:53
root.go
type Todo struct {
Name string `mapstructure:"name"`
Description string `mapstructure:"description"`
Deadline string `mapstructure:"deadline"`
}
type Todos struct {
Todos []Todo `mapstructure:"todos"`
}
@afarid
afarid / gist:460ec51a3f74c654283c291db2875503
Created September 4, 2021 12:47
posgresql-admin-commands
## track index creation/re-indexing (available since version 12)
```
postgres=# select * from pg_stat_progress_create_index;
```
@afarid
afarid / docker-compose.yaml
Created March 14, 2021 19:45
hot-reload-docker-compose
version: "3"
services:
example-app:
build:
dockerfile: Dockerfile
context: ./
volumes:
- ./:/app
ports:
- 8080:8080
@afarid
afarid / .air.conf
Created March 14, 2021 19:42
Air conf
# Working directory
# . or absolute path, please note that the directories following must be under root.
root = "."
tmp_dir = "tmp"
[build]
# Just plain old shell command. You could use `make` as well.
cmd = "go build -o ./tmp/main ."
# Binary file yields from `cmd`.
bin = "tmp/main"
@afarid
afarid / Dockerfile
Created March 14, 2021 19:31
Air-dockerfile
FROM golang:latest
RUN go get -u github.com/cosmtrek/air
WORKDIR /app
ENTRYPOINT ["air"]
@afarid
afarid / main.go
Created March 14, 2021 19:29
simple go web server
package main
import (
"net/http"
)
func main() {
http.HandleFunc("/", func (w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, World"))
})