Skip to content

Instantly share code, notes, and snippets.

{
"name": "Debian",
"image": "mcr.microsoft.com/devcontainers/base:bookworm",
"features": {
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {
"version": "latest",
"helm": "latest",
"minikube": "none"
},
"ghcr.io/devcontainers/features/terraform:1": {
@tlhakhan
tlhakhan / zerocounter.py
Created May 23, 2024 00:15
Python zero counter
import sys
def find_largest_zero_sequence(filename):
max_zeros = 0
current_zeros = 0
with open(filename, 'rb') as file:
while True:
byte = file.read(1)
if not byte: # End of file
break
@tlhakhan
tlhakhan / macos-vmware-fusion-custom-networking.md
Created April 8, 2024 16:07
MacOS: Configuring VMware Fusion's networking

README

  • For VMware Fusion on MacOS
  • Add custom domain names and DNS servers in dhcpd.conf

/Library/Preferences/VMware\ Fusion/networking

  • Edit this networking file for custom DHCP subnet for the NAT network.
  • After updating, run the vmnet-cli commands to refresh the dhcpd.conf file.
  • VMNET_1 is for the Host-only network config.
  • VMNET_8 is for the NAT network config.
@tlhakhan
tlhakhan / task.go
Created November 15, 2021 15:00
task.go
package task
import (
"context"
"encoding/json"
"fmt"
"github.com/gorilla/mux"
"log"
"net/http"
"os/exec"
Every 1.0s: cat /proc/spl/kstat/zfs/arcstats | grep evictable | grep -E '^mru|^mfu' batfs0557: Mon Jul 26 10:57:53 2021
mru_evictable_data 4 0
mru_evictable_metadata 4 4096
mru_ghost_evictable_data 4 0
mru_ghost_evictable_metadata 4 0
mfu_evictable_data 4 0
mfu_evictable_metadata 4 0
mfu_ghost_evictable_data 4 0
mfu_ghost_evictable_metadata 4 0
@tlhakhan
tlhakhan / gist:95e4d46c2ea4318f8fbde47388aeb969
Created July 26, 2021 14:56
arcstats during overflow and arc_prune tasks working (zfs_prune)
time read miss miss% dmis dm% pmis pm% mmis mm% arcsz c
08:45:22 13 0 0 0 0 0 0 0 0 64G 64G
08:45:23 1.8K 3 0 1 0 2 66 3 0 64G 64G
08:45:24 469K 2.0K 0 629 0 1.4K 11 2.0K 0 64G 64G
08:45:25 777K 3.9K 0 1.4K 0 2.5K 15 3.9K 0 64G 64G
08:45:26 819K 3.6K 0 1.4K 0 2.2K 15 3.6K 0 64G 64G
08:45:27 235K 1.2K 0 441 0 760 17 1.2K 0 64G 64G
08:45:28 253K 1.3K 0 529 0 736 24 1.3K 0 64G 64G
08:45:29 510K 2.6K 0 897 0 1.7K 17 2.6K 0 64G 64G
08:45:30 37K 118 0 59 0 59 25 118 0 64G 64G
root@batfs0557:~# cat super_cache_scan.bt
#!/bin/env /usr/bin/bpftrace
#include <linux/types.h>
#include <asm-generic/atomic-long.h>
#include <linux/shrinker.h>
kprobe:super_cache_scan {
$sc = (struct shrink_control *) arg1;
@nr_to_scan[$sc->nid, comm, probe] = hist($sc->nr_to_scan);
}
@tlhakhan
tlhakhan / local.sh
Created June 8, 2021 23:05
Append to the /etc/rc.local.d/local.sh script to wait for vusb#s to initialize and then refresh the ESXi host networking to properly register uplinks to vSwitches.
#
# Description: Wait for 3 vusb interfaces to intialize and then refresh the ESXi host network settings.
# Original reference: https://flings.vmware.com/usb-network-native-driver-for-esxi#instructions
#
# Get status of 3 vusb interfaces to be "Up Up Up", see the use of 3 in head -n3 and xargs -n3.
vusb_status=$(esxcli network nic list | grep vusb | awk '{print $5}' | sort | head -n3 | xargs -n3)
# Loop until all 3 vusb interfaces are Up
# Waits a maximum of 20 * 10 seconds before falling through.
@tlhakhan
tlhakhan / transform_vusb.sh
Created June 8, 2021 22:56
Persist vusb to mac address mapping
[root@vs-1:~] esxcli network nic list
Name PCI Device Driver Admin Status Link Status Speed Duplex MAC Address MTU Description
------ ------------ ------ ------------ ----------- ----- ------ ----------------- ---- ------------------------------------------------
vmnic0 0000:00:1f.6 ne1000 Up Up 1000 Full 94:c6:91:a5:40:79 1500 Intel Corporation Ethernet Connection (6) I219-V
vusb0 Pseudo uether Up Up 1000 Full 00:50:b6:1b:f2:79 1500 ASIX Elec. Corp. AX88179
vusb1 Pseudo uether Up Up 1000 Full 00:50:b6:ea:b8:42 1500 ASIX Elec. Corp. AX88179
vusb2 Pseudo uether Up Up 1000 Full 00:50:b6:1e:dc:72 1500 ASIX Elec. Corp. AX88179
[root@vs-1:~] esxcli network nic list | grep vusb | awk '{print $1"_mac="$8}'
vusb0_mac=00:50:b6:1b:f2:79
@tlhakhan
tlhakhan / keepalived.conf
Created April 15, 2021 18:34
keepalived example
global_defs {
enable_script_security
}
vrrp_script check_script {
script "/usr/bin/systemctl is-active {{ .ServiceName }}.service"
weight 10
interval 3
fall 1
rise 3