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 / main.go
Created January 13, 2024 02:35 — forked from fl64/main.go
golang prometheus exporter example
package main
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"log"
"math/rand"
"net/http"
"time"
@udhos
udhos / grace.go
Created October 28, 2023 21:22 — forked from silkeh/grace.go
Golang graceful restart with TCP connections
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"log"
"net"
"os"
"os/signal"
@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 / 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 / assume_role.py
Created August 3, 2020 17:26 — forked from DaisukeMiyamoto/assume_role.py
AWS Boto3 Assume Role example
import boto3
from boto3.session import Session
def assume_role(arn, session_name):
"""aws sts assume-role --role-arn arn:aws:iam::00000000000000:role/example-role --role-session-name example-role"""
client = boto3.client('sts')
account_id = client.get_caller_identity()["Account"]
print(account_id)
@udhos
udhos / 01_get_account_id_for_user_ec2instance_role_or_lambda.py
Created April 2, 2020 13:04 — forked from gene1wood/01_get_account_id_for_user_ec2instance_role_or_lambda.py
Method to determine your AWS account ID using boto3 for either a user or an ec2 instance or lambda function
import boto3
print(boto3.client('sts').get_caller_identity()['Account'])
@udhos
udhos / http_get.go
Created March 18, 2020 01:37 — forked from hidva/http_get.go
golang wget
package main
import (
"context"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"time"
@udhos
udhos / keyping.go
Created January 16, 2020 22:18 — forked from zmanian/keyping.go
Key Pinning in #Golang
package main
import (
"bytes"
"crypto/sha256"
"crypto/tls"
"crypto/x509"
"log"
"net"
"net/http"
@udhos
udhos / main.go
Last active November 28, 2019 04:56 — forked from julz/main.go
containersched minicontainer
//
// https://www.youtube.com/watch?v=HPuvDm8IC-4
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
@udhos
udhos / .txt
Last active October 22, 2019 13:26 — forked from prudhvigodithi/.txt
Kubectl cheat sheet.
see also: https://kubernetes.io/docs/reference/kubectl/cheatsheet/
kubectl run nginx image=nginx  --port=80  --record
kubectl set image deployment nginx nginx=nginx:1.2
kubectl rollout history deployment nginx
kubectl rollout status deployment nginx
kubectl rollout undo deployment nginx  --to-revision=2
kubectl autoscale deployment nginx  --cpu-percent=50  -- min=1  -- max 2
kubectl run nginx3  --image=nginx  --requests=cpu=200m  --limits=cpu=300m  --requests=memory=1Gi  --limits=memory=2Gi
kubectl run hello  --schedule=”*/1 * * * *”  --restart=OnFailure  -- image=busybox  -- /bin/sh -c “date; echo Hello from the kubernetes cluster”