Skip to content

Instantly share code, notes, and snippets.

@sakateka
sakateka / get_pod_netns.sh
Created June 23, 2023 09:43 — forked from johscheuer/get_pod_netns.sh
This script get's the netns from a Kubernetes pod
#### WAY with crictl
#### TODO validate crictl with docker runtime !!
# Get all pods of a specific node
#kubectl get po --field-selector=spec.nodeName="fluffy-master" --all-namespaces
kubectl get --all-namespaces po --field-selector=spec.nodeName=="$(hostname)" -o json | jq -r '.items[] | select(.status.hostIP!=.status.podIP) | "\(.metadata.name) \(.metadata.namespace)"'
# Get the Pod ID of the Pod with crictl
POD_ID=$(sudo crictl pods --name=nginx-6f858d4d45-vnszm --namespace=default -q --no-trunc)
@sakateka
sakateka / build_kernel.sh
Created February 28, 2023 19:47 — forked from tdack/build_kernel.sh
Build the kernel for the Next Thing Co C.H.I.P.
#!/bin/bash
# Desktop build
MAKE="make -j 4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-"
# C.H.I.P. build
#MAKE="make"
CDIR=$PWD
LINUX=$CDIR/CHIP-linux
WIFI=$CDIR/RTL8723BS
@sakateka
sakateka / config
Created February 28, 2023 19:40 — forked from tdack/config
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm 4.4.11 Kernel Configuration
#
CONFIG_ARM=y
CONFIG_ARM_HAS_SG_CHAIN=y
CONFIG_NEED_SG_DMA_LENGTH=y
CONFIG_ARM_DMA_USE_IOMMU=y
CONFIG_ARM_DMA_IOMMU_ALIGNMENT=8
CONFIG_MIGHT_HAVE_PCI=y
var server = java.lang.management.ManagementFactory.getPlatformMBeanServer();
var mb = java.lang.management.ManagementFactory.newPlatformMXBeanProxy(
server,
"com.sun.management:type=HotSpotDiagnostic",
com.sun.management.HotSpotDiagnosticMXBean.class
);
mb.getDiagnosticOptions();
@sakateka
sakateka / result_2017.txt
Last active February 20, 2021 06:48
threaded malloc test
$ clang -g -Wall -O3 threaded_malloc.c -o threaded_malloc -pthread
$ # ptmalloc2
$ /usr/bin/time -v ./threaded_malloc
100,000,000 allocations in 2439ms (41000410/s)
100,000,000 deallocations in 13101ms (7633005/s)
100,000,000 allocations in 14536ms (6879471/s)
100,000,000 deallocations in 13306ms (7515406/s)
100,000,000 allocations in 14947ms (6690305/s)
100,000,000 deallocations in 2424ms (41254125/s)
Command being timed: "./threaded_malloc"
@sakateka
sakateka / result.txt
Last active October 14, 2017 08:27
Shuffle slice indices vs append
go test -bench=. -benchmem shuffle_test.go
goos: linux
goarch: amd64
BenchmarkIndex-4 100000000 12.5 ns/op 0 B/op 0 allocs/op
BenchmarkAppend-4 1000000 1423 ns/op 661 B/op 0 allocs/op
PASS
ok command-line-arguments 2.707s
coproc ZKLOCK {
zk-flock -w 10 -x 81 -c $ZK_FLOCK_CONFIG $LOCK_NAME "bash -c 'echo Locked; read'"
if (($? == 81)); then
echo "LockBusy"
else
echo "Failed"
fi
}
zk_stdin=${ZKLOCK[1]}
read -u ${ZKLOCK[0]} zk_reply 2>/dev/null
@sakateka
sakateka / lua.go
Last active November 24, 2016 20:38
lua plugin benchmark
package main
import (
"fmt"
"reflect"
"strconv"
luar "github.com/layeh/gopher-luar"
lua "github.com/yuin/gopher-lua"
)
@sakateka
sakateka / c.sh
Created January 8, 2016 02:21
Interactive C Shell
c(){
local go_libs="-lm" go_flags="-g -Wall -include allheads.h -O0"
local prompt="C > "
local first_line="int main(int argc, const char *argv[]){"
local end_line="}"
local code prev_code line
local HISTFILE="~/.c.hist"
#while read -erp "C > " line; do
@sakateka
sakateka / parallel_logs_rotate.sh
Last active October 26, 2015 06:43
parallel many logs rotate
#!/bin/bash
pigz_mv() { g="$1-$(date +%Y%m%d-%s).gz"; pigz -k "$1" && mv "$1".gz "$g" && truncate -s0 "$1"; }
plog_pigz_mv() {
local logs="$@" ts=$(date '+%Y%m%d-%s');
pigz -k $logs;
for l in $logs; do
mv ${l}.gz ${l}-${ts}.gz && truncate -s0 $l;
done