Skip to content

Instantly share code, notes, and snippets.

View haani-niyaz's full-sized avatar

Haani Niyaz haani-niyaz

  • Melbourne, Australia
View GitHub Profile
@haani-niyaz
haani-niyaz / go-dev-guiding-principles.md
Last active February 10, 2022 07:02
Go application development guiding principles
View go-dev-guiding-principles.md

Go Dev Guiding Principles

An opinionated list of practices when developing in Go.

(1) Names

Names should be self revealing.

@haani-niyaz
haani-niyaz / clean_code.md
Created June 29, 2020 01:37 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin
View clean_code.md

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@haani-niyaz
haani-niyaz / go-journal.md
Last active May 11, 2023 21:32
Go notes
View go-journal.md

Go Journal

Developer Environment

Private Repo Setup

git config --global \
  url."https://${user}:${personal_access_token}@privategitlab.com".insteadOf \
  "https://privategitlab.com"
@haani-niyaz
haani-niyaz / python_decorator_guide.md
Last active November 3, 2019 05:31 — forked from Zearin/python_decorator_guide.md
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)
View python_decorator_guide.md

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@haani-niyaz
haani-niyaz / kubectl.md
Created January 3, 2019 22:36 — forked from so0k/kubectl.md
Playing with kubectl output
View kubectl.md

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
@haani-niyaz
haani-niyaz / haproxy-docker-nexus.md
Last active March 22, 2023 12:37
HAProxy config for nexus docker repo with no connector
View haproxy-docker-nexus.md

HAPROXY Docker Nexus (No HTTP Connector)

Background

  1. The docker-login repo is setup with minimal (read-only) access which allows all users to login. This creates the necessary credentials store required for all subsequent docker operations. The team docker repositories will be setup with RBAC to only allow access to members of that respective team to perform docker push/pull operations.

  2. The proxy will inspect the context path for the docker pull/push operations and proceed only if authorization is successful.

@haani-niyaz
haani-niyaz / 14-aws.sh
Last active May 24, 2020 09:07 — forked from vfarcic/14-aws.sh
kubernetes training
View 14-aws.sh
cd k8s-specs
git pull
export AWS_ACCESS_KEY_ID=[...]
export AWS_SECRET_ACCESS_KEY=[...]
aws --version
@haani-niyaz
haani-niyaz / haproxy_resolvers.cfg
Created May 9, 2018 00:53
How to use DNS name backends in haproxy
View haproxy_resolvers.cfg
global
log 127.0.0.1 local2
pidfile /var/run/haproxy.pid
user haproxy
group haproxy
maxconn 1000
defaults
log global
mode http
View 8.2.3. HTTP log format
8.2.3. HTTP log format
----------------------
The HTTP format is the most complete and the best suited for HTTP proxies. It
is enabled by when "option httplog" is specified in the frontend. It provides
the same level of information as the TCP format with additional features which
are specific to the HTTP protocol. Just like the TCP format, the log is usually
emitted at the end of the session, unless "option logasap" is specified, which
generally only makes sense for download sites. A session which matches the
"monitor" rules will never logged. It is also possible not to log sessions for
@haani-niyaz
haani-niyaz / kube-snippets.md
Last active March 26, 2018 00:39
Random kubernetes code snippets
View kube-snippets.md

How to use hostPath pv with a volumeClaimTemplate in StatefulSets

hostPath PV

---
kind: PersistentVolume
apiVersion: v1
metadata: