Skip to content

Instantly share code, notes, and snippets.

@time-river
time-river / one_zero_pack-2.cpp
Last active July 31, 2018 10:42
背包九讲之01背包,一维(滚动)数组解法
/*
* 背包九讲之01背包 滚动数组
* from: http://www.hawstein.com/posts/dp-knapsack.html
*/
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000
@time-river
time-river / one_zero_pack-1.cpp
Last active July 31, 2018 10:43
背包九讲之01背包,二维数组解法,打印选择的背包
/*
* 背包九讲之01背包 二维数组
* from: http://www.hawstein.com/posts/dp-knapsack.html
*/
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000
@time-river
time-river / ip-datagram.py
Last active June 6, 2018 18:52
like '[simple-tun-read-write.py](https://gist.github.com/time-river/f2288ae1dbe8bfa5cc84a841c9a507ad)', but automatic configure tun device and route table.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
description:
like 'simple-tun-read-write.py', but automatic configure tun device and route table.
catch all ip packet and print
'IP protocol version + IP header size'
'protocol of encapsulated packet'
'source IP'
@time-river
time-river / simple-tun-read-write.py
Last active June 6, 2018 18:51
a simple program which could print all package of content sended from local machine
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
a simple program which could print all package of content sended from local machine
prepare:
# ip tuntap add mode tun tun0
# ip link set tun0 up
# ip addr add 10.0.0.2/24 dev tun0
# ip route add default via 10.0.0.2 dev tun0 table 100