This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "stdafx.h" | |
| #include <iostream> | |
| #include <cassert> | |
| #include <memory> | |
| #include <tuple> | |
| typedef char* CharSPtr; | |
| class RingBuffer | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import socket | |
| import time | |
| import selectors | |
| kReadEvent = selectors.EVENT_READ | |
| kWriteEvent = selectors.EVENT_WRITE | |
| kNoneEvent = 0 | |
| class Poller: | |
| """ I/O 多路分发 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| import scrapy | |
| from scrapy.http import Request | |
| class ZhihuSpider(scrapy.Spider): | |
| name = 'zhihu' | |
| allowed_domains = ['www.zhihu.com'] | |
| start_urls = ['https://www.zhihu.com/topic/19619463/hot'] | |
| headers = { | |
| "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import scrapy | |
| class FootballTeamNormalItem(scrapy.Item): | |
| # define the fields for your item here like: | |
| # name = scrapy.Field() | |
| c_type = scrapy.Field() # 比赛类型 | |
| result = scrapy.Field() # 赛季战况(胜/负/平) | |
| jingqiu = scrapy.Field() # 总进球数 | |
| shiqiu = scrapy.Field() # 失球数 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| #include <string.h> | |
| #include <errno.h> | |
| #include <stdlib.h> | |
| #include <netdb.h> | |
| #include <unistd.h> | |
| #include <sys/epoll.h> | |
| #include <assert.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 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的大小不知道(当前已解决)。下面有相应的讨论 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |