Skip to content

Instantly share code, notes, and snippets.

View sunhay's full-sized avatar
😶
...

sunny klair sunhay

😶
...
View GitHub Profile
@sunhay
sunhay / kubectl.md
Created August 19, 2019 19:20 — forked from so0k/kubectl.md
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
@sunhay
sunhay / host_devices.go
Created August 15, 2018 19:17
Listing docker host devices
Taken from: https://github.com/opencontainers/runc/blob/master/libcontainer/devices/devices.go
```
$ go get -u github.com/opencontainers/runc
$ go get -u golang.org/x/sys/unix
```
@sunhay
sunhay / checkc.sh
Last active July 13, 2018 18:34
Checking c compiler (from musl configure)
#!/bin/sh
echo () { printf "%s\n" "$*" ; }
fail () { echo "$*" ; exit 1 ; }
fnmatch () { eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" ; }
cmdexists () { type "$1" >/dev/null 2>&1 ; }
trycc () { test -z "$CC" && cmdexists "$1" && CC=$1 ; }
printf "checking for C compiler... "
trycc ${CROSS_COMPILE}gcc
@sunhay
sunhay / readme.md
Last active July 2, 2018 00:29
Setting up linux headers for musl and golang

Setting up linux headers for musl and golang

Example

$ ./setup_linux_headers
$ CGO_CFLAGS="-I/kernel-headers/include" CC='/usr/local/musl/bin/musl-gcc' go build -a --ldflags '-linkmode external -extldflags "-static"' main.go
{
"args": [
"/usr/bin/lxcfs",
"/var/lib/lxcfs/"
],
"ppid": 1
}
{
"args": [
"/sbin/iscsid"
@sunhay
sunhay / tcp_monitor.c
Last active August 25, 2023 08:11
eBPF socket filter based tcptop
#include <uapi/linux/ptrace.h>
#include <uapi/linux/if_packet.h>
#include <net/sock.h>
#include <bcc/proto.h>
#define IP_TCP 6
#define ETH_HLEN 14
struct Key {
u32 src_ip; // source ip
@sunhay
sunhay / cbounce_results.md
Last active December 30, 2021 02:56
cache line bouncing in golang
MacBook Pro (13-inch, 2017)
Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
16 GB 2133 MHz LPDDR3
$ go test -bench=.
goos: darwin
goarch: amd64
@sunhay
sunhay / bitsbench_test.go
Last active January 12, 2018 03:22
Benchmarking dgryski/go-bits versus math/bits
package bitsbench
import (
dbits "github.com/dgryski/go-bits"
"math/bits"
"testing"
)
// Modelled after https://github.com/golang/go/blob/master/src/math/bits/bits_test.go