Skip to content

Instantly share code, notes, and snippets.

View tsunejui's full-sized avatar
👋
Your IT Solutions Partner

Rex Wu tsunejui

👋
Your IT Solutions Partner
View GitHub Profile
@tsunejui
tsunejui / pprof.md
Created June 11, 2024 00:04 — forked from slok/pprof.md
Go pprof cheat sheet

Enable profiling

Default http server

import (
    _ "net/http/pprof"
    "net/http"
)
@tsunejui
tsunejui / README.md
Created January 28, 2024 12:45 — forked from mosquito/README.md
Add doker-compose as a systemd unit

Docker compose as a systemd unit

Create file /etc/systemd/system/docker-compose@.service. SystemD calling binaries using an absolute path. In my case is prefixed by /usr/local/bin, you should use paths specific for your environment.

[Unit]
Description=%i service with docker compose
PartOf=docker.service
After=docker.service
@tsunejui
tsunejui / README.md
Created January 27, 2024 16:24 — forked from Integralist/README.md
[golang custom http client] #go #golang #http #client #timeouts #dns #resolver

Go Network Timeouts

NOTE: Guide to net/http timeouts

Although not explicitly stated, DNS resolution appears to be taken into consideration as part of the overall http.Client.Timeout setting. If you need to set your own DNS timeout, then it seems https://github.com/miekg/dns is a popular solution.

Additionally, it's important to realise how golang resolves hostnames to IPs (i.e. DNS resolution):
https://golang.org/pkg/net/#hdr-Name_Resolution

When cross-compiling binaries you'll find that CGO is typically disabled in favour of the native Go resolver. You can enforce CGO or native like so:

@tsunejui
tsunejui / generate-ios.sh
Created December 4, 2023 02:25 — forked from monmonja/generate-ios.sh
generate ios from command line
# download this file to your project folder and excute
# chmod +x generate-ios.sh
# then run using
# ./generate-ios.sh
# flutter build defaults to --release
flutter build ios
# make folder, add .app then zip it and rename it to .ipa
mkdir -p Payload
@tsunejui
tsunejui / scaledown.sh
Created November 7, 2023 14:28 — forked from waynedovey/scaledown.sh
Scale Down OpenShift Monitoring
oc patch clusterversion/version --type='merge' -p "$(cat <<- EOF
spec:
overrides:
- group: apps/v1
kind: Deployment
name: cluster-monitoring-operator
namespace: openshift-monitoring
unmanaged: true
EOF
)"
#!/bin/sh
#===================================================================================
#
# FILE: dump.sh
# USAGE: dump.sh [-i interface] [tcpdump-parameters]
# DESCRIPTION: tcpdump on any interface and add the prefix [Interace:xy] in front of the dump data.
# OPTIONS: same as tcpdump
# REQUIREMENTS: tcpdump, sed, ifconfig, kill, awk, grep, posix regex matching
# BUGS: ---
# FIXED: - In 1.0 The parameter -w would not work without -i parameter as multiple tcpdumps are started.
@tsunejui
tsunejui / containerd-certificate-ds.yaml
Created May 22, 2023 02:34 — forked from tomconte/containerd-certificate-ds.yaml
This is a Kubernetes DaemonSet definition that will install a custom certificate on the nodes and restart containerd. This is useful if your private registry is protected using a self-signed certificate. Not tested in production.
apiVersion: v1
kind: ConfigMap
metadata:
name: trusted-ca
namespace: kube-system
data:
ca.crt: |+
-----BEGIN CERTIFICATE-----
MIIFkTCCA3mgAwIBAgIUCXaMcLg8teiGZ7o0dIQRIOdHEA8wDQYJKoZIhvcNAQEL
BQAweDELMAkGA1UEBhMCRlIxDDAKBgNVBAgMA04vQTEMMAoGA1UEBwwDTi9BMSAw
@tsunejui
tsunejui / 01nginx-tls-sni.md
Created April 26, 2023 14:22 — forked from kekru/01nginx-tls-sni.md
nginx TLS SNI routing, based on subdomain pattern

Nginx TLS SNI routing, based on subdomain pattern

Nginx can be configured to route to a backend, based on the server's domain name, which is included in the SSL/TLS handshake (Server Name Indication, SNI).
This works for http upstream servers, but also for other protocols, that can be secured with TLS.

prerequisites

  • at least nginx 1.15.9 to use variables in ssl_certificate and ssl_certificate_key.
  • check nginx -V for the following:
    ...
    TLS SNI support enabled
@tsunejui
tsunejui / export-node-stats.md
Created March 21, 2023 03:12 — forked from ScriptingSquirrel/export-node-stats.md
Setup prometheus-node-exporter and push stats to Pushgateway with cron job

(Assuming a Debian 8-like system)

  • Install prometheus-node-exporter

    $ sudo apt update && sudo apt install prometheus-node-exporter
  • Configure prometheus-node-exporter to expose metrics only to localhost, not on to all networks. Modify file /etc/default/prometheus-node-exporter:

    # Set the command-line arguments to pass to the server.