Skip to content

Instantly share code, notes, and snippets.

@huiliu
huiliu / semtex.c
Created June 14, 2013 09:18 — forked from onemouth/semtex.c
/*
* linux 2.6.37-3.x.x x86_64, ~100 LOC
* gcc-4.6 -O2 semtex.c && ./a.out
* 2010 sd@fucksheep.org, salut!
*
* update may 2013:
* seems like centos 2.6.32 backported the perf bug, lol.
* jewgold to 115T6jzGrVMgQ2Nt1Wnua7Ch1EuL9WXT2g if you insist.
*/
@huiliu
huiliu / calculate_date.sh
Created July 4, 2013 15:34
求得今天前的N天的字符串,如:"20130704"
#!/bin/bash
# Use shell calculate the date interval before today
SECOND_TODAY=`date +%s`
SECOND_PER_DAY=86400
INTERVAL=7
SEQ=`seq $INTERVAL`
@huiliu
huiliu / elec.py
Last active December 23, 2015 19:29
厦大电费查询
#!/bin/env python
import datetime
import time
import sys
import urllib
import smtplib
from email.mime.text import MIMEText
mail_to_list=["YourEmailRecieveMessage"]
@huiliu
huiliu / parse.py
Last active August 29, 2015 14:08
将XML数据转换为SQL
# -*- coding: utf-8 -*-
from xml.etree import ElementTree as ET
from xml.dom import minidom as dom
import sys
import os
import time
def parse(filename):
"""
@huiliu
huiliu / parser
Created January 22, 2015 15:36
parser
#!/bin/env python
import re
import sys
from collections import OrderedDict
Enum_Value_Dict = {}
class Parse:
"""
@huiliu
huiliu / getnifs.py
Created October 15, 2015 06:39 — forked from provegard/getnifs.py
Python script for listing network interfaces with name, index and addresses
#!/usr/bin/python
# Based on getifaddrs.py from pydlnadms [http://code.google.com/p/pydlnadms/].
# Only tested on Linux!
from socket import AF_INET, AF_INET6, inet_ntop
from ctypes import (
Structure, Union, POINTER,
pointer, get_errno, cast,
c_ushort, c_byte, c_void_p, c_char_p, c_uint, c_int, c_uint16, c_uint32
@huiliu
huiliu / showif.c
Created October 21, 2015 07:47 — forked from OrangeTide/showif.c
example to list network interfaces on linux/bsd/osx/etc
/* showif.c : PUBLIC DOMAIN - Jon Mayo - August 22, 2006
* - You may remove any comments you wish, modify this code any way you wish,
* and distribute any way you wish.*/
/* finds all network interfaces and shows a little information about them.
* some operating systems list interfaces multiple times because of different
* flags, modes, etc. if you want to use this code you should be aware that
* duplicate interfaces is a possibility */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@huiliu
huiliu / get_if_macaddr.c
Created October 21, 2015 07:54
取得某个网络接口的MAC地址
/*
* Demonstrates retrieving hardware address of adapter using ioctl()
*
* Author: Ben Menking <bmenking@highstream.net>
*
* 此代码源自:
* http://stackoverflow.com/questions/1519585/how-to-get-mac-address-for-an-interface-in-linux-using-a-c-program
*
*
* 编译时会提示struct ifreq的大小不知道(当前已解决)。下面有相应的讨论
@huiliu
huiliu / app.py
Created December 8, 2015 17:12
Flask Streaming from Templates
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask, stream_with_context, request, Response, flash
from time import sleep
app = Flask(__name__)
def stream_template(template_name, **context):
@huiliu
huiliu / ping.py
Created December 30, 2015 18:03
解析nmap -sn 192.168.122.0/24 -oX ping.xml的结果
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from xml.etree import ElementTree as ET
xml_file = 'ping.xml'
def main():
host_info = list()
doc = ET.parse(xml_file)