Skip to content

Instantly share code, notes, and snippets.

View khenidak's full-sized avatar
💭
"If we're going to be damned, let's be damned for what we really are."

Khaled Henidak (Kal) khenidak

💭
"If we're going to be damned, let's be damned for what we really are."
View GitHub Profile
// src https://www.cs.cmu.edu/afs/cs/academic/class/15213-f99/www/class26/tcpserver.c
// modified to show the impact of bind(2) v listen(2) on tcp connection as visible by netstat -atp
/*
* tcpserver.c - A simple TCP echo server
* usage: tcpserver <port>
*/
#include <stdio.h>
git log --pretty=format:"%h" <base branch>..<target branch> | xargs -I {} git diff-tree -v --name-status -r {}
@khenidak
khenidak / PriorityQueue.cs
Created September 30, 2019 19:34
thread safe C# priority queue
/*
we depend on the discipline List<T> have (or not) arround allocating arrays
if you are dealing with known length then modify to have a cap parameter and pre allocate your List<T>
*/
using System;
using System.Threading;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
@khenidak
khenidak / linux-kernel-5.0.0-on-azure.md
Last active March 9, 2022 00:38
Run kernel v 5.0.0 on Azure VM
@khenidak
khenidak / Network.xml
Last active October 15, 2018 02:20
kernel dev network (virsh based). and sample qemu vm on it
<network>
<name>kernel-net</name>
<uuid>5618453a-d6af-42f5-b77d-eb1727371b73</uuid>
<forward mode='nat'>
<nat>
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='kerneldevbr0' stp='on' delay='0'/>
<mac address='42:ef:c9:0b:a4:f1'/>
@khenidak
khenidak / ensure_tooling.sh
Created October 14, 2018 20:09
Handy for preping whatever tools your script needs.
# on a debian system
# expects $1 as "<binary>:<package> <binary>:<package>"
# example "qemu-img:qemu-utils nslookup:dnsutils"
# if you are not sure which package has your binary
# use apt-file search <binary name>
# we don't handle error here. so make sure you are
# using the correct binary and package names in design time
ensure_tooling(){
local req_tools=($1)
for tool in "${req_tools[@]}"; do
#Sources:
# https://stackoverflow.com/a/28938235
# Reset
Color_Off='\033[0m' # Text Reset
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
# simple linux tracepoint parser that converts
# /sys/kernel/debug/tracing/events/<sub sys>/<tracepoint>/format
# into a meaningful json object for further processing.
# each event is has subsystem, id, fields, fmt (original fmt in format file)
# each field has name, size, is_array, array_size, is_pointer
# stderr has max tracepoint record size, subsystem, name
# run with `python linux_tracepoint_parser.py | jq`
#!/bin/bash
# What is this: it creates vxlan across two hosts
# does this need multicast on hosts: no, we are using the no learning approach
# How: we are using static popluation of fdb and arp database. (we don't use l2miss or l3miss - maybe we try it on a different script)
# What do i need:
# two VMs running everywhere, as long as you can do udp between them.
# modify host1/2 for host ips (your VMs)
# modify ip1/ip2 and vip1/vip2 for your configuration.
# the script connect to VMs via ssh. so make sure you have the keys handy
# what can i use it for: VMs/Containers/funky networking. get creative