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 / read-access.sql
Created January 13, 2025 14:30 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@tsunejui
tsunejui / monzo-alertmanager-config.yaml
Created November 19, 2024 09:28 — forked from milesbxf/monzo-alertmanager-config.yaml
Monzo's Alertmanager Slack templates
###################################################
##
## Alertmanager YAML configuration for routing.
##
## Will route alerts with a code_owner label to the slack-code-owners receiver
## configured above, but will continue processing them to send to both a
## central Slack channel (slack-monitoring) and PagerDuty receivers
## (pd-warning and pd-critical)
##
@tsunejui
tsunejui / nfs-provisioner-test.yaml
Created August 27, 2024 06:02 — forked from ryanhay/nfs-provisioner-test.yaml
PVC and Pod for testing an NFS Auto Provisioner Storage Class
# Apply this file
# Get a bash prompt in the container with: kubectl exec -it pod/ubuntu-test-nfs -- /bin/bash
# Navigate to /nfs directory
# Create some files and confirm everything is as expected on the NFS Server
#
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: test-nfs-provisioner
namespace: default
@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