Skip to content

Instantly share code, notes, and snippets.

View huzhifeng's full-sized avatar

Zhifeng Hu huzhifeng

View GitHub Profile
#include <stdio.h>
#include <string.h>
extern void hexdump(FILE * stream, void const * data, unsigned int len)
{
unsigned int i;
unsigned int r,c;
if (!stream)
return;
@huzhifeng
huzhifeng / html2pdf.py
Created July 14, 2014 10:54
Convert html page to PDF file online and download
# -*- coding: utf-8 -*-
import json
import os
import requests
def pdfcrowd(url):
download_url = ''
pdfcrowd_post_url = 'http://pdfcrowd.com/form/json/convert/uri/'
headers = {
'Host': 'pdfcrowd.com',
@huzhifeng
huzhifeng / cscope.sh
Created August 2, 2014 18:35
Automatic cscope
#!/bin/sh
cs_install() {
echo "installing ..."
if [ ! -e cscope.files ]
then
find ./ -name "*.[hc]" > cscope.files
else
echo "cscope.files exist"
fi
@huzhifeng
huzhifeng / AutoReboot.ttl
Created October 13, 2014 02:26
A TTL(Tera Term Language) script used for automatic reboot test
; TTL Script used for automatic reboot test
username = 'root'
password = 'root'
usernamePrompt = 'login'
passwordPrompt = 'Password'
oopsPrompt = 'Oops'
panicPrompt = 'Kernel panic'
maxLoop = 1000
@huzhifeng
huzhifeng / http_sniffer.c
Last active August 29, 2015 14:07
A linux kernel module to snoop HTTP based on Netfilter
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/netfilter_ipv4.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("[email protected]>");
MODULE_DESCRIPTION("Netfilter HTTP sniffer module");
@huzhifeng
huzhifeng / crifan.py
Last active August 29, 2015 14:08
A python script used to download PDFs from http://www.crifan.com/files/doc/docbook/
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Usage:
pip install requests
pip install pyquery
pip install beautifulsoup4
pip install wget
python crifan.py
@huzhifeng
huzhifeng / coolshell.py
Last active August 29, 2015 14:08
A python script used to download all HTML articles on http://coolshell.cn and save as PDF files
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Usage:
pip install requests
pip install beautifulsoup4
python coolshell.py
'''
@huzhifeng
huzhifeng / huzhifeng.py
Last active August 29, 2015 14:08
A python script used to download all HTML articles on http://www.ruanyifeng.com/blog/ and save as PDF files
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# huzhifeng's Python Lib
import os
import re
import time
import json
import requests
@huzhifeng
huzhifeng / csdn_blog.py
Created November 2, 2014 11:52
A python script used to download CSDN blog as PDF files
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Usage:
pip install requests
pip install beautifulsoup4
python csdn_blog.py
'''
@huzhifeng
huzhifeng / getip.sh
Created January 9, 2015 08:08
Get IP address
huzhifeng@Ubuntu12:~$ hostname -i
127.0.1.1
huzhifeng@Ubuntu12:~$ hostname -I
192.168.2.132
huzhifeng@Ubuntu12:~$ ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1;}'
192.168.2.132
huzhifeng@Ubuntu12:~$ ifconfig eth0 2>/dev/null | awk '/inet addr:/ {print $2}' | sed 's/addr://'
192.168.2.132
huzhifeng@Ubuntu12:~$ ip route get 8.8.8.8 | awk 'NR==1 {print $NF}'
192.168.2.132