Skip to content

Instantly share code, notes, and snippets.

View StoneMoe's full-sized avatar

Lake Chan StoneMoe

View GitHub Profile
@StoneMoe
StoneMoe / traceicmpsoftirq.py
Created December 19, 2019 11:07 — forked from iAklis/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
{
u64 timestamp_ns;
u32 tgid;
@StoneMoe
StoneMoe / migrate.sh
Last active July 14, 2020 09:53
volume to volume
# make tarball from sentry_pgdb volume
docker run --rm -v sentry_pgdb:/var/lib/postgresql/data -v (pwd):/backup busybox tar cvf /backup/backup.tar /var/lib/postgresql/data
# create a sentry-postgres volum
docker volume create sentry-postgres
# restore to sentry-postgres volume
# NOTE: tarball will keep absolute path folder structure, so we don't need specify the target extract path
docker run --rm -v sentry-postgres:/var/lib/postgresql/data -v (pwd):/backup busybox tar xvf /backup/backup.tar
#!/bin/bash
# Source https://stackoverflow.com/questions/36651091/how-to-install-packages-in-linux-centos-without-root-user-with-automatic-depen
pkgname=$1
if [ -z $pkgname ]; then
echo "Usage: ./non-root-yum-install.sh pkgname-here"
exit 1
fi
rand=$(openssl rand -base64 6)
@StoneMoe
StoneMoe / unicorn.py
Created January 30, 2021 15:47
Simple preforking echo server in Python
"""
Simple preforking echo server in Python.
Python port of http://tomayko.com/writings/unicorn-is-unix.
"""
import os
import sys
import socket
@StoneMoe
StoneMoe / tun2socks_cli.sh
Last active December 6, 2022 09:18
setup tun2socks with script
#!/bin/bash
if [ $UID -ne 0 ]; then
echo Please run as root.
exit 1
fi
GW=$(ip route | grep default | awk '{print $3}')
IF=$(ip route | grep default | awk '{print $5}')
TUN=192.18.0.1
echo Detected Network: $GW $IF