All interesting links and reflections throughout time goes here.
Postgres UUID
create extension "uuid-ossp";
select uuid_generate_v4();
Postgres UPDATE FROM SELECT
UPDATE
Table_A
SET
Table_A.col1 = Table_B.col1
FROM
Some_Table AS Table_A
WHERE
Table_A.col3 = 'cool'
Create new table from existing
alter table tablename rename to oldtable;
create table tablename (column defs go here);
insert into tablename (col1, col2, col3) select col2, col1, col3 from oldtable;
alter table tablename OWNER TO someownerifneeded;
Replace text on file using sed
sed -i '' 's/old/new/g' /path/to/file.txt
Git replace master with our branch
git checkout seotweaks
git merge -s ours master
git checkout master
git merge seotweaks
Git update submodules
git submodule foreach git pull origin master
Git update fork
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
git pull upstream master
Git copy code from VSTS to GitHub (or others)
git clone --mirror <url_of_old_repo>
cd <name_of_old_repo>
git remote add new-origin <url_of_new_repo>
git push new-origin --mirror
git remote rm new-origin
Kubernetes delete evicted pods
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
Flux Sync
alias ff='fluxctl sync --k8s-fwd-ns flux'
Flux Helm Sync
kb exec -n flux helm-operator-5f85794486-xq59m -- curl -XPOST http://localhost:3030/api/v1/sync-git
Go dependencies graph
godepgraph -nostdlib -horizontal -onlyprefixes=github.com/repo/svc github.com/repo/svc/cmd/server | dot -Tpng -o godepgraphz.png
General
C#
- Use
class
for identity and behaviour (DDD). - Use
struct
for value objects without behaviour (such as Money). - The
record
keyword addsIEquatable
andToString
comparators. - A
record class
is inmmutable, you can create copies with thewith
keyword. - A
record struct
is mutable unless you add thereadonly
keyword.
Golang
- Slice of pointers
- Iterating over slices
- Slices and internals
- Collections of unknown length
- Slice append
- Altered slices by value
- Cap vs len
- Communicating Sequential Processing
- Sleep sort
- Guide to timeouts
- Context package
- Context cancellation
- Postgres in Go, prepared statements
Postgres
- Fetch first with ties
- Pgbouncer diagnostic info
- Prometheus exporter for Pgbouncer
- Pgbouncer and prepared statements
- Pgbouncer, Golang and prepared statements
Github Pages
Kubernetes
- Pod disruption budget
- PVC created by statefulset not removed by design
- Understanding CPU and Memory with Vertical Pod Autoscaler
- Megabyte vs mebibyte
- Rightsize Your Pods with Vertical Pod Autoscaling
- Restart-Free Vertical Scaling for Kubernetes Pods
- Kubernetes best practices: Resource requests and limits
- Horizontal Pod Autoscaler Walkthrough
Kubernetes Summary
- Health check: Restarts pod if it does not work, so just check the internal dependencies, that can be solved with a restart, are up.
- Ready check: Stop routing traffic if it does not work, check external dependencies, now beware you can actually give cause latency issues or denial of service to yourself, be conservative.
- Cluster autoscaling: Feature of GKE, add more nodes workers to certain node pool.
- Horizontal scale: Upon certain metric (could be custom or could be cpu/mem) reaches a % another replica could be spawned.
- Vertical scale:
- Has 2 modes, recommendation and update. Possibility of excluding certain container of a pod.
- On recommendation it tells you how much mem/cpu you need to assign as resource.
- On auto it kills the pod and spawns a new one with new resource.
- Does not work on auto when only 1 replica.
- Pdb is recommended so you don't have downtime.
- Goldilocks:
- Tool that exposes dashboard and fires vpa for every container on namespace.
- Dashboard allows you to port forward and check the recommended limits, so you change yourself.
- Resources:
- Requests: The minimum the scheduler needs to allocate for running this container.
- Limits: Pod can reach up to this amount, in an overcommited state (likely to be killed).
- cpu: 50m is expressed in millicores, 1000 is 1 cpu, 250 1/4 cpu. In case of overcommitted it will get throttled.
- memory: Expressed in Mi as memybytes. In case of overcommitted it will get killed.
Istio
- Cronjobs not ending because of Istio proxy
- Istio ports 31400 and 15443
- Istio on GKE private cluster, create firewall rule
- Injection diagnosis
- Migration init container running before proxy
BankID
- Test certificate for BankID
- Unofficial bankID lib
- BankID docs
- Formatted text for visible data
- Get test BankID on mobile and PC
- Issue a test bank ID with your real one
Signicat