Skip to content

Instantly share code, notes, and snippets.

View zhangjiaxing's full-sized avatar
🙄

zhiliao zhangjiaxing

🙄
  • Beijing
  • 12:23 (UTC +08:00)
View GitHub Profile
@zhangjiaxing
zhangjiaxing / color-echo.sh
Last active September 17, 2021 07:01
bash color_echo
#!/usr/bin/env bash
# Depends: ncurses-utils
# man tput(1) terminfo(5)
_BLACK=0
_RED=1
_GREEN=2
_YELLOW=3
_BLUE=4
_MAGENTA=5
@zhangjiaxing
zhangjiaxing / c autoprt
Created September 16, 2021 19:30
c autoprt
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined (__GNUC__) || defined (__clang__)
#define G_GNUC_UNUSED \
__attribute__((__unused__))
#define _AUTOPTR_TYPENAME(TypeName) TypeName##_autoptr
@zhangjiaxing
zhangjiaxing / gist:763397bf9f794598305548934120aa8e
Last active September 16, 2021 19:31
python3 /proc/net/route
import os
import socket
import struct
RTF_UP = 0x0001
RTF_GATEWAY = 0x0002
RTF_HOST = 0x0004
def format_rt_field(key, value):
@zhangjiaxing
zhangjiaxing / gist:3df093530ba7b64f414f7de957c7ceec
Created July 24, 2020 08:06
Netlink 检测网线热插拔事件
#include <sys/types.h>
#include <sys/socket.h>
#include <asm/types.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <linux/if.h>