Skip to content

Instantly share code, notes, and snippets.

@icpz
icpz / darwin-self-cpu-usage.c
Created Nov 27, 2019
get cpu usage in percent of current process on darwin
View darwin-self-cpu-usage.c
#include <mach/bootstrap.h>
#include <mach/mach_host.h>
#include <mach/mach_port.h>
#include <mach/task.h>
#include <mach/mach_vm.h>
#include <mach/thread_act.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
@icpz
icpz / darwin-SIOCAIFADDR_IN6.c
Created Nov 24, 2019
example of adding ipv6 address via ioctl(SIOCAIFADDR_IN6)
View darwin-SIOCAIFADDR_IN6.c
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <arpa/inet.h>
#include <netinet6/nd6.h>
#include <unistd.h>
@icpz
icpz / darwin-route.c
Last active Nov 28, 2019
manipulate routing table via route socket on darwin
View darwin-route.c
#include <sys/socket.h>
#include <sys/types.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <net/route.h>
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <unistd.h>
@icpz
icpz / v2ray-as-ss-over-v2plugin-server-config.json
Last active Nov 27, 2020
`shadowsocks over v2ray-plugin' as client work with `v2ray' as server
View v2ray-as-ss-over-v2plugin-server-config.json
{
"log": {
"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "info"
},
"inbounds": [
{
"port": "10000", /* this is the server port for client */
"listen": "127.0.0.1",