Skip to content

Instantly share code, notes, and snippets.

View xh4n3's full-sized avatar
🎯
Focusing

Shane Xie xh4n3

🎯
Focusing
  • Alibaba Cloud
  • Hangzhou, China
  • X @xh4n3
View GitHub Profile
@DavadDi
DavadDi / traceicmpsoftirq.py
Created November 27, 2020 02:02 — forked from theojulienne/traceicmpsoftirq.py
ICMP packet tracer using BCC
#!/usr/bin/python
bpf_text = """
#include <linux/ptrace.h>
#include <linux/sched.h> /* For TASK_COMM_LEN */
#include <linux/icmp.h>
#include <linux/netdevice.h>
struct probe_icmp_data_t
{
@cmpark0126
cmpark0126 / llvm-ir-gen.sh
Last active July 6, 2024 12:37
How to Generate LLVM IR from C Source Code?
#!/bin/bash
name=${1%.*c} # detatch .c from c file name
clang-9 -O0 -Xclang -disable-O0-optnone -fno-discard-value-names -emit-llvm -c $name.c # convert source code(.c) to bit code(.bc)
llvm-dis-9 $name.bc -o $name.ll # generate llvm ir(.ll) from bit code(.bc) obtained above without any optimization
opt-9 -mem2reg $name.bc -o $name.mem2reg.bc # optimize bit code using `mem2reg` optimization pass before generating llvm ir
llvm-dis-9 $name.mem2reg.bc -o $name.mem2reg.ll # generate llvm ir(.ll) from optimized bit code(.bc)
@chendotjs
chendotjs / skbtracer.c
Last active March 31, 2025 05:13
ebpf-skbtracer
#include <bcc/proto.h>
#include <uapi/linux/ip.h>
#include <uapi/linux/ipv6.h>
#include <uapi/linux/icmp.h>
#include <uapi/linux/tcp.h>
#include <uapi/linux/udp.h>
#include <uapi/linux/icmpv6.h>
#include <net/inet_sock.h>
#include <linux/netfilter/x_tables.h>
@DzeryCZ
DzeryCZ / ReadingHelmResources.md
Last active April 7, 2025 07:06
Decoding Helm3 resources in secrets

Helm 3 is storing description of it's releases in secrets. You can simply find them via

$ kubectl get secrets
NAME                                                TYPE                                  DATA   AGE
sh.helm.release.v1.wordpress.v1                     helm.sh/release.v1                    1      1h

If you want to get more info about the secret, you can try to describe the secret

$ kubectl describe secret sh.helm.release.v1.wordpress.v1
@miguelmota
miguelmota / uint8_to_hex.cpp
Last active February 26, 2025 03:31
C++ uint8_t to hex string
#include <sstream>
#include <iostream>
#include <iomanip>
std::string uint8_to_hex_string(const uint8_t *v, const size_t s) {
std::stringstream ss;
ss << std::hex << std::setfill('0');
for (int i = 0; i < s; i++) {
#!/bin/bash
# Script to determine what named images and containers are dependent on the specified image (or a containers image) from stdin or in the args
# An unmatchable input is ignored
# All of the following will be found:
# Any image name / tag / name:tag / id that has a prefix in it that matches the input
# Any other image that relies on the images specified
# Any containers (running or not) that use any of these images
set -euf -o pipefail
@lizrice
lizrice / main.go
Created August 25, 2016 10:02
Container from scratch
package main
// @lizrice, mostly copied from @doctor_julz: https://gist.github.com/julz/c0017fa7a40de0543001
import (
"fmt"
"os"
"os/exec"
"syscall"
)
@arfon
arfon / big_query_examples.md
Last active September 19, 2022 13:00
BigQuery Examples for blog post

How many times shouldn't it happen...

-- https://news.ycombinator.com/item?id=11396045

SELECT count(*)
FROM (SELECT id, repo_name, path
        FROM [bigquery-public-data:github_repos.sample_files]
 ) AS F
@christiangenco
christiangenco / download_egghead_videos.md
Last active January 29, 2024 03:16 — forked from ldong/download_egghead_videos.md
download egghead videos
@e7d
e7d / sample.sh
Last active May 11, 2024 13:46
Bash "try catch"
#!/bin/bash
export AnException=100
export AnotherException=101
# start with a try
try
( # open a subshell !!!
echo "do something"
[ someErrorCondition ] && throw $AnException