↓ Skip to main content
  1. Dev/

Snippets

·2 mins

Small fixes and commands that were each a post of their own once. They’re collected here so they’re easier to find.

Disable ping in Linux
#

echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all

Files empty in an HTML form?
#

Put enctype="multipart/form-data" in your form tag.

“Importing plotly failed. Interactive plots will not work.”
#

pip3 install --upgrade plotly

Find large directories on AIX
#

I usually run it from under a partition which is running out of space. It can take a while.

du -g | sort -n -r

Tell if a number is whole in PHP
#

if ($num == (int) $num) {
    // It's whole
} else {
    // It's not
}

sar (sysstat) for performance monitoring
#

Using sar, you can also collect all performance data on an on-going basis, store them, and do historical analysis to identify bottlenecks.

via 10 Useful Sar (Sysstat) Examples for UNIX / Linux Performance Monitoring.

How much can you get out of a $4 VPS?
#

I am a big fan of cheap VPSs. I start many personal projects, bring up a VPS, play around and then wipe it. Never have to worry about accidentally running up a bill in 100s or 1000s of dollars. I run this blog on a $4 server.

So this was interesting to read how far can a cheap VPS go.

Related

How to backup Kubernetes' Config

·1 min
The easiest solution seems to be the following script by Stack Overflow user, Timothy Perez : <pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-bash" data-lang="bash">#!/bin/bash # NAMESPACED EXPORTS for ns in $( kubectl get ns --no-headers | cut -d " " -f1 ) ; do kubectl --namespace = " ${ ns} " get -o = json bindings,cm,ep,ev,limits,pvc,po,podtemplates,rc,quota,secrets,sa,svc,controllerrevisions,ds,deploy,rs,sts,localsubjectaccessreviews,hpa,cj,jobs,leases,ev,ds,deploy,ing,netpol,rs,pods,netpol,pdb,roles,rolebindings | \ jq '.items[] | select(.type!="kubernetes.io/service-account-token") | del( .spec.clusterIP, .metadata.uid, .metadata.selfLink, .metadata.resourceVersion, .metadata.creationTimestamp, .metadata.generation, .status, .spec.template.spec.securityContext, .spec.template.spec.dnsPolicy, .spec.template.spec.terminationGracePeriodSeconds, .spec.template.spec.restartPolicy )' >> "./ ${ ns} .json" done # NON-NAMESPACED EXPORTS kubectl get -o = json cs,ns,no,pv,mutatingwebhookconfigurations,validatingwebhookconfigurations,crds,apiservices,tokenreviews,selfsubjectaccessreviews,selfsubjectrulesreviews,subjectaccessreviews,csr,psp,nodes,psp,clusterrolebindings,clusterroles,pc,sc,volumeattachments | \ jq '.items[] | select(.type!="kubernetes.io/service-account-token") | del( .spec.clusterIP, .metadata.uid, .metadata.selfLink, .metadata.resourceVersion, .metadata.creationTimestamp, .metadata.generation, .status, .spec.template.spec.securityContext, .spec.template.spec.dnsPolicy, .spec.template.spec.terminationGracePeriodSeconds, .spec.template.spec.restartPolicy )' >> "./cluster_non-namespaced_export.json" Script copied here under CC BY-SA 4.0 license

Kubernetes not passing full path to Nodejs

·1 min
I spent hours troubleshooting why the url path was getting stripped from requests in our Nodejs/Expressjs based app. The reason was this line in Kubernetes’ Ingress: nginx.ingress.kubernetes.io/rewrite-target : / Removing it fixed the issue. Check the Kubernetes documentation for more details.

Ask HN: Software Engineer hitting 40: what's next?

·1 min
Recent thread on Hacker News, https://news.ycombinator.com/item?id=29360119, was very interesting for me especially since I turned 40 this year. Programming is something I enjoy and am pretty good at it. I’m still not at the top of the salary range for programmers but this is a tough question. I can get into FAANG but there is still a ceiling of how much one can earn as a software engineer. This comment says it best: