Skip to content

Instantly share code, notes, and snippets.

@weshouman
weshouman / README.md
Last active August 23, 2020 06:42
AWK hints

Following are some hints

  • There are many flavors for awk, mawkminimal&default, gawkfeature-full & nawknew-implementation
  • For a technical comparison between mawk and gawk follow this google discussion
  • MAWK was slow, follow this guide. But the recent version 1.3.4 seems to fix that
  • AWKPATH is only available in gawk. nawk may have it too. But the default one mawk only uses the -f notation, it doesn't even havet the @inlcude statement, thus one can't nest the files, without creating a wrapper application, in a conf/lib like directory structure.
@weshouman
weshouman / README.md
Created April 2, 2020 04:51
memory hints

Hints for working with memory on linux

  • Set swappiness to zero guide
  • Utilize ps_mem to check for the real memory usage
  • Check for the caches by checking /proc/meminfo, for GB/MB view use this answer
  • Drop the caches if desired by using sudo sh -c "/bin/echo 3 > /proc/sys/vm/drop_caches" then resetting to 0, the guide is here, notice that sudo should wrap the whole redirection.
@weshouman
weshouman / README.md
Last active September 7, 2022 20:15
Automating Synology Disk Station

Following are the steps I followed to have further understanding

  1. Know the architecture from this link. Whether the API totally encapsulates the CGI or there are some differences, that is not the topic of this guide, so it's better to be always aware of the Disk Station Architecture your script would support, so that when we have to read the sources we'll know which source to check

  2. Try a working ansible role. That will give a pretty good overview of how the interaction is implemented.

  3. Check the official docs for the

@weshouman
weshouman / README.md
Last active August 19, 2021 15:22
Advanced Ansible hints

Naming

  • Use underscores
  • Do not use hyphens, based on the issues 1042 and 1123

History

  • Previously people used ansible-role-ROLE-NAME and Galaxy removed the ansible-role- part and kept ROLE-NAME
  • Later on galaxy stopped removing the prefix, and left the role maintainers do the heavy-lefting of setting the ROLE-NAME into meta/main.yml:role_name:
    However, there's a trick here, hyphens will be replaced with underscores, only the old roles could keep their hyphens x)
  • Then meta/main.yml:role_name: got deprecated, people got pretty angry as they are now stuck with ansible-role-ROLE-NAME naming, then over time they undeprecated the option
@weshouman
weshouman / README.md
Last active April 17, 2020 09:39
vim regex guide
  • Half the even numbered spaces :% s/\(\( \)\{\-2\}\)/\2/g by matching the the consecutive 4 spaces, source
    • origin: s/(( ){-2}/$2/g
  • Half the even numbered spaces :% s/\^\(\( \)\+\)\\1/\1/g by matching the whole spaces and halving them, source
    • origin: s/^(( )+)\1/$1/g
  • Encapsulate all the small caps strings into double quotes: :% s/\([a-z]\+\)/"\1"/g
    • origin: s /([a-z]+)/"$1"/g
  • Replace [:abc] with "abc": :% s/\[:\([a-z]\+\)\]/"\1"/g
    • origin: s /[:([a-z]+)]/$1/g or s /\[:([a-z]+)\]/$1/g I have to double check
  • Replace Model.enum[:abc].to_s with "abc": :% s/Model\.[a-z]\+\[:\([a-z]\+\)\]\.to_s/"\1"/g
  • origin: s /Model\.[a-z]+[:([a-z]+)]\.to_s/$1/g or s /Model\.[a-z]+\[:([a-z]+)\]\.to_s/$1/g I have to double check
@weshouman
weshouman / exploder.py
Last active September 21, 2023 21:51
Unentangling my yaml confusion
#!/usr/bin/python
# This script cleans up reference keys assuming they start with an underscore
import yaml
import argparse
def read_data(input_file):
# Read YAML file
with open(input_file, 'r') as f:
data = yaml.safe_load(f)
@weshouman
weshouman / bare-metal.md
Last active July 2, 2022 03:03
A guide to some issues working with cloud-init

Post-Setup Modification

I was looking forward to changing the user-data available on baremetal installation of user-data on an RPI, and following are the hits that I reached.

Note: I found multiple instances of the user-data and user-data.i, but I didn't reach yet which is the source as all the ones that I changed got reverted upon a restart.

rsyslog

The warning cc_rsyslog.py:205: FutureWarning: Possible nested set at position 23 is not severe, but it shows up, it could be circumvented using version 19.1

@weshouman
weshouman / kube-registry.yaml
Last active June 10, 2020 12:33 — forked from coco98/kube-registry.yaml
Docker registry on a cluster
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
spec:
replicas: 1
@weshouman
weshouman / README.md
Last active January 31, 2020 13:35
metrics-server deployment tips

Using Geerlingguy's K8s cluster and trying to install the metrics-server has some little snowflakes, following is how they got solved for me.

Steps

  • get the metrics server git clone https://github.com/kubernetes-sigs/metrics-server.git metrics-server
  • label the nodes according to the metrics-server node affinity to ensure it works, original labelling was in my case beta.kubernetes.io/arch=amd64
kubectl label node master kubernetes.io/arch=amd64
kubectl label node node1  kubernetes.io/arch=amd64
kubectl label node node2  kubernetes.io/arch=amd64
@weshouman
weshouman / 1-simple.mk
Last active August 28, 2024 13:59
Makefile function example
PATH = /tmp/
define myfn
processed_input=${PATH}/$(2)
$(1) := $$(processed_input)
endef
mytarget:
$(eval FILE=myfile)
$(eval $(call myfn,abs_filename,$(FILE)))