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
@khenidak
khenidak / ServiceFabricCompositeListener
Last active December 11, 2017 01:50
Composite Listener allows you to create multiple ICommunicationListener(s) per Service Fabric Replica (each can run its own communication stack)
/*
** this code is undergoing major updates (and fixes), please stay tuned.
for more details check: http://henidak.com/2015/10/azure-service-fabric-multiple-communication-listeners-per-service/
*/
public enum ICommunicationListenerStatus
{
Closed,
Opening,
Opened,
@khenidak
khenidak / Clicker.cs
Created October 10, 2015 02:51
Clicker is high performance lock-free in memory histogram (moving calculation) like implementation
// for more details please refer to: http://henidak.com/2015/10/on-train-rides-and-histograms/
/*
Typical Use
- Create a class (or use Click class) that sub-classes Click (if you need more than *.value)
- The implementation favors speed over memory (it will copy the tree everytime you do a calc using the Do method).
// this keeps the clicks for 1 min, then remove anything older
private Clicker<MyClickType> m_MinuteClicker = new Clicker>MyClickType>(TimeSpan.FromMinutes(1));
// this keeps the clicks for 1 hour, then remove anything older
@khenidak
khenidak / createAzureStorageSharedKey.js
Created January 7, 2016 18:02
Create Azure Storage REST API SharedKey
var crypto = require('crypto');
var algo = 'SHA256';
var hashencoding = 'base64';
// the below is not checked for casing
var arStandardHeaders = ['content-encoding', 'content-language', 'content-length', 'content-md5', 'content-type',
'date', 'If-Modified-Since', 'If-Match', 'If-None-Match', 'If-unmodified-Since', 'range'];
@khenidak
khenidak / nested-dev-env-azure.md
Created June 11, 2018 01:01
Create nested dev environment on Azure

Create a nested development envrionment on Azure VM. I use this for kernel specific sandboxes/dev. Admittedly, This is following my own quirky dev env. So apprach this with care.

What will you have:

  1. Separate virtual network for your sandbox
  2. QEMU (kvm enabled) vms running using this network
  3. Additional data disk aufs mounted for home directory (to move that disk to new vms if needed)

Steps

#!/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
# 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`
#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
@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
@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 / linux-kernel-5.0.0-on-azure.md
Last active March 9, 2022 00:38
Run kernel v 5.0.0 on Azure VM