我们需要做一次测试,由A向B发送HTTP请求,要求这些请求的IP地址是不同的,A会检查HTTP响应以判断是否正确。 问题是逐步明确的。
最初的测试只是要求一个IP发送,很简单,我写了一个Python的脚本,使用urllib库完成了所有的事情。能够值得 一提的是,urllib自己处理了302的跳转,这个出乎我的预料,这个还需要读文档。
但是一到多个IP地址的时候,问题就不那么容易了。
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
; | |
(define (atom? x) | |
(and (not (pair? x)) (not (null? x)))) | |
; consist of atoms | |
(define (lat? l) | |
(cond | |
((null? l) #f) | |
((atom? (car l)) (lat? (cdr l))) | |
(else #f))) |
int foo(void) { | |
using namespace std; | |
std::vector<int> vi(10); | |
std::vector<int>::iterator iter; | |
for_each(vi.begin(), vi.end(), [](int &val){ val = rand() % 100; }); | |
for_each(vi.begin(), vi.end(), [](int val) { std::cout << val << ", "; }); | |
cout << endl; | |
do { | |
iter = max_element(vi.begin(), vi.end()); |
// compile by: g++ hello.cxx -shared -fPIC -o hello.so -I/usr/include/python2.7 -lboost_python | |
#include <string> | |
#include <boost/python.hpp> | |
using std::string; | |
using namespace boost::python; | |
string hello() { return "Hello, world!"; } | |
// add a argument |
from distutils.core import setup | |
import py2exe | |
setup( | |
options = {"py2exe": {"bundle_files": 1, "includes": "numpy"}}, | |
console=["readCamera.py"], | |
zipfile = None, | |
) |
#! /usr/bin/env python | |
import cv2 | |
if __name__ == "__main__": | |
''' ''' | |
camera = cv2.VideoCapture(0) | |
while True: | |
# cv2.VideoCapture return a tuple, (Bool, Numpy.ndarray) | |
_, im = camera.read() |
require "open-uri" | |
require "net/http" | |
Net::HTTP.version_1_2 | |
uri = URI.parse("http://192.168.1.1") | |
http = Net::HTTP.new(uri.host, uri.port) | |
while true |
-- from Real World Haskell, Chapter 9 | |
module RecursiveContents (getRecursiveContents) where | |
import Control.Monad (forM) | |
import System.Directory (doesDirectoryExist, getDirectoryContents, getCurrentDirectory) | |
import System.FilePath ((</>)) | |
getRecursiveContents :: FilePath -> IO [FilePath] | |
getRecursiveContents topdir = do |
module Main where | |
import Control.Monad.State | |
type IntState = State Int | |
inc :: IntState () | |
-- inc = get >>= put . (+1) | |
inc = do | |
v <- get |