0%

Binary Search Conclusion

Mr. Knuth, who invents KMP algorithm, once has said that the idea of binary search is straight forward, but devil in the details.

Read more »

IP command

Cent OS/RHEL 5 or 6 = ifconfig

CentOS/RHEL 7 = ip

CentPS/RHEL 7.5 and up = ifconfig command has been deprecated, you should type: ip addr

To use ifconfig in 7.5 = yum install net-tools

Read more »

UDP

UDP is a transport layer protocol which is only implemented at the hosts. It’s datagram oriented, unreliable and connectionless. It supports unicast and multicast and commonly be used for network control signaling services – Network management (SNMP), routing (RIP), DNS, TFTP.

Read more »

1
echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 1.7)" >> ~/.bash_profile

TCP

TCP is a transport layer protocol provides connection-oriented, reliable service to applications. It supports unicast only. TCP connection uses socket: the combination of an IP address and a port number which is uniquely identified by the two end sockets. TCP connection establishment: two end TCP modules allocate required resources for the connection and negotiate the value of the parameter uses such as maximum segment size(MSS), given by the receiver side, and receiving buffer size(advertised window, WIN). Initial sequence number(ISN), specified by the sender side.

Read more »

Map-Reduce

RDBMS/SQL empowers us by restricting how we store and query data.

Map-Reduce empowers us by restrcting how we implement algorithms.

Read more »

Sieve of Eratosthenes
  1. Create a list contains number from 2 to n.

  2. Initially, set p to 2 which is the first prime number.

  3. Starting from p^2, mark p*(p+1), p*(p+2), p*(p+3)… as not prime numbers

  4. Find the smallest number greater than p that is not marked in the list, and repeat from step 3. If there is no such number, stop.

    Time Complexity: O(nlog(log(n)))

    Read more »

Python Decorator

Naming a property starting with a single underscore implies that the property is protected and is not recommended for direct access, so if you want to access the property, you can do so using the getter and setter methods of the property. To do this, consider using the @property wrapper to wrap getter and setter methods to make access to properties secure and convenient, as shown below.

Read more »

Usage for if "__name__" == "__main__":

If the module we import, in addition to defined functions, still has executable code. Then python interpreter would execute this code which is unexpected. Therefore, if we write executable code in modules, better put this code in if "__name__" == "__main__": so that the code under “if” condition won’t be executed unless to execute its module directly. Since only the name of the module to be executed directly is "__main__".

Read more »