原创 Crawl GB2312 encoded webpages with Python 3.x

The following code works well. from urllib.request import urlopen import bs4 doc= urlopen("http://www.w3school.com.

原创 Hidden terminal and Exposed terminal

Exposed terminal [figure from https://en.wikipedia.org/wiki/Exposed_node_problem] S1 is transmitting packages to R1, S

原创 Using pip to install Python packages on Anaconda

Windows Platform: cd C:\Users\jack\AppData\Local\Continuum\Anaconda2\pythonw.exe C:\Users\yfeng14\AppData\Local\Continu

原创 [A Weird Bug] caused by the name of Python script

I attempt to run a Python LDA module after 'pip install lda'. But there al

原创 CSMA (carrier sense multiple access)

CSMA (carrier sense multiple access) is a probabilistic media access control protocol, which verifies the absence of tr

原创 Parallel Python for loop

An example on Windows: from joblib import Parallel, delayed import multiprocessing data = range(100) def process

原创 Python 3.5 deleting specified files recursively

Starting with Python 3.5, glob module supports the '**' directive, which matches any files and zero or more directories

原创 C++ 11 : create all possible k combinations of n items

#include <iostream> #include <algorithm> #include <vector> main () { int nn = 5; int r = 3; std::vector<int> v_rea

原创 MACAW (multiple access with collision avoidance fro Wireless)

Compared with MACA, the MACAW mainly optimizes the backoff algorithm and designs RTS-CTS-DS-DATA-ACK message exchange. 

原创 Tips for writing efficient Python code

Find the difference of keys between two dictionaries Suppose two dictionaries A and B. We would like to find the keys i

原创 Fill Countries in Python Basemap

I googled many Python methods to color countries in a world map. But most of them require additional Python packages, l

原创 MACA (Multiple Access with Collision Avoidance)

MACA (Multiple access with collision avoidance) is a slotted media access control protocol with collision avoidance for

原创 C++ 11 : call a function on every item of a vector

vector<int> nums = {1, 2, 3, 4}; std::for_each(nums.begin(), nums.end(), [](int &n) { n = -n; }); for (int element :

原创 Crawl AJAX dynamic web page using Python 2.x and 3.x

The term AJAX is short for Asynchronous Javascript and XML. It uses the Javascript XMLHttpRequest function to create a

原创 The Concept of Indistinguishability under Chosen Plaintext Attack (IND-CPA)

First, the concept of the Semantic Security means the knowledge of the ciphertext of unknown message does not reveal an